~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: abentley
  • Date: 2006-04-20 23:47:53 UTC
  • mfrom: (1681 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1683.
  • Revision ID: abentley@lappy-20060420234753-6a6874b76f09f86d
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
class ReportCommitToLog(NullCommitReporter):
129
129
 
130
130
    def snapshot_change(self, change, path):
 
131
        if change == 'unchanged':
 
132
            return
131
133
        note("%s %s", change, path)
132
134
 
133
135
    def completed(self, revno, rev_id):
134
 
        note('committed r%d {%s}', revno, rev_id)
 
136
        note('Committed revision %d.', revno)
135
137
    
136
138
    def deleted(self, file_id):
137
139
        note('deleted %s', file_id)
179
181
               verbose=False,
180
182
               revprops=None,
181
183
               working_tree=None,
182
 
               local=False):
 
184
               local=False,
 
185
               reporter=None,
 
186
               config=None):
183
187
        """Commit working copy as a new revision.
184
188
 
185
189
        branch -- the deprecated branch to commit to. New callers should pass in 
227
231
        self.bound_branch = None
228
232
        self.local = local
229
233
        self.master_branch = None
 
234
        self.master_locked = False
230
235
        self.rev_id = rev_id
231
236
        self.specific_files = specific_files
232
237
        self.allow_pointless = allow_pointless
234
239
        if revprops is not None:
235
240
            self.revprops.update(revprops)
236
241
 
 
242
        if reporter is None and self.reporter is None:
 
243
            self.reporter = NullCommitReporter()
 
244
        elif reporter is not None:
 
245
            self.reporter = reporter
 
246
 
237
247
        self.work_tree.lock_write()
238
248
        try:
239
249
            # setup the bound branch variables as needed.
299
309
                    or self.new_inv != self.basis_inv):
300
310
                raise PointlessCommit()
301
311
 
302
 
            if len(list(self.work_tree.iter_conflicts()))>0:
 
312
            if len(self.work_tree.conflicts())>0:
303
313
                raise ConflictsInTree
304
314
 
305
315
            self.inv_sha1 = self.branch.repository.add_inventory(
324
334
            self.branch.append_revision(self.rev_id)
325
335
 
326
336
            self.work_tree.set_pending_merges([])
327
 
            if len(self.parents):
328
 
                precursor = self.parents[0]
329
 
            else:
330
 
                precursor = None
331
 
            self.work_tree.set_last_revision(self.rev_id, precursor)
 
337
            self.work_tree.set_last_revision(self.rev_id)
332
338
            # now the work tree is up to date with the branch
333
339
            
334
 
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
 
340
            self.reporter.completed(self.branch.revno(), self.rev_id)
335
341
            if self.config.post_commit() is not None:
336
342
                hooks = self.config.post_commit().split(' ')
337
343
                # this would be nicer with twisted.python.reflect.namedAny
384
390
        # so grab the lock
385
391
        self.bound_branch = self.branch
386
392
        self.master_branch.lock_write()
 
393
        self.master_locked = True
387
394
####        
388
395
####        # Check to see if we have any pending merges. If we do
389
396
####        # those need to be pushed into the master branch
402
409
        """
403
410
        if not self.bound_branch:
404
411
            return
405
 
        self.master_branch.unlock()
 
412
        if self.master_locked:
 
413
            self.master_branch.unlock()
406
414
 
407
415
    def _escape_commit_message(self):
408
416
        """Replace xml-incompatible control characters."""
 
417
        # FIXME: RBC 20060419 this should be done by the revision
 
418
        # serialiser not by commit. Then we can also add an unescaper
 
419
        # in the deserializer and start roundtripping revision messages
 
420
        # precisely. See repository_implementations/test_repository.py
 
421
        
409
422
        # Python strings can include characters that can't be
410
423
        # represented in well-formed XML; escape characters that
411
424
        # aren't listed in the XML specification
492
505
        # mark-merge.  
493
506
        for path, ie in self.new_inv.iter_entries():
494
507
            previous_entries = ie.find_previous_heads(
495
 
                self.parent_invs, 
496
 
                self.weave_store.get_weave_or_empty(ie.file_id,
497
 
                    self.branch.get_transaction()))
 
508
                self.parent_invs,
 
509
                self.weave_store,
 
510
                self.branch.repository.get_transaction())
498
511
            if ie.revision is None:
499
512
                change = ie.snapshot(self.rev_id, path, previous_entries,
500
513
                                     self.work_tree, self.weave_store,
514
527
        revision set to their prior value.
515
528
        """
516
529
        mutter("Selecting files for commit with filter %s", self.specific_files)
517
 
        self.new_inv = Inventory()
 
530
        self.new_inv = Inventory(revision_id=self.rev_id)
518
531
        for path, new_ie in self.work_inv.iter_entries():
519
532
            file_id = new_ie.file_id
520
533
            mutter('check %s {%s}', path, new_ie.file_id)