Merge lp:~gagern/bzr/bug869912-log-root-dir into lp:bzr

Proposed by Martin von Gagern
Status: Work in progress
Proposed branch: lp:~gagern/bzr/bug869912-log-root-dir
Merge into: lp:bzr
Prerequisite: lp:~gagern/bzr/bug869915-mkdir-quiet
Diff against target: 168 lines (+89/-8) (has conflicts)
4 files modified
bzrlib/builtins.py (+5/-6)
bzrlib/log.py (+0/-2)
bzrlib/tests/blackbox/test_log.py (+76/-0)
doc/en/release-notes/bzr-2.5.txt (+8/-0)
Text conflict in doc/en/release-notes/bzr-2.5.txt
To merge this branch: bzr merge lp:~gagern/bzr/bug869912-log-root-dir
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+78612@code.launchpad.net

Commit message

Allow "bzr log dir" to filter on path even if dir names a branch root.

Description of the change

Make "bzr log dir" filter for the given directory even if it is the root directory of its branch. Important for split branches. Use "bzr log -d dir" for old behaviour of listing the complete history of a given branch.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This has a performance impact for e.g. "bzr log ~/src/bzr/bzr.dev". It would be interesting to know how big that impact is.

Presumably "bzr log" inside of a branch would still show the entire history and "bzr log ." would only show that for the current root. Can you add tests for those as well?

Revision history for this message
Martin von Gagern (gagern) wrote :

Performance impact is highly significant, you don't want to run "bzr log bzr.dev" using the current r6202 state of this branch. So there are basically three solutions, I believe:

1. Don't suggest that command. Get users to type "bzr log -d bzr.dev" instead. I fear users might respond to this in a rather negative way, though.

2. Add some kind of optimization. While walking the history, as long as the specified directory is the root directory, don't do any filtering. Correctly mixing this optimized unfiltered logging with slow filtered logging in the presence of split/join might be tricky, though.

An even better solution would be some general performance improvement for filtered logging. After all, there could theoretically be projects the size of bzr.dev contained in some directories of even larger projects, so filtering by subdir on that scale might be desirable. Have you ever discussed possibilities for this? How do other dvcs handle such requests?

6203. By Martin von Gagern

Add blackbox test for full and root-dir log in current working directory.

Revision history for this message
Martin von Gagern (gagern) wrote :

To talk figures: log of bzr.dev took 1.5s with -d, but 300s without it, which amounts to a factor 200 slow down. :-(

Revision history for this message
Martin Packman (gz) wrote :

> To talk figures: log of bzr.dev took 1.5s with -d, but 300s without it, which
> amounts to a factor 200 slow down. :-(

Ow. I actually do this quite a bit when I don't want to cd between two locations. I imagine people who grew up in a shell have more cunning methods.

Revision history for this message
Martin Pool (mbp) wrote :

We can't really merge this as it is given the performance impact, but I would like there to be a way to do this.

One cheap way would be to just add an option that says to follow the previous history of the root.

Perhaps there is a better way to detect it. Making log filtered by ids faster would be well worth while too, but it's unlikely to ever have zero cost.

I'm going to bump this out of the review queue for now but please do ask if you want to talk more about how to solve it.

Unmerged revisions

6203. By Martin von Gagern

Add blackbox test for full and root-dir log in current working directory.

6202. By Martin von Gagern

Fix typo and improve language.

6201. By Martin von Gagern

Document fix for #869912.

6200. By Martin von Gagern

Make use of quiet subdir creation.

6199. By Martin von Gagern

Merge from bug869915-mkdir-quiet

6198. By Martin von Gagern

Merge from bzr.dev

6197. By Martin von Gagern

Removed one more special case handling of root directory.

6196. By Martin von Gagern

Always pass listed directories in file_ids, even for root directory.
Add support for the --directory option to bzr log.
Currently the filtering by root directory still does not work as intended.

6195. By Martin von Gagern

Forgot to commit after split

6194. By Martin von Gagern

Add blackbox test case for bug #869912.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2011-10-14 13:56:45 +0000
+++ bzrlib/builtins.py 2011-10-17 12:24:37 +0000
@@ -2465,6 +2465,7 @@
2465 takes_args = ['file*']2465 takes_args = ['file*']
2466 _see_also = ['log-formats', 'revisionspec']2466 _see_also = ['log-formats', 'revisionspec']
2467 takes_options = [2467 takes_options = [
2468 'directory',
2468 Option('forward',2469 Option('forward',
2469 help='Show from oldest to newest.'),2470 help='Show from oldest to newest.'),
2470 'timezone',2471 'timezone',
@@ -2559,6 +2560,7 @@
2559 match_author=None,2560 match_author=None,
2560 match_bugs=None,2561 match_bugs=None,
2561 omit_merges=False,2562 omit_merges=False,
2563 directory=None,
2562 include_merges=symbol_versioning.DEPRECATED_PARAMETER,2564 include_merges=symbol_versioning.DEPRECATED_PARAMETER,
2563 ):2565 ):
2564 from bzrlib.log import (2566 from bzrlib.log import (
@@ -2615,12 +2617,7 @@
2615 raise errors.BzrCommandError(gettext(2617 raise errors.BzrCommandError(gettext(
2616 "Path unknown at end or start of revision range: %s") %2618 "Path unknown at end or start of revision range: %s") %
2617 relpath)2619 relpath)
2618 # If the relpath is the top of the tree, we log everything2620 file_ids.append(file_id)
2619 if relpath == '':
2620 file_ids = []
2621 break
2622 else:
2623 file_ids.append(file_id)
2624 filter_by_dir = filter_by_dir or (2621 filter_by_dir = filter_by_dir or (
2625 kind in ['directory', 'tree-reference'])2622 kind in ['directory', 'tree-reference'])
2626 else:2623 else:
@@ -2629,6 +2626,8 @@
2629 if revision is not None \2626 if revision is not None \
2630 and len(revision) > 0 and revision[0].get_branch():2627 and len(revision) > 0 and revision[0].get_branch():
2631 location = revision[0].get_branch()2628 location = revision[0].get_branch()
2629 elif directory is not None:
2630 location = directory
2632 else:2631 else:
2633 location = '.'2632 location = '.'
2634 dir, relpath = controldir.ControlDir.open_containing(location)2633 dir, relpath = controldir.ControlDir.open_containing(location)
26352634
=== modified file 'bzrlib/log.py'
--- bzrlib/log.py 2011-10-14 13:56:45 +0000
+++ bzrlib/log.py 2011-10-17 12:24:37 +0000
@@ -2047,8 +2047,6 @@
2047 info_list = []2047 info_list = []
2048 start_rev_info, end_rev_info = _get_revision_range(revisionspec_list, b,2048 start_rev_info, end_rev_info = _get_revision_range(revisionspec_list, b,
2049 "log")2049 "log")
2050 if relpaths in ([], [u'']):
2051 return b, [], start_rev_info, end_rev_info
2052 if start_rev_info is None and end_rev_info is None:2050 if start_rev_info is None and end_rev_info is None:
2053 if tree is None:2051 if tree is None:
2054 tree = b.basis_tree()2052 tree = b.basis_tree()
20552053
=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- bzrlib/tests/blackbox/test_log.py 2011-10-12 16:00:13 +0000
+++ bzrlib/tests/blackbox/test_log.py 2011-10-17 12:24:37 +0000
@@ -30,6 +30,7 @@
30from bzrlib.tests import (30from bzrlib.tests import (
31 test_log,31 test_log,
32 features,32 features,
33 script,
33 )34 )
3435
3536
@@ -1052,3 +1053,78 @@
1052 self.assertLogRevnos(["--match-author", "author"], ["2", "1"])1053 self.assertLogRevnos(["--match-author", "author"], ["2", "1"])
1053 self.assertLogRevnos(["--match-author", "author1", 1054 self.assertLogRevnos(["--match-author", "author1",
1054 "--match-author", "author2"], ["2", "1"])1055 "--match-author", "author2"], ["2", "1"])
1056
1057
1058class TestLogScripts(script.TestCaseWithTransportAndScript):
1059
1060 def test_root_of_split_branch_subdir(self):
1061 self.run_script("""\
1062$ bzr init -q .
1063$ bzr mkdir -q sub
1064$ echo foo_content > sub/foo
1065$ bzr add -q sub/foo
1066$ bzr commit -q -m "created sub"
1067$ echo bar_content > bar
1068$ bzr add -q bar
1069$ bzr commit -q -m "not modifying sub"
1070$ bzr split sub
1071$ bzr commit -q -m "split sub from its parent" sub
1072$ bzr log --log-format=line sub
10733: ... split sub from its parent
10741: ... created sub
1075""")
1076
1077 def test_whole_history_of_split_branch_subdir(self):
1078 self.run_script("""\
1079$ bzr init -q .
1080$ bzr mkdir -q sub
1081$ echo foo_content > sub/foo
1082$ bzr add -q sub/foo
1083$ bzr commit -q -m "created sub"
1084$ echo bar_content > bar
1085$ bzr add -q bar
1086$ bzr commit -q -m "not modifying sub"
1087$ bzr split sub
1088$ bzr commit -q -m "split sub from its parent" sub
1089$ bzr log --log-format=line -d sub
10903: ... split sub from its parent
10912: ... not modifying sub
10921: ... created sub
1093""")
1094
1095 def test_root_of_split_branch_curdir(self):
1096 self.run_script("""\
1097$ bzr init -q .
1098$ bzr mkdir -q sub
1099$ echo foo_content > sub/foo
1100$ bzr add -q sub/foo
1101$ bzr commit -q -m "created sub"
1102$ echo bar_content > bar
1103$ bzr add -q bar
1104$ bzr commit -q -m "not modifying sub"
1105$ bzr split sub
1106$ bzr commit -q -m "split sub from its parent" sub
1107$ cd sub
1108$ bzr log --log-format=line .
11093: ... split sub from its parent
11101: ... created sub
1111""")
1112
1113 def test_whole_history_of_split_branch_curdir(self):
1114 self.run_script("""\
1115$ bzr init -q .
1116$ bzr mkdir -q sub
1117$ echo foo_content > sub/foo
1118$ bzr add -q sub/foo
1119$ bzr commit -q -m "created sub"
1120$ echo bar_content > bar
1121$ bzr add -q bar
1122$ bzr commit -q -m "not modifying sub"
1123$ bzr split sub
1124$ bzr commit -q -m "split sub from its parent" sub
1125$ cd sub
1126$ bzr log --log-format=line
11273: ... split sub from its parent
11282: ... not modifying sub
11291: ... created sub
1130""")
10551131
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- doc/en/release-notes/bzr-2.5.txt 2011-10-16 10:05:26 +0000
+++ doc/en/release-notes/bzr-2.5.txt 2011-10-17 12:24:37 +0000
@@ -51,10 +51,18 @@
51* ``bzr mkdir --quiet`` now does not print a line for every created51* ``bzr mkdir --quiet`` now does not print a line for every created
52 directory. (Martin von Gagern, #869915)52 directory. (Martin von Gagern, #869915)
5353
54<<<<<<< TREE
54* ``bzr shelve`` now use ``UIFactory.choose`` for input handling, making55* ``bzr shelve`` now use ``UIFactory.choose`` for input handling, making
55 it usable when creating a custom ``UIFactory`` implementation. (Benoît56 it usable when creating a custom ``UIFactory`` implementation. (Benoît
56 Pierre)57 Pierre)
5758
59=======
60* ``bzr log dir`` now filters for the given directory even if it is
61 the root directory of its branch. This is important for split
62 branches. Use ``bzr log -d dir`` for old behaviour of listing the
63 complete history of a given branch. (Martin von Gagern, #869912)
64
65>>>>>>> MERGE-SOURCE
58Documentation66Documentation
59*************67*************
6068