/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: Jelmer Vernooij
  • Date: 2011-11-25 17:54:52 UTC
  • mfrom: (6303 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6321.
  • Revision ID: jelmer@samba.org-20111125175452-v0uwwxqcp97tzuzv
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
363
363
        self._check_bound_branch(operation, possible_master_transports)
364
364
 
365
365
        # Check that the working tree is up to date
366
 
        old_revno, new_revno = self._check_out_of_date_tree()
 
366
        old_revno, old_revid, new_revno = self._check_out_of_date_tree()
367
367
 
368
368
        # Complete configuration setup
369
369
        if reporter is not None:
411
411
            self.builder.abort()
412
412
            raise errors.ExcludesUnsupported(self.branch.repository)
413
413
 
 
414
        if self.builder.updates_branch and self.bound_branch:
 
415
            self.builder.abort()
 
416
            raise AssertionError(
 
417
                "bound branches not supported for commit builders "
 
418
                "that update the branch")
 
419
 
414
420
        try:
415
421
            self.builder.will_record_deletes()
416
422
            # find the location being committed to
445
451
            self.builder.abort()
446
452
            raise
447
453
 
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)
463
 
 
464
 
        # Merge local tags to remote
465
 
        if self.bound_branch:
466
 
            self._set_progress_stage("Merging tags to master branch")
467
 
            tag_updates, tag_conflicts = self.branch.tags.merge_to(
468
 
                self.master_branch.tags)
469
 
            if tag_conflicts:
470
 
                warning_lines = ['    ' + name for name, _, _ in tag_conflicts]
471
 
                note( gettext("Conflicting tags in bound branch:\n{0}".format(
472
 
                    "\n".join(warning_lines))) )
 
454
        self._update_branches(old_revno, old_revid, new_revno)
473
455
 
474
456
        # Make the working tree be up to date with the branch. This
475
457
        # includes automatic changes scheduled to be made to the tree, such
482
464
        self._process_post_hooks(old_revno, new_revno)
483
465
        return self.rev_id
484
466
 
 
467
    def _update_branches(self, old_revno, old_revid, new_revno):
 
468
        """Update the master and local branch to the new revision.
 
469
 
 
470
        This will try to make sure that the master branch is updated
 
471
        before the local branch.
 
472
 
 
473
        :param old_revno: Revision number of master branch before the
 
474
            commit
 
475
        :param old_revid: Tip of master branch before the commit
 
476
        :param new_revno: Revision number of the new commit
 
477
        """
 
478
        if not self.builder.updates_branch:
 
479
            self._process_pre_hooks(old_revno, new_revno)
 
480
 
 
481
            # Upload revision data to the master.
 
482
            # this will propagate merged revisions too if needed.
 
483
            if self.bound_branch:
 
484
                self._set_progress_stage("Uploading data to master branch")
 
485
                # 'commit' to the master first so a timeout here causes the
 
486
                # local branch to be out of date
 
487
                (new_revno, self.rev_id) = self.master_branch.import_last_revision_info_and_tags(
 
488
                    self.branch, new_revno, self.rev_id, lossy=self._lossy)
 
489
                if self._lossy:
 
490
                    self.branch.fetch(self.master_branch, self.rev_id)
 
491
 
 
492
            # and now do the commit locally.
 
493
            self.branch.set_last_revision_info(new_revno, self.rev_id)
 
494
        else:
 
495
            try:
 
496
                self._process_pre_hooks(old_revno, new_revno)
 
497
            except:
 
498
                # The commit builder will already have updated the branch,
 
499
                # revert it.
 
500
                self.branch.set_last_revision_info(old_revno, old_revid)
 
501
                raise
 
502
 
 
503
        # Merge local tags to remote
 
504
        if self.bound_branch:
 
505
            self._set_progress_stage("Merging tags to master branch")
 
506
            tag_updates, tag_conflicts = self.branch.tags.merge_to(
 
507
                self.master_branch.tags)
 
508
            if tag_conflicts:
 
509
                warning_lines = ['    ' + name for name, _, _ in tag_conflicts]
 
510
                note( gettext("Conflicting tags in bound branch:\n{0}".format(
 
511
                    "\n".join(warning_lines))) )
 
512
 
485
513
    def _select_reporter(self):
486
514
        """Select the CommitReporter to use."""
487
515
        if is_quiet():
544
572
    def _check_out_of_date_tree(self):
545
573
        """Check that the working tree is up to date.
546
574
 
547
 
        :return: old_revision_number,new_revision_number tuple
 
575
        :return: old_revision_number, old_revision_id, new_revision_number
 
576
            tuple
548
577
        """
549
578
        try:
550
579
            first_tree_parent = self.work_tree.get_parent_ids()[0]
563
592
        else:
564
593
            # ghost parents never appear in revision history.
565
594
            new_revno = 1
566
 
        return old_revno,new_revno
 
595
        return old_revno, master_last, new_revno
567
596
 
568
597
    def _process_pre_hooks(self, old_revno, new_revno):
569
598
        """Process any registered pre commit hooks."""