Merge lp:~vila/bzr/575631-exclude-ancestry into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5285
Proposed branch: lp:~vila/bzr/575631-exclude-ancestry
Merge into: lp:bzr
Diff against target: 166 lines (+53/-11) (has conflicts)
4 files modified
NEWS (+7/-0)
bzrlib/log.py (+14/-7)
bzrlib/tests/blackbox/test_log.py (+20/-0)
bzrlib/tests/test_log.py (+12/-4)
Text conflict in NEWS
To merge this branch: bzr merge lp:~vila/bzr/575631-exclude-ancestry
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+27228@code.launchpad.net

Commit message

``bzr log --exclude-common-ancestry`` works for linear ancestries.

Description of the change

log has too many code paths, some were forgotten when --exclude-ancestry was implemented.

This proposal fixes the cases where simple revnos are used.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/bzr/575631-exclude-ancestry into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #575631 "bzr log --exclude-common-ancestry -rX..Y" inconsistent
> https://bugs.launchpad.net/bugs/575631
>
>
> log has too many code paths, some were forgotten when --exclude-ancestry was implemented.
>
> This proposal fixes the cases where simple revnos are used.
>

 merge: approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwQ3KQACgkQJdeBCYSNAAPWvQCfbP/TRBO5oR2B5DJdg1NEZVf8
TZ8AoLuU7aoXU8Pavrs9abBrEBOVF1X6
=IB3i
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-06-07 02:38:04 +0000
3+++ NEWS 2010-06-10 07:12:29 +0000
4@@ -24,10 +24,17 @@
5 Bug Fixes
6 *********
7
8+<<<<<<< TREE
9 * ``bzr init`` does not recursively scan directory contents anymore
10 leading to faster init for directories with existing content.
11 (Martin [gz], Parth Malwankar, #501307)
12
13+=======
14+* ``bzr log --exclude-common-ancestry`` is now taken into account for
15+ linear ancetries.
16+ (Vincent Ladeuil, #575631)
17+
18+>>>>>>> MERGE-SOURCE
19 * Final fix for 'no help for command' issue. We now show a clean message
20 when a command has no help, document how to set help more clearly, and
21 test that all commands available to the test suite have help.
22
23=== modified file 'bzrlib/log.py'
24--- bzrlib/log.py 2010-05-11 08:44:59 +0000
25+++ bzrlib/log.py 2010-06-10 07:12:29 +0000
26@@ -522,7 +522,7 @@
27 elif not generate_merge_revisions:
28 # If we only want to see linear revisions, we can iterate ...
29 iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
30- direction)
31+ direction, exclude_common_ancestry)
32 if direction == 'forward':
33 iter_revs = reversed(iter_revs)
34 else:
35@@ -544,8 +544,11 @@
36 return [(rev_id, revno_str, 0)]
37
38
39-def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction):
40- result = _linear_view_revisions(branch, start_rev_id, end_rev_id)
41+def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction,
42+ exclude_common_ancestry=False):
43+ result = _linear_view_revisions(
44+ branch, start_rev_id, end_rev_id,
45+ exclude_common_ancestry=exclude_common_ancestry)
46 # If a start limit was given and it's not obviously an
47 # ancestor of the end limit, check it before outputting anything
48 if direction == 'forward' or (start_rev_id
49@@ -572,7 +575,7 @@
50 if delayed_graph_generation:
51 try:
52 for rev_id, revno, depth in _linear_view_revisions(
53- branch, start_rev_id, end_rev_id):
54+ branch, start_rev_id, end_rev_id, exclude_common_ancestry):
55 if _has_merges(branch, rev_id):
56 # The end_rev_id can be nested down somewhere. We need an
57 # explicit ancestry check. There is an ambiguity here as we
58@@ -643,14 +646,17 @@
59 return True
60
61
62-def _linear_view_revisions(branch, start_rev_id, end_rev_id):
63+def _linear_view_revisions(branch, start_rev_id, end_rev_id,
64+ exclude_common_ancestry=False):
65 """Calculate a sequence of revisions to view, newest to oldest.
66
67 :param start_rev_id: the lower revision-id
68 :param end_rev_id: the upper revision-id
69+ :param exclude_common_ancestry: Whether the start_rev_id should be part of
70+ the iterated revisions.
71 :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples.
72 :raises _StartNotLinearAncestor: if a start_rev_id is specified but
73- is not found walking the left-hand history
74+ is not found walking the left-hand history
75 """
76 br_revno, br_rev_id = branch.last_revision_info()
77 repo = branch.repository
78@@ -667,7 +673,8 @@
79 revno = branch.revision_id_to_dotted_revno(revision_id)
80 revno_str = '.'.join(str(n) for n in revno)
81 if not found_start and revision_id == start_rev_id:
82- yield revision_id, revno_str, 0
83+ if not exclude_common_ancestry:
84+ yield revision_id, revno_str, 0
85 found_start = True
86 break
87 else:
88
89=== modified file 'bzrlib/tests/blackbox/test_log.py'
90--- bzrlib/tests/blackbox/test_log.py 2010-04-14 12:30:17 +0000
91+++ bzrlib/tests/blackbox/test_log.py 2010-06-10 07:12:29 +0000
92@@ -159,6 +159,14 @@
93 self.assertLogRevnos(['-c1'], ['1'])
94
95
96+class TestLogExcludeCommonAncestry(TestLogWithLogCatcher):
97+
98+ def test_exclude_common_ancestry_simple_revnos(self):
99+ self.make_linear_branch()
100+ self.assertLogRevnos(['-r1..3', '--exclude-common-ancestry'],
101+ ['3', '2'])
102+
103+
104 class TestLogMergedLinearAncestry(TestLogWithLogCatcher):
105
106 def setUp(self):
107@@ -167,6 +175,18 @@
108 # stop calling run_bzr, there is no point) --vila 100118.
109 builder = branchbuilder.BranchBuilder(self.get_transport())
110 builder.start_series()
111+ # 1
112+ # | \
113+ # 2 1.1.1
114+ # | / |
115+ # 3 1.1.2
116+ # | |
117+ # | 1.1.3
118+ # | / |
119+ # 4 1.1.4
120+ # | /
121+ # 5
122+
123 # mainline
124 builder.build_snapshot('1', None, [
125 ('add', ('', 'root-id', 'directory', ''))])
126
127=== modified file 'bzrlib/tests/test_log.py'
128--- bzrlib/tests/test_log.py 2010-05-05 08:18:32 +0000
129+++ bzrlib/tests/test_log.py 2010-06-10 07:12:29 +0000
130@@ -1724,13 +1724,13 @@
131 return br
132
133 def assertLogRevnos(self, expected_revnos, b, start, end,
134- exclude_common_ancestry):
135+ exclude_common_ancestry, generate_merge_revisions=True):
136 # FIXME: the layering in log makes it hard to test intermediate levels,
137 # I wish adding filters with their parameters were easier...
138 # -- vila 20100413
139 iter_revs = log._calc_view_revisions(
140 b, start, end, direction='reverse',
141- generate_merge_revisions=True,
142+ generate_merge_revisions=generate_merge_revisions,
143 exclude_common_ancestry=exclude_common_ancestry)
144 self.assertEqual(expected_revnos,
145 [revid for revid, revno, depth in iter_revs])
146@@ -1738,11 +1738,19 @@
147 def test_merge_sorted_exclude_ancestry(self):
148 b = self.make_branch_with_alternate_ancestries()
149 self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
150- b, '1', '3', False)
151+ b, '1', '3', exclude_common_ancestry=False)
152 # '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
153 # it should be mentioned even if merge_sort order will make it appear
154 # after 1.1.1
155 self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
156- b, '1.1.1', '3', True)
157+ b, '1.1.1', '3', exclude_common_ancestry=True)
158
159+ def test_merge_sorted_simple_revnos_exclude_ancestry(self):
160+ b = self.make_branch_with_alternate_ancestries()
161+ self.assertLogRevnos(['3', '2'],
162+ b, '1', '3', exclude_common_ancestry=True,
163+ generate_merge_revisions=False)
164+ self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2'],
165+ b, '1', '3', exclude_common_ancestry=True,
166+ generate_merge_revisions=True)
167