[Pkg-bazaar-commits] ./bzr/unstable r476: - remove dead diff_trees function
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:18:53 UTC 2009
------------------------------------------------------------
revno: 476
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Wed 2005-05-11 17:46:46 +1000
message:
- remove dead diff_trees function
modified:
bzrlib/diff.py
-------------- next part --------------
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py 2005-05-11 07:45:56 +0000
+++ b/bzrlib/diff.py 2005-05-11 07:46:46 +0000
@@ -21,114 +21,6 @@
from errors import BzrError
-def diff_trees(old_tree, new_tree):
- """Compute diff between two trees.
-
- They may be in different branches and may be working or historical
- trees.
-
- This only compares the versioned files, paying no attention to
- files which are ignored or unknown. Those can only be present in
- working trees and can be reported on separately.
-
- Yields a sequence of (state, id, old_name, new_name, kind).
- Each filename and each id is listed only once.
- """
- ## TODO: Allow specifying a list of files to compare, rather than
- ## doing the whole tree? (Not urgent.)
-
- ## TODO: Allow diffing any two inventories, not just the
- ## current one against one. We mgiht need to specify two
- ## stores to look for the files if diffing two branches. That
- ## might imply this shouldn't be primarily a Branch method.
-
- sha_match_cnt = modified_cnt = 0
-
- old_it = old_tree.list_files()
- new_it = new_tree.list_files()
-
- def next(it):
- try:
- return it.next()
- except StopIteration:
- return None
-
- old_item = next(old_it)
- new_item = next(new_it)
-
- # We step through the two sorted iterators in parallel, trying to
- # keep them lined up.
-
- while (old_item != None) or (new_item != None):
- # OK, we still have some remaining on both, but they may be
- # out of step.
- if old_item != None:
- old_name, old_class, old_kind, old_id = old_item
- else:
- old_name = None
-
- if new_item != None:
- new_name, new_class, new_kind, new_id = new_item
- else:
- new_name = None
-
- if old_item:
- # can't handle the old tree being a WorkingTree
- assert old_class == 'V'
-
- if new_item and (new_class != 'V'):
- yield new_class, None, None, new_name, new_kind
- new_item = next(new_it)
- elif (not new_item) or (old_item and (old_name < new_name)):
- if new_tree.has_id(old_id):
- # will be mentioned as renamed under new name
- pass
- else:
- yield 'D', old_id, old_name, None, old_kind
- old_item = next(old_it)
- elif (not old_item) or (new_item and (new_name < old_name)):
- if old_tree.has_id(new_id):
- yield 'R', new_id, old_tree.id2path(new_id), new_name, new_kind
- else:
- yield 'A', new_id, None, new_name, new_kind
- new_item = next(new_it)
- elif old_id != new_id:
- assert old_name == new_name
- # both trees have a file of this name, but it is not the
- # same file. in other words, the old filename has been
- # overwritten by either a newly-added or a renamed file.
- # (should we return something about the overwritten file?)
- if old_tree.has_id(new_id):
- # renaming, overlying a deleted file
- yield 'R', new_id, old_tree.id2path(new_id), new_name, new_kind
- else:
- yield 'A', new_id, None, new_name, new_kind
-
- new_item = next(new_it)
- old_item = next(old_it)
- else:
- assert old_id == new_id
- assert old_id != None
- assert old_name == new_name
- assert old_kind == new_kind
-
- if old_kind == 'directory':
- yield '.', new_id, old_name, new_name, new_kind
- elif old_tree.get_file_sha1(old_id) == new_tree.get_file_sha1(old_id):
- sha_match_cnt += 1
- yield '.', new_id, old_name, new_name, new_kind
- else:
- modified_cnt += 1
- yield 'M', new_id, old_name, new_name, new_kind
-
- new_item = next(new_it)
- old_item = next(old_it)
-
-
- mutter("diff finished: %d SHA matches, %d modified"
- % (sha_match_cnt, modified_cnt))
-
-
def _diff_one(oldlines, newlines, to_file, **kw):
import difflib
More information about the Pkg-bazaar-commits
mailing list