Rev 6377: (vila) Relax constraints on bzr log -rX..Y by falling back to the slower in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Dec 15 18:13:53 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6377 [merge]
revision-id: pqm at pqm.ubuntu.com-20111215181352-gsrdj3ma7273pzkt
parent: pqm at pqm.ubuntu.com-20111215124354-r79d90ukkqzpfeyf
parent: v.ladeuil+lp at free.fr-20111215144722-fie3up92mth126r5
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-12-15 18:13:52 +0000
message:
(vila) Relax constraints on bzr log -rX..Y by falling back to the slower
implementation when needed (Vincent Ladeuil)
modified:
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py 2011-11-23 18:59:43 +0000
+++ b/bzrlib/log.py 2011-12-15 14:47:22 +0000
@@ -580,20 +580,32 @@
and (not generate_merge_revisions
or not _has_merges(branch, end_rev_id))):
# If a single revision is requested, check we can handle it
- iter_revs = _generate_one_revision(branch, end_rev_id, br_rev_id,
- br_revno)
- elif not generate_merge_revisions:
- # If we only want to see linear revisions, we can iterate ...
- iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
- direction, exclude_common_ancestry)
- if direction == 'forward':
- iter_revs = reversed(iter_revs)
- else:
- iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
- direction, delayed_graph_generation,
- exclude_common_ancestry)
- if direction == 'forward':
- iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
+ return _generate_one_revision(branch, end_rev_id, br_rev_id,
+ br_revno)
+ if not generate_merge_revisions:
+ try:
+ # If we only want to see linear revisions, we can iterate ...
+ iter_revs = _linear_view_revisions(
+ branch, start_rev_id, end_rev_id,
+ exclude_common_ancestry=exclude_common_ancestry)
+ # If a start limit was given and it's not obviously an
+ # ancestor of the end limit, check it before outputting anything
+ if (direction == 'forward'
+ or (start_rev_id and not _is_obvious_ancestor(
+ branch, start_rev_id, end_rev_id))):
+ iter_revs = list(iter_revs)
+ if direction == 'forward':
+ iter_revs = reversed(iter_revs)
+ return iter_revs
+ except _StartNotLinearAncestor:
+ # Switch to the slower implementation that may be able to find a
+ # non-obvious ancestor out of the left-hand history.
+ pass
+ iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
+ direction, delayed_graph_generation,
+ exclude_common_ancestry)
+ if direction == 'forward':
+ iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
return iter_revs
@@ -606,23 +618,6 @@
return [(rev_id, revno_str, 0)]
-def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction,
- exclude_common_ancestry=False):
- result = _linear_view_revisions(
- branch, start_rev_id, end_rev_id,
- exclude_common_ancestry=exclude_common_ancestry)
- # If a start limit was given and it's not obviously an
- # ancestor of the end limit, check it before outputting anything
- if direction == 'forward' or (start_rev_id
- and not _is_obvious_ancestor(branch, start_rev_id, end_rev_id)):
- try:
- result = list(result)
- except _StartNotLinearAncestor:
- raise errors.BzrCommandError(gettext('Start revision not found in'
- ' left-hand history of end revision.'))
- return result
-
-
def _generate_all_revisions(branch, start_rev_id, end_rev_id, direction,
delayed_graph_generation,
exclude_common_ancestry=False):
=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- a/bzrlib/tests/blackbox/test_log.py 2011-12-14 20:08:26 +0000
+++ b/bzrlib/tests/blackbox/test_log.py 2011-12-15 14:47:22 +0000
@@ -205,6 +205,10 @@
# 4 1.1.4
# | /
# 5
+ # | \
+ # | 5.1.1
+ # | /
+ # 6
# mainline
builder.build_snapshot('1', None, [
@@ -223,6 +227,8 @@
builder.build_snapshot('1.1.4', ['1.1.3', '4'], [])
# merge branch into mainline
builder.build_snapshot('5', ['4', '1.1.4'], [])
+ builder.build_snapshot('5.1.1', ['5'], [])
+ builder.build_snapshot('6', ['5', '5.1.1'], [])
builder.finish_series()
def test_n0(self):
@@ -241,6 +247,11 @@
self.assertLogRevnos(['-n1', '-r1.1.1..1.1.4', '--forward'],
['1.1.1', '1.1.2', '1.1.3', '1.1.4'])
+ def test_fallback_when_end_rev_is_not_on_mainline(self):
+ self.assertLogRevnos(['-n1', '-r1.1.1..5.1.1'],
+ # We don't get 1.1.1 because we say -n1
+ ['5.1.1', '5', '4', '3'])
+
class Test_GenerateAllRevisions(TestLogWithLogCatcher):
@@ -258,6 +269,19 @@
# The graph below may look a bit complicated (and it may be but I've
# banged my head enough on it) but the bug requires at least dotted
# revnos *and* merged revisions below that.
+ # 1
+ # | \
+ # 2 1.1.1
+ # | X
+ # 3 2.1.1
+ # | | \
+ # | 2.1.2 2.2.1
+ # | | X
+ # | 2.1.3 \
+ # | / /
+ # 4 /
+ # | /
+ # 5 -----/
builder.build_snapshot('1', None, [
('add', ('', 'root-id', 'directory', ''))])
builder.build_snapshot('2', ['1'], [])
@@ -382,7 +406,7 @@
def test_log_reversed_dotted_revspecs(self):
self.make_merged_branch()
self.run_bzr_error(('bzr: ERROR: Start revision not found in '
- 'left-hand history of end revision.\n',),
+ 'history of end revision.\n',),
"log -r 1.1.1..1")
def test_log_bad_message_re(self):
=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py 2011-11-23 11:22:56 +0000
+++ b/bzrlib/tests/test_log.py 2011-12-15 14:47:22 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2010 Canonical Ltd
+# Copyright (C) 2005-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1569,7 +1569,7 @@
def assertLogRevnos(self, expected_revnos, b, start, end,
exclude_common_ancestry, generate_merge_revisions=True):
# FIXME: the layering in log makes it hard to test intermediate levels,
- # I wish adding filters with their parameters were easier...
+ # I wish adding filters with their parameters was easier...
# -- vila 20100413
iter_revs = log._calc_view_revisions(
b, start, end, direction='reverse',
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-12-15 11:54:55 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-12-15 14:47:22 +0000
@@ -56,6 +56,10 @@
* Create obsolete_packs directory when repacking if it does not
exist. (Jonathan Riddell, Jelmer Vernooij, #314314)
+* Fallback to the slower ``bzr log`` implementation when displaying a range
+ of revisions whose ancestry is not obviously on the same developement
+ line. (Vincent Ladeuil, #904744)
+
* Not setting ``gpg_signing_key`` or setting it to ``default`` will use the
user email (obtained from the ``email`` configuration option or its
default value). (Vincent Ladeuil, Jelmer Vernooij, #904550)
More information about the bazaar-commits
mailing list