[Pkg-bazaar-commits] ./bzr/unstable r478: - put back support for running diff or status on
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:20:08 UTC 2009
------------------------------------------------------------
revno: 478
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Wed 2005-05-11 18:01:27 +1000
message:
- put back support for running diff or status on
only selected files.
modified:
TODO
bzrlib/diff.py
bzrlib/status.py
-------------- next part --------------
=== modified file 'TODO'
--- a/TODO 2005-05-11 02:48:39 +0000
+++ b/TODO 2005-05-11 08:01:27 +0000
@@ -103,19 +103,15 @@
* Selective commit of only some files.
-* Faster diff/status.
-
- Status should be handled differently because it needs to report on
- deleted and unknown files. diff only needs to deal with versioned
- files.
-
* Merge Aaron's merge code.
* Merge revert patch.
* ``bzr mv`` that does either rename or move as in Unix.
-* More efficient diff of only selected files.
+* More efficient diff of only selected files. We should be able to
+ just get the id for the selected files, look up their location and
+ diff just those files. No need to traverse the entire inventories.
* Fix up Inventory objects to represent root object as an entry.
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py 2005-05-11 07:50:07 +0000
+++ b/bzrlib/diff.py 2005-05-11 08:01:27 +0000
@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from sets import Set
+from sets import Set, ImmutableSet
from trace import mutter
from errors import BzrError
@@ -70,9 +70,6 @@
def show_diff(b, revision, file_list):
import sys
- if file_list:
- raise NotImplementedError('diff on restricted files broken at the moment')
-
if revision == None:
old_tree = b.basis_tree()
else:
@@ -92,7 +89,8 @@
# TODO: Generation of pseudo-diffs for added/deleted files could
# be usefully made into a much faster special case.
- delta = compare_trees(old_tree, new_tree, want_unchanged=False)
+ delta = compare_trees(old_tree, new_tree, want_unchanged=False,
+ file_list=file_list)
for path, file_id, kind in delta.removed:
print '*** removed %s %r' % (kind, path)
@@ -201,11 +199,30 @@
-def compare_trees(old_tree, new_tree, want_unchanged):
+def compare_trees(old_tree, new_tree, want_unchanged, file_list=None):
+ """Describe changes from one tree to another.
+
+ Returns a TreeDelta with details of added, modified, renamed, and
+ deleted entries.
+
+ The root entry is specifically exempt.
+
+ This only considers versioned files.
+
+ want_unchanged
+ If true, also list files unchanged from one version to the next.
+
+ file_list
+ If true, only check for changes to specified files.
+ """
old_inv = old_tree.inventory
new_inv = new_tree.inventory
delta = TreeDelta()
mutter('start compare_trees')
+
+ if file_list:
+ file_list = ImmutableSet(file_list)
+
for file_id in old_tree:
if file_id in new_tree:
kind = old_inv.get_file_kind(file_id)
@@ -220,6 +237,11 @@
old_path = old_inv.id2path(file_id)
new_path = new_inv.id2path(file_id)
+ if file_list:
+ if (old_path not in file_list
+ and new_path not in file_list):
+ continue
+
if kind == 'file':
old_sha1 = old_tree.get_file_sha1(file_id)
new_sha1 = new_tree.get_file_sha1(file_id)
@@ -247,8 +269,12 @@
for file_id in new_inv:
if file_id in old_inv:
continue
+ new_path = new_inv.id2path(file_id)
+ if file_list:
+ if new_path not in file_list:
+ continue
kind = new_inv.get_file_kind(file_id)
- delta.added.append((new_inv.id2path(file_id), file_id, kind))
+ delta.added.append((new_path, file_id, kind))
delta.removed.sort()
delta.added.sort()
=== modified file 'bzrlib/status.py'
--- a/bzrlib/status.py 2005-05-11 07:50:07 +0000
+++ b/bzrlib/status.py 2005-05-11 08:01:27 +0000
@@ -35,11 +35,8 @@
old = branch.basis_tree()
new = branch.working_tree()
- if file_list:
- raise NotImplementedError("sorry, status on selected files is not implemented "
- "at the moment")
-
- delta = diff.compare_trees(old, new, want_unchanged=show_unchanged)
+ delta = diff.compare_trees(old, new, want_unchanged=show_unchanged,
+ file_list=file_list)
delta.show(sys.stdout, show_ids=show_ids,
show_unchanged=show_unchanged)
More information about the Pkg-bazaar-commits
mailing list