Rev 6433: (jelmer) Keep tags for pending merges while uncommitting (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jan 5 17:20:21 UTC 2012


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6433 [merge]
revision-id: pqm at pqm.ubuntu.com-20120105172020-8ccmcfg8ovyg0m0y
parent: pqm at pqm.ubuntu.com-20120105155820-dexlerdo51d5i6j8
parent: jelmer at samba.org-20120105160311-12o5p67kin1v3zps
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2012-01-05 17:20:20 +0000
message:
  (jelmer) Keep tags for pending merges while uncommitting (Jelmer Vernooij)
modified:
  bzrlib/tests/test_uncommit.py  test_uncommit.py-20080316104338-y3gxu67g5m2qih10-1
  bzrlib/uncommit.py             uncommit.py-20050626215513-5ec509fa425b305c
  doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/tests/test_uncommit.py'
--- a/bzrlib/tests/test_uncommit.py	2011-08-22 10:44:29 +0000
+++ b/bzrlib/tests/test_uncommit.py	2011-12-16 19:41:30 +0000
@@ -110,6 +110,27 @@
             "pointsatexisting": history[0]
             }, tree.branch.tags.get_tag_dict())
 
+    def test_uncommit_remove_tags_keeps_pending_merges(self):
+        tree, history = self.make_linear_tree()
+        copy = tree.bzrdir.sprout('copyoftree').open_workingtree()
+        copy.commit(message='merged', rev_id='merged')
+        tree.merge_from_branch(copy.branch)
+        tree.branch.tags.set_tag('pointsatmerged', 'merged')
+        history.append(tree.commit('merge'))
+        self.assertEquals('merged', tree.branch.tags.lookup_tag('pointsatmerged'))
+        self.assertEqual(history[2], tree.last_revision())
+        self.assertEqual((3, history[2]), tree.branch.last_revision_info())
+        tree.branch.tags.set_tag(u"pointsatexisting", history[1])
+        tree.branch.tags.set_tag(u"pointsatremoved", history[2])
+        uncommit.uncommit(tree.branch, tree=tree)
+        self.assertEqual(history[1], tree.last_revision())
+        self.assertEqual((2, history[1]), tree.branch.last_revision_info())
+        self.assertEquals([history[1], 'merged'], tree.get_parent_ids())
+        self.assertEqual({
+            "pointsatexisting": history[1],
+            "pointsatmerged": 'merged',
+            }, tree.branch.tags.get_tag_dict())
+
     def test_uncommit_keep_tags(self):
         tree, history = self.make_linear_tree()
         self.assertEqual(history[1], tree.last_revision())

=== modified file 'bzrlib/uncommit.py'
--- a/bzrlib/uncommit.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/uncommit.py	2012-01-05 16:03:11 +0000
@@ -28,17 +28,17 @@
 from bzrlib.errors import BoundBranchOutOfDate
 
 
-def remove_tags(branch, graph, old_tip, new_tip):
+def remove_tags(branch, graph, old_tip, parents):
     """Remove tags on revisions between old_tip and new_tip.
 
     :param branch: Branch to remove tags from
     :param graph: Graph object for branch repository
     :param old_tip: Old branch tip
-    :param new_tip: New branch tip
+    :param parents: New parents
     :return: Names of the removed tags
     """
     reverse_tags = branch.tags.get_reverse_tag_dict()
-    ancestors = graph.find_unique_ancestors(old_tip, [new_tip])
+    ancestors = graph.find_unique_ancestors(old_tip, parents)
     removed_tags = []
     for revid, tags in reverse_tags.iteritems():
         if not revid in ancestors:
@@ -130,15 +130,15 @@
                     hook_new_tip = None
                 hook(hook_local, hook_master, old_revno, old_tip, new_revno,
                      hook_new_tip)
-            if branch.supports_tags() and not keep_tags:
-                remove_tags(branch, graph, old_tip, new_revision_id)
+            if not _mod_revision.is_null(new_revision_id):
+                parents = [new_revision_id]
+            else:
+                parents = []
             if tree is not None:
-                if not _mod_revision.is_null(new_revision_id):
-                    parents = [new_revision_id]
-                else:
-                    parents = []
                 parents.extend(reversed(pending_merges))
                 tree.set_parent_ids(parents)
+            if branch.supports_tags() and not keep_tags:
+                remove_tags(branch, graph, old_tip, parents)
     finally:
         for item in reversed(unlockable):
             item.unlock()

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2012-01-05 11:39:43 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2012-01-05 16:03:11 +0000
@@ -110,6 +110,9 @@
 * Stop altering ``sys.platform`` on OSX when initialising the locale.
   (Martin Packman, #570495)
 
+* Uncommit no longer removes tags if they are part of the working
+  trees pending merges. (Jelmer Vernooij, #905462)
+
 Documentation
 *************
 




More information about the bazaar-commits mailing list