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
1=== modified file 'bzrlib/builtins.py'
2--- bzrlib/builtins.py 2011-10-14 13:56:45 +0000
3+++ bzrlib/builtins.py 2011-10-17 12:24:37 +0000
4@@ -2465,6 +2465,7 @@
5 takes_args = ['file*']
6 _see_also = ['log-formats', 'revisionspec']
7 takes_options = [
8+ 'directory',
9 Option('forward',
10 help='Show from oldest to newest.'),
11 'timezone',
12@@ -2559,6 +2560,7 @@
13 match_author=None,
14 match_bugs=None,
15 omit_merges=False,
16+ directory=None,
17 include_merges=symbol_versioning.DEPRECATED_PARAMETER,
18 ):
19 from bzrlib.log import (
20@@ -2615,12 +2617,7 @@
21 raise errors.BzrCommandError(gettext(
22 "Path unknown at end or start of revision range: %s") %
23 relpath)
24- # If the relpath is the top of the tree, we log everything
25- if relpath == '':
26- file_ids = []
27- break
28- else:
29- file_ids.append(file_id)
30+ file_ids.append(file_id)
31 filter_by_dir = filter_by_dir or (
32 kind in ['directory', 'tree-reference'])
33 else:
34@@ -2629,6 +2626,8 @@
35 if revision is not None \
36 and len(revision) > 0 and revision[0].get_branch():
37 location = revision[0].get_branch()
38+ elif directory is not None:
39+ location = directory
40 else:
41 location = '.'
42 dir, relpath = controldir.ControlDir.open_containing(location)
43
44=== modified file 'bzrlib/log.py'
45--- bzrlib/log.py 2011-10-14 13:56:45 +0000
46+++ bzrlib/log.py 2011-10-17 12:24:37 +0000
47@@ -2047,8 +2047,6 @@
48 info_list = []
49 start_rev_info, end_rev_info = _get_revision_range(revisionspec_list, b,
50 "log")
51- if relpaths in ([], [u'']):
52- return b, [], start_rev_info, end_rev_info
53 if start_rev_info is None and end_rev_info is None:
54 if tree is None:
55 tree = b.basis_tree()
56
57=== modified file 'bzrlib/tests/blackbox/test_log.py'
58--- bzrlib/tests/blackbox/test_log.py 2011-10-12 16:00:13 +0000
59+++ bzrlib/tests/blackbox/test_log.py 2011-10-17 12:24:37 +0000
60@@ -30,6 +30,7 @@
61 from bzrlib.tests import (
62 test_log,
63 features,
64+ script,
65 )
66
67
68@@ -1052,3 +1053,78 @@
69 self.assertLogRevnos(["--match-author", "author"], ["2", "1"])
70 self.assertLogRevnos(["--match-author", "author1",
71 "--match-author", "author2"], ["2", "1"])
72+
73+
74+class TestLogScripts(script.TestCaseWithTransportAndScript):
75+
76+ def test_root_of_split_branch_subdir(self):
77+ self.run_script("""\
78+$ bzr init -q .
79+$ bzr mkdir -q sub
80+$ echo foo_content > sub/foo
81+$ bzr add -q sub/foo
82+$ bzr commit -q -m "created sub"
83+$ echo bar_content > bar
84+$ bzr add -q bar
85+$ bzr commit -q -m "not modifying sub"
86+$ bzr split sub
87+$ bzr commit -q -m "split sub from its parent" sub
88+$ bzr log --log-format=line sub
89+3: ... split sub from its parent
90+1: ... created sub
91+""")
92+
93+ def test_whole_history_of_split_branch_subdir(self):
94+ self.run_script("""\
95+$ bzr init -q .
96+$ bzr mkdir -q sub
97+$ echo foo_content > sub/foo
98+$ bzr add -q sub/foo
99+$ bzr commit -q -m "created sub"
100+$ echo bar_content > bar
101+$ bzr add -q bar
102+$ bzr commit -q -m "not modifying sub"
103+$ bzr split sub
104+$ bzr commit -q -m "split sub from its parent" sub
105+$ bzr log --log-format=line -d sub
106+3: ... split sub from its parent
107+2: ... not modifying sub
108+1: ... created sub
109+""")
110+
111+ def test_root_of_split_branch_curdir(self):
112+ self.run_script("""\
113+$ bzr init -q .
114+$ bzr mkdir -q sub
115+$ echo foo_content > sub/foo
116+$ bzr add -q sub/foo
117+$ bzr commit -q -m "created sub"
118+$ echo bar_content > bar
119+$ bzr add -q bar
120+$ bzr commit -q -m "not modifying sub"
121+$ bzr split sub
122+$ bzr commit -q -m "split sub from its parent" sub
123+$ cd sub
124+$ bzr log --log-format=line .
125+3: ... split sub from its parent
126+1: ... created sub
127+""")
128+
129+ def test_whole_history_of_split_branch_curdir(self):
130+ self.run_script("""\
131+$ bzr init -q .
132+$ bzr mkdir -q sub
133+$ echo foo_content > sub/foo
134+$ bzr add -q sub/foo
135+$ bzr commit -q -m "created sub"
136+$ echo bar_content > bar
137+$ bzr add -q bar
138+$ bzr commit -q -m "not modifying sub"
139+$ bzr split sub
140+$ bzr commit -q -m "split sub from its parent" sub
141+$ cd sub
142+$ bzr log --log-format=line
143+3: ... split sub from its parent
144+2: ... not modifying sub
145+1: ... created sub
146+""")
147
148=== modified file 'doc/en/release-notes/bzr-2.5.txt'
149--- doc/en/release-notes/bzr-2.5.txt 2011-10-16 10:05:26 +0000
150+++ doc/en/release-notes/bzr-2.5.txt 2011-10-17 12:24:37 +0000
151@@ -51,10 +51,18 @@
152 * ``bzr mkdir --quiet`` now does not print a line for every created
153 directory. (Martin von Gagern, #869915)
154
155+<<<<<<< TREE
156 * ``bzr shelve`` now use ``UIFactory.choose`` for input handling, making
157 it usable when creating a custom ``UIFactory`` implementation. (Benoît
158 Pierre)
159
160+=======
161+* ``bzr log dir`` now filters for the given directory even if it is
162+ the root directory of its branch. This is important for split
163+ branches. Use ``bzr log -d dir`` for old behaviour of listing the
164+ complete history of a given branch. (Martin von Gagern, #869912)
165+
166+>>>>>>> MERGE-SOURCE
167 Documentation
168 *************
169