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