~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Jelmer Vernooij
  • Date: 2011-10-15 13:37:45 UTC
  • mto: This revision was merged to the branch mainline in revision 6250.
  • Revision ID: jelmer@samba.org-20111015133745-9acjzqp1177tnaq1
Add CommitBuilder.updates_branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
436
436
            message = message_callback(self)
437
437
            self.message = message
438
438
 
 
439
            if self.builder.updates_branch:
 
440
                # Remember the current last revision, in case
 
441
                # the pre_commit hook raises an exception
 
442
                # and the branch has to be reverted.
 
443
                old_rev_info = self.branch.last_revision_info()
 
444
                if self.bound_branch:
 
445
                    raise AssertionError(
 
446
                        "bound branches not supported for commit builders "
 
447
                        "that update the branch")
 
448
 
439
449
            # Add revision data to the local branch
440
450
            self.rev_id = self.builder.commit(self.message)
441
451
 
445
455
            self.builder.abort()
446
456
            raise
447
457
 
448
 
        self._process_pre_hooks(old_revno, new_revno)
449
 
 
450
 
        # Upload revision data to the master.
451
 
        # this will propagate merged revisions too if needed.
452
 
        if self.bound_branch:
453
 
            self._set_progress_stage("Uploading data to master branch")
454
 
            # 'commit' to the master first so a timeout here causes the
455
 
            # local branch to be out of date
456
 
            (new_revno, self.rev_id) = self.master_branch.import_last_revision_info_and_tags(
457
 
                self.branch, new_revno, self.rev_id, lossy=lossy)
458
 
            if lossy:
459
 
                self.branch.fetch(self.master_branch, self.rev_id)
460
 
 
461
 
        # and now do the commit locally.
462
 
        self.branch.set_last_revision_info(new_revno, self.rev_id)
 
458
        if not self.builder.updates_branch:
 
459
            self._process_pre_hooks(old_revno, new_revno)
 
460
 
 
461
            # Upload revision data to the master.
 
462
            # this will propagate merged revisions too if needed.
 
463
            if self.bound_branch:
 
464
                self._set_progress_stage("Uploading data to master branch")
 
465
                # 'commit' to the master first so a timeout here causes the
 
466
                # local branch to be out of date
 
467
                (new_revno, self.rev_id) = self.master_branch.import_last_revision_info_and_tags(
 
468
                    self.branch, new_revno, self.rev_id, lossy=lossy)
 
469
                if lossy:
 
470
                    self.branch.fetch(self.master_branch, self.rev_id)
 
471
 
 
472
            # and now do the commit locally.
 
473
            self.branch.set_last_revision_info(new_revno, self.rev_id)
 
474
        else:
 
475
            try:
 
476
                self._process_pre_hooks(old_revno, new_revno)
 
477
            except:
 
478
                # The commit builder will already have updated the branch,
 
479
                # revert it.
 
480
                self.branch.set_last_revision_info(
 
481
                    old_rev_info[0], old_rev_info[1])
 
482
                raise
463
483
 
464
484
        # Merge local tags to remote
465
485
        if self.bound_branch: