/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Aaron Bentley
  • Date: 2007-02-16 07:02:19 UTC
  • mfrom: (2292 +trunk)
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20070216070219-b22k0gwnisnxawnk
Merged bzr.dev (17 tests failing)

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    inventory,
62
62
    tree,
63
63
    )
 
64
from bzrlib.branch import Branch
64
65
import bzrlib.config
65
66
from bzrlib.errors import (BzrError, PointlessCommit,
66
67
                           ConflictsInTree,
256
257
                # this is so that we still consier the master branch
257
258
                # - in a checkout scenario the tree may have no
258
259
                # parents but the branch may do.
259
 
                first_tree_parent = None
260
 
            master_last = self.master_branch.last_revision()
261
 
            if (master_last is not None and
262
 
                master_last != first_tree_parent):
263
 
                raise errors.OutOfDateTree(self.work_tree)
264
 
    
 
260
                first_tree_parent = bzrlib.revision.NULL_REVISION
 
261
            old_revno, master_last = self.master_branch.last_revision_info()
 
262
            if master_last != first_tree_parent:
 
263
                if master_last != bzrlib.revision.NULL_REVISION:
 
264
                    raise errors.OutOfDateTree(self.work_tree)
 
265
            if self.branch.repository.has_revision(first_tree_parent):
 
266
                new_revno = old_revno + 1
 
267
            else:
 
268
                # ghost parents never appear in revision history.
 
269
                new_revno = 1
265
270
            if strict:
266
271
                # raise an exception as soon as we find a single unknown.
267
272
                for unknown in self.work_tree.unknowns():
325
330
                # now the master has the revision data
326
331
                # 'commit' to the master first so a timeout here causes the local
327
332
                # branch to be out of date
328
 
                self.master_branch.append_revision(self.rev_id)
 
333
                self.master_branch.set_last_revision_info(new_revno,
 
334
                                                          self.rev_id)
329
335
 
330
336
            # and now do the commit locally.
331
 
            self.branch.append_revision(self.rev_id)
 
337
            self.branch.set_last_revision_info(new_revno, self.rev_id)
332
338
 
333
339
            rev_tree = self.builder.revision_tree()
334
340
            self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
335
341
            # now the work tree is up to date with the branch
336
342
            
337
 
            self.reporter.completed(self.branch.revno(), self.rev_id)
 
343
            self.reporter.completed(new_revno, self.rev_id)
 
344
            # old style commit hooks - should be deprecated ? (obsoleted in
 
345
            # 0.15)
338
346
            if self.config.post_commit() is not None:
339
347
                hooks = self.config.post_commit().split(' ')
340
348
                # this would be nicer with twisted.python.reflect.namedAny
343
351
                                  {'branch':self.branch,
344
352
                                   'bzrlib':bzrlib,
345
353
                                   'rev_id':self.rev_id})
 
354
            # new style commit hooks:
 
355
            if not self.bound_branch:
 
356
                hook_master = self.branch
 
357
                hook_local = None
 
358
            else:
 
359
                hook_master = self.master_branch
 
360
                hook_local = self.branch
 
361
            # With bound branches, when the master is behind the local branch,
 
362
            # the 'old_revno' and old_revid values here are incorrect.
 
363
            # XXX: FIXME ^. RBC 20060206
 
364
            if self.parents:
 
365
                old_revid = self.parents[0]
 
366
            else:
 
367
                old_revid = bzrlib.revision.NULL_REVISION
 
368
            for hook in Branch.hooks['post_commit']:
 
369
                hook(hook_local, hook_master, old_revno, old_revid, new_revno,
 
370
                    self.rev_id)
346
371
            self._emit_progress_update()
347
372
        finally:
348
373
            self._cleanup()
502
527
        # TODO: Make sure that this list doesn't contain duplicate 
503
528
        # entries and the order is preserved when doing this.
504
529
        self.parents = self.work_tree.get_parent_ids()
505
 
        self.parent_invs = []
506
 
        for revision in self.parents:
 
530
        self.parent_invs = [self.basis_inv]
 
531
        for revision in self.parents[1:]:
507
532
            if self.branch.repository.has_revision(revision):
508
533
                mutter('commit parent revision {%s}', revision)
509
534
                inventory = self.branch.repository.get_inventory(revision)