Rev 3885: Start implementing log --deep to display revisions touching a in file:///net/bigmamac/Volumes/home/vila/src/bzr/cases/3232-spurious-conflict/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Dec 10 16:55:28 GMT 2008
At file:///net/bigmamac/Volumes/home/vila/src/bzr/cases/3232-spurious-conflict/
------------------------------------------------------------
revno: 3885
revision-id: v.ladeuil+lp at free.fr-20081210165523-3lczl4wx1xb166df
parent: v.ladeuil+lp at free.fr-20081210093306-j4l1wiesc76519fy
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: log-deep
timestamp: Wed 2008-12-10 17:55:23 +0100
message:
Start implementing log --deep to display revisions touching a
path (instead of a file-id).
* bzrlib/tests/blackbox/test_log.py:
(TestLogFileDeep): Tests for --deep parameter.
* bzrlib/log.py:
(LogFormatter): Mention delta_filter.
(LogFormatter.__init__): Add 'delta_filter' parameter.
(LongLogFormatter.log_revision, ShortLogFormatter.log_revision):
Pass delta_filter.
* bzrlib/builtins.py:
(cmd_log): Add a '--deep' parameter.
(cmd_log.run): Start implementing --deep handling.
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2008-12-05 12:35:15 +0000
+++ b/bzrlib/builtins.py 2008-12-10 16:55:23 +0000
@@ -1767,6 +1767,8 @@
'timezone',
custom_help('verbose',
help='Show files changed in each revision.'),
+ Option('deep',
+ help='Search for files in all revisions (slower).'),
'show-ids',
'revision',
Option('change',
@@ -1791,6 +1793,7 @@
@display_command
def run(self, location=None, timezone='original',
verbose=False,
+ deep=False,
show_ids=False,
forward=False,
revision=None,
@@ -1811,7 +1814,8 @@
revision = change
# log everything
- file_id = None
+ specific_file_id = None
+ specific_file_path = None
if location:
# find the file id to log:
@@ -1820,11 +1824,12 @@
if fp != '':
if tree is None:
tree = b.basis_tree()
- file_id = tree.path2id(fp)
- if file_id is None:
+ specific_file_id = tree.path2id(fp)
+ if specific_file_id is None:
raise errors.BzrCommandError(
"Path does not have any revision history: %s" %
location)
+ specific_file_path = fp
else:
# local dir only
# FIXME ? log the current subdir only RBC 20060203
@@ -1860,13 +1865,29 @@
if log_format is None:
log_format = log.log_formatter_registry.get_default(b)
+ if specific_file_id is None:
+ delta_filter = None
+ if deep:
+ # FIXME: missing test
+ warning('No file specified, --deep ignored')
+ else:
+ if deep:
+ def only_that_file(path, file_id):
+ return path == specific_file_path
+ specific_file_id = None # FIXME: Ugly
+ else:
+ def only_that_file(path, file_id):
+ return file_id == specific_file_id
+ delta_filter = only_that_file
+
lf = log_format(show_ids=show_ids, to_file=self.outf,
show_timezone=timezone,
- delta_format=get_verbosity_level())
+ delta_format=get_verbosity_level(),
+ delta_filter=delta_filter)
show_log(b,
lf,
- file_id,
+ specific_file_id,
verbose=verbose,
direction=direction,
start_revision=rev1,
=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py 2008-12-09 08:57:33 +0000
+++ b/bzrlib/log.py 2008-12-10 16:55:23 +0000
@@ -711,7 +711,9 @@
- supports_delta must be True if this log formatter supports delta.
Otherwise the delta attribute may not be populated. The 'delta_format'
attribute describes whether the 'short_status' format (1) or the long
- one (2) sould be used.
+ one (2) sould be used. The 'delta_filter' attribute (if not None)
+ should be a callable that receives 'path' and 'file_id' as parameters
+ and returns True if the file should be displayed as part of the delta.
- supports_merge_revisions must be True if this log formatter supports
merge revisions. If not, and if supports_single_merge_revisions is
@@ -732,7 +734,8 @@
"""
def __init__(self, to_file, show_ids=False, show_timezone='original',
- delta_format=None):
+ delta_format=None,
+ delta_filter=None):
self.to_file = to_file
self.show_ids = show_ids
self.show_timezone = show_timezone
@@ -740,6 +743,7 @@
# Ensures backward compatibility
delta_format = 2 # long format
self.delta_format = delta_format
+ self.delta_filter = delta_filter
# TODO: uncomment this block after show() has been removed.
# Until then defining log_revision would prevent _show_log calling show()
@@ -818,7 +822,8 @@
to_file.write(indent + ' %s\n' % (l,))
if revision.delta is not None:
revision.delta.show(to_file, self.show_ids, indent=indent,
- short_status=self.delta_format==1)
+ short_status=self.delta_format==1,
+ filter=self.delta_filter)
class ShortLogFormatter(LogFormatter):
@@ -850,7 +855,8 @@
if revision.delta is not None:
revision.delta.show(to_file, self.show_ids,
- short_status=self.delta_format==1)
+ short_status=self.delta_format==1,
+ filter=self.delta_filter)
to_file.write('\n')
=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- a/bzrlib/tests/blackbox/test_log.py 2008-12-05 12:35:15 +0000
+++ b/bzrlib/tests/blackbox/test_log.py 2008-12-10 16:55:23 +0000
@@ -539,3 +539,56 @@
self.assertNotContainsRe(log, 'revno: 3\n')
self.assertNotContainsRe(log, 'revno: 3.1.1\n')
self.assertNotContainsRe(log, 'revno: 4\n')
+
+
+class TestLogFileDeep(TestCaseWithTransport):
+
+ def setUp(self):
+ super(TestLogFileDeep, self).setUp()
+ wt = self.make_branch_and_tree('branch')
+ self.build_tree_contents([('branch/f1', '1\n'),
+ ('branch/f2', '2\n'),
+ ('branch/dir/',),
+ ])
+ wt.add(['f1', 'f2', 'dir'],
+ ['f1-id', 'f2-id', 'dir-id'])
+ wt.commit('commit one', rev_id='1', committer='joe')
+ wt.remove('f2')
+ wt.commit('delete f2', rev_id='2', committer='joe')
+ self.build_tree_contents([('branch/f2', '2bis\n')])
+ wt.add(['f2'], ['f2-id-bis'])
+ wt.commit('add f2 again', rev_id='3', committer='joe')
+ os.chdir('branch')
+ self.addCleanup(os.chdir, '..')
+ self.tree = wt
+
+ def test_log_file_not_deep_long(self):
+ log = self.run_bzr(['log', '-v', '--long', 'f2'])[0]
+ self.assertNotContainsRe(log, 'revno: 1\n')
+ self.assertContainsRe(log, '(?sm)revno: 3\n.*A f2\n')
+
+ def test_log_file_not_deep_short(self):
+ log = self.run_bzr(['log', '-v', '--short', 'f2'])[0]
+ self.assertNotContainsRe(log, 'A f1\n')
+ self.assertNotContainsRe(log, ' f1\n')
+ self.assertContainsRe(log, ' f2\n')
+
+ def test_log_file_deep_long(self):
+ log = self.run_bzr(['log', '-v', '--deep', '--long', 'f2'])[0]
+ # revnos 1 and 3 appear and mention adding f2
+ self.assertContainsRe(log, '(?sm)revno: 1\n.*A f2\n')
+ self.assertContainsRe(log, '(?sm)revno: 3\n.*A f2\n')
+ # revno 2 appears and mentions deleting f2
+ self.assertContainsRe(log, '(?sm)revno: 2\n.*D f2\n')
+
+ def test_log_file_not_deep_short(self):
+ log = self.run_bzr(['log', '-v', '--deep', '--short', 'f2'])[0]
+ # revnos 1 and 3 appear and mention adding f2
+ self.assertContainsRe(log, '(?sm)^ +3 joe.*A f2\n.*^ +1 joe.*A f2\n')
+ # revno 2 appears and mentions deleting f2
+ self.assertNotContainsRe(log, '(?sm)^ +2 joe.*D f2\n')
+
+# tests for:
+# --deep accept file not existing anymore
+# --deep filter revisions not mentionning file
+# --deep warning if no file specified
More information about the bazaar-commits
mailing list