Merge lp:~jelmer/bzr/uncommit-keeps-pending-merge-tags into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 6433
Proposed branch: lp:~jelmer/bzr/uncommit-keeps-pending-merge-tags
Merge into: lp:bzr
Diff against target: 91 lines (+33/-9)
3 files modified
bzrlib/tests/test_uncommit.py (+21/-0)
bzrlib/uncommit.py (+9/-9)
doc/en/release-notes/bzr-2.5.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/uncommit-keeps-pending-merge-tags
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+86106@code.launchpad.net

Commit message

Keep tags for pending merges while uncommitting

Description of the change

Make uncommit no longer remove tags if they are pointing to revisions that are in pending merges.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Nice test, well done.

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/test_uncommit.py'
2--- bzrlib/tests/test_uncommit.py 2011-08-22 10:44:29 +0000
3+++ bzrlib/tests/test_uncommit.py 2012-01-05 16:09:25 +0000
4@@ -110,6 +110,27 @@
5 "pointsatexisting": history[0]
6 }, tree.branch.tags.get_tag_dict())
7
8+ def test_uncommit_remove_tags_keeps_pending_merges(self):
9+ tree, history = self.make_linear_tree()
10+ copy = tree.bzrdir.sprout('copyoftree').open_workingtree()
11+ copy.commit(message='merged', rev_id='merged')
12+ tree.merge_from_branch(copy.branch)
13+ tree.branch.tags.set_tag('pointsatmerged', 'merged')
14+ history.append(tree.commit('merge'))
15+ self.assertEquals('merged', tree.branch.tags.lookup_tag('pointsatmerged'))
16+ self.assertEqual(history[2], tree.last_revision())
17+ self.assertEqual((3, history[2]), tree.branch.last_revision_info())
18+ tree.branch.tags.set_tag(u"pointsatexisting", history[1])
19+ tree.branch.tags.set_tag(u"pointsatremoved", history[2])
20+ uncommit.uncommit(tree.branch, tree=tree)
21+ self.assertEqual(history[1], tree.last_revision())
22+ self.assertEqual((2, history[1]), tree.branch.last_revision_info())
23+ self.assertEquals([history[1], 'merged'], tree.get_parent_ids())
24+ self.assertEqual({
25+ "pointsatexisting": history[1],
26+ "pointsatmerged": 'merged',
27+ }, tree.branch.tags.get_tag_dict())
28+
29 def test_uncommit_keep_tags(self):
30 tree, history = self.make_linear_tree()
31 self.assertEqual(history[1], tree.last_revision())
32
33=== modified file 'bzrlib/uncommit.py'
34--- bzrlib/uncommit.py 2011-12-19 13:23:58 +0000
35+++ bzrlib/uncommit.py 2012-01-05 16:09:25 +0000
36@@ -28,17 +28,17 @@
37 from bzrlib.errors import BoundBranchOutOfDate
38
39
40-def remove_tags(branch, graph, old_tip, new_tip):
41+def remove_tags(branch, graph, old_tip, parents):
42 """Remove tags on revisions between old_tip and new_tip.
43
44 :param branch: Branch to remove tags from
45 :param graph: Graph object for branch repository
46 :param old_tip: Old branch tip
47- :param new_tip: New branch tip
48+ :param parents: New parents
49 :return: Names of the removed tags
50 """
51 reverse_tags = branch.tags.get_reverse_tag_dict()
52- ancestors = graph.find_unique_ancestors(old_tip, [new_tip])
53+ ancestors = graph.find_unique_ancestors(old_tip, parents)
54 removed_tags = []
55 for revid, tags in reverse_tags.iteritems():
56 if not revid in ancestors:
57@@ -130,15 +130,15 @@
58 hook_new_tip = None
59 hook(hook_local, hook_master, old_revno, old_tip, new_revno,
60 hook_new_tip)
61- if branch.supports_tags() and not keep_tags:
62- remove_tags(branch, graph, old_tip, new_revision_id)
63+ if not _mod_revision.is_null(new_revision_id):
64+ parents = [new_revision_id]
65+ else:
66+ parents = []
67 if tree is not None:
68- if not _mod_revision.is_null(new_revision_id):
69- parents = [new_revision_id]
70- else:
71- parents = []
72 parents.extend(reversed(pending_merges))
73 tree.set_parent_ids(parents)
74+ if branch.supports_tags() and not keep_tags:
75+ remove_tags(branch, graph, old_tip, parents)
76 finally:
77 for item in reversed(unlockable):
78 item.unlock()
79
80=== modified file 'doc/en/release-notes/bzr-2.5.txt'
81--- doc/en/release-notes/bzr-2.5.txt 2012-01-05 11:39:43 +0000
82+++ doc/en/release-notes/bzr-2.5.txt 2012-01-05 16:09:25 +0000
83@@ -110,6 +110,9 @@
84 * Stop altering ``sys.platform`` on OSX when initialising the locale.
85 (Martin Packman, #570495)
86
87+* Uncommit no longer removes tags if they are part of the working
88+ trees pending merges. (Jelmer Vernooij, #905462)
89+
90 Documentation
91 *************
92