1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
*** modified file 'bzrlib/commands.py'
--- bzrlib/commands.py
+++ bzrlib/commands.py
@@ -610,11 +610,13 @@
hidden = True
takes_args = ["filename"]
def run(self, filename):
+ from bzrlib.log import find_touching_revisions
b = Branch(filename, lock_mode='r')
inv = b.read_working_inventory()
file_id = inv.path2id(b.relpath(filename))
- for revno, revision_id, what in bzrlib.log.find_touching_revisions(b, file_id):
- print "%6d %s" % (revno, what)
+ rh = b.revision_history()
+ for revision_id, what in find_touching_revisions(b, file_id, rh):
+ print "%-40s %s" % (revision_id, what)
class cmd_ls(Command):
*** modified file 'bzrlib/log.py'
--- bzrlib/log.py
+++ bzrlib/log.py
@@ -17,7 +17,7 @@
-def find_touching_revisions(branch, file_id):
+def find_touching_revisions(branch, file_id, revisions):
"""Yield a description of revisions which affect the file_id.
Each returned element is (revno, revision_id, description)
@@ -25,13 +25,20 @@
This is the list of revisions where the file is either added,
modified, renamed or deleted.
- TODO: Perhaps some way to limit this to only particular revisions,
- or to traverse a non-mainline set of revisions?
+ branch
+ Branch to examine
+
+ file_id
+ File to consider
+
+ revisions
+ Sequence of revisions to search, can be
+ branch.revision_history() or a filtered version of that
+ or some sequence of non-mailine revisions.
"""
last_ie = None
last_path = None
- revno = 1
- for revision_id in branch.revision_history():
+ for revision_id in revisions:
this_inv = branch.get_revision_inventory(revision_id)
if file_id in this_inv:
this_ie = this_inv[file_id]
@@ -46,19 +53,19 @@
# not present in either
pass
elif this_ie and not last_ie:
- yield revno, revision_id, "added " + this_path
+ yield revision_id, "added " + this_path
elif not this_ie and last_ie:
# deleted here
- yield revno, revision_id, "deleted " + last_path
+ yield revision_id, "deleted " + last_path
elif this_path != last_path:
- yield revno, revision_id, ("renamed %s => %s" % (last_path, this_path))
+ yield revision_id, ("renamed %s => %s" % (last_path, this_path))
elif (this_ie.text_size != last_ie.text_size
or this_ie.text_sha1 != last_ie.text_sha1):
- yield revno, revision_id, "modified " + this_path
+ yield revision_id, "modified " + this_path
last_ie = this_ie
last_path = this_path
- revno += 1
+
def show_log(branch,
|