/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: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
from bzrlib.inventory import Inventory, InventoryEntry, make_entry
73
73
from bzrlib import symbol_versioning
74
74
from bzrlib.urlutils import unescape_for_display
75
 
 
 
75
from bzrlib.i18n import gettext
76
76
 
77
77
class NullCommitReporter(object):
78
78
    """I report on progress of a commit."""
113
113
        note(format, *args)
114
114
 
115
115
    def snapshot_change(self, change, path):
116
 
        if path == '' and change in ('added', 'modified'):
 
116
        if path == '' and change in (gettext('added'), gettext('modified')):
117
117
            return
118
118
        self._note("%s %s", change, path)
119
119
 
127
127
                                   "to started.", DeprecationWarning,
128
128
                                   stacklevel=2)
129
129
            location = ''
130
 
        self._note('Committing%s', location)
 
130
        self._note(gettext('Committing%s'), location)
131
131
 
132
132
    def completed(self, revno, rev_id):
133
 
        self._note('Committed revision %d.', revno)
 
133
        self._note(gettext('Committed revision %d.'), revno)
134
134
        # self._note goes to the console too; so while we want to log the
135
135
        # rev_id, we can't trivially only log it. (See bug 526425). Long
136
136
        # term we should rearrange the reporting structure, but for now
139
139
        mutter('Committed revid %s as revno %d.', rev_id, revno)
140
140
 
141
141
    def deleted(self, path):
142
 
        self._note('deleted %s', path)
 
142
        self._note(gettext('deleted %s'), path)
143
143
 
144
144
    def missing(self, path):
145
 
        self._note('missing %s', path)
 
145
        self._note(gettext('missing %s'), path)
146
146
 
147
147
    def renamed(self, change, old_path, new_path):
148
148
        self._note('%s %s => %s', change, old_path, new_path)
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_conflicts = self.branch.tags.merge_to(self.master_branch.tags)
468
 
            if tag_conflicts:
469
 
                warning_lines = ['    ' + name for name, _, _ in tag_conflicts]
470
 
                note("Conflicting tags in bound branch:\n" +
471
 
                    "\n".join(warning_lines))
 
454
        self._update_branches(old_revno, old_revid, new_revno)
472
455
 
473
456
        # Make the working tree be up to date with the branch. This
474
457
        # includes automatic changes scheduled to be made to the tree, such
481
464
        self._process_post_hooks(old_revno, new_revno)
482
465
        return self.rev_id
483
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
 
484
513
    def _select_reporter(self):
485
514
        """Select the CommitReporter to use."""
486
515
        if is_quiet():
543
572
    def _check_out_of_date_tree(self):
544
573
        """Check that the working tree is up to date.
545
574
 
546
 
        :return: old_revision_number,new_revision_number tuple
 
575
        :return: old_revision_number, old_revision_id, new_revision_number
 
576
            tuple
547
577
        """
548
578
        try:
549
579
            first_tree_parent = self.work_tree.get_parent_ids()[0]
562
592
        else:
563
593
            # ghost parents never appear in revision history.
564
594
            new_revno = 1
565
 
        return old_revno,new_revno
 
595
        return old_revno, master_last, new_revno
566
596
 
567
597
    def _process_pre_hooks(self, old_revno, new_revno):
568
598
        """Process any registered pre commit hooks."""
694
724
                # Reset the new path (None) and new versioned flag (False)
695
725
                change = (change[0], (change[1][0], None), change[2],
696
726
                    (change[3][0], False)) + change[4:]
 
727
                new_path = change[1][1]
 
728
                versioned = False
697
729
            elif kind == 'tree-reference':
698
730
                if self.recursive == 'down':
699
731
                    self._commit_nested_tree(change[0], change[1][1])
703
735
                    if new_path is None:
704
736
                        reporter.deleted(old_path)
705
737
                    elif old_path is None:
706
 
                        reporter.snapshot_change('added', new_path)
 
738
                        reporter.snapshot_change(gettext('added'), new_path)
707
739
                    elif old_path != new_path:
708
 
                        reporter.renamed('renamed', old_path, new_path)
 
740
                        reporter.renamed(gettext('renamed'), old_path, new_path)
709
741
                    else:
710
742
                        if (new_path or 
711
743
                            self.work_tree.branch.repository._format.rich_root_data):
712
744
                            # Don't report on changes to '' in non rich root
713
745
                            # repositories.
714
 
                            reporter.snapshot_change('modified', new_path)
 
746
                            reporter.snapshot_change(gettext('modified'), new_path)
715
747
            self._next_progress_entry()
716
748
        # Unversion IDs that were found to be deleted
717
749
        self.deleted_ids = deleted_ids
940
972
            self.reporter.renamed(change, old_path, path)
941
973
            self._next_progress_entry()
942
974
        else:
943
 
            if change == 'unchanged':
 
975
            if change == gettext('unchanged'):
944
976
                return
945
977
            self.reporter.snapshot_change(change, path)
946
978
            self._next_progress_entry()
962
994
 
963
995
    def _emit_progress(self):
964
996
        if self.pb_entries_count is not None:
965
 
            text = "%s [%d] - Stage" % (self.pb_stage_name,
 
997
            text = gettext("{0} [{1}] - Stage").format(self.pb_stage_name,
966
998
                self.pb_entries_count)
967
999
        else:
968
 
            text = "%s - Stage" % (self.pb_stage_name, )
 
1000
            text = gettext("%s - Stage") % (self.pb_stage_name, )
969
1001
        self.pb.update(text, self.pb_stage_count, self.pb_stage_total)
970
1002
 
971
1003
    def _set_specific_file_ids(self):