Rev 4390: (igc) faster diff on large trees (Ian Clatworthy) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu May 28 19:56:59 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4390
revision-id: pqm at pqm.ubuntu.com-20090528185655-uip7we14796b5c8j
parent: pqm at pqm.ubuntu.com-20090528180643-13zpler3llbz9c47
parent: ian.clatworthy at canonical.com-20090528134652-g1j4m0rr1g1hdcpe
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-05-28 19:56:55 +0100
message:
  (igc) faster diff on large trees (Ian Clatworthy)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
    ------------------------------------------------------------
    revno: 4385.1.1
    revision-id: ian.clatworthy at canonical.com-20090528134652-g1j4m0rr1g1hdcpe
    parent: pqm at pqm.ubuntu.com-20090528085340-bfw8729wfm9kmfmd
    parent: ian.clatworthy at canonical.com-20090528134454-p1kkcddnnq4gpm4k
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: integration
    timestamp: Thu 2009-05-28 23:46:52 +1000
    message:
      (igc) faster diff on large trees (Ian Clatworthy)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
    ------------------------------------------------------------
    revno: 4377.3.4
    revision-id: ian.clatworthy at canonical.com-20090528134454-p1kkcddnnq4gpm4k
    parent: ian.clatworthy at canonical.com-20090527071820-yotvank2tggf0j4o
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: faster-diff
    timestamp: Thu 2009-05-28 23:44:54 +1000
    message:
      back out tree-level cache of dirstate entries as agreed during review
    modified:
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 4377.3.3
    revision-id: ian.clatworthy at canonical.com-20090527071820-yotvank2tggf0j4o
    parent: ian.clatworthy at canonical.com-20090527071745-er1xah246qi0ah0l
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: faster-diff
    timestamp: Wed 2009-05-27 17:18:20 +1000
    message:
      avoid unnecessary id2path calculation when diffing
    modified:
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
    ------------------------------------------------------------
    revno: 4377.3.2
    revision-id: ian.clatworthy at canonical.com-20090527071745-er1xah246qi0ah0l
    parent: ian.clatworthy at canonical.com-20090522080517-862cs0on3nj49973
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: faster-diff
    timestamp: Wed 2009-05-27 17:17:45 +1000
    message:
      cache last dirstate entry found in DirStateRevisionTree
    modified:
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 4377.3.1
    revision-id: ian.clatworthy at canonical.com-20090522080517-862cs0on3nj49973
    parent: pqm at pqm.ubuntu.com-20090522023622-3nmhis99wz3qgg6z
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: faster-diff
    timestamp: Fri 2009-05-22 18:05:17 +1000
    message:
      faster diff on large trees
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
=== modified file 'NEWS'
--- a/NEWS	2009-05-28 17:14:38 +0000
+++ b/NEWS	2009-05-28 18:56:55 +0000
@@ -23,6 +23,8 @@
 
 * ``bzr branch --notree`` is now faster. (Ian Clatworthy)
 
+* ``bzr diff`` is now faster on large trees. (Ian Clatworthy)
+
 Bug Fixes
 *********
 

=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py	2009-03-28 02:10:54 +0000
+++ b/bzrlib/diff.py	2009-05-27 07:18:20 +0000
@@ -620,9 +620,11 @@
             return self.CANNOT_DIFF
         from_label = '%s%s\t%s' % (self.old_label, old_path, old_date)
         to_label = '%s%s\t%s' % (self.new_label, new_path, new_date)
-        return self.diff_text(from_file_id, to_file_id, from_label, to_label)
+        return self.diff_text(from_file_id, to_file_id, from_label, to_label,
+            old_path, new_path)
 
-    def diff_text(self, from_file_id, to_file_id, from_label, to_label):
+    def diff_text(self, from_file_id, to_file_id, from_label, to_label,
+        from_path=None, to_path=None):
         """Diff the content of given files in two trees
 
         :param from_file_id: The id of the file in the from tree.  If None,
@@ -630,15 +632,17 @@
         :param to_file_id: The id of the file in the to tree.  This may refer
             to a different file from from_file_id.  If None,
             the file is not present in the to tree.
+        :param from_path: The path in the from tree or None if unknown.
+        :param to_path: The path in the to tree or None if unknown.
         """
-        def _get_text(tree, file_id):
+        def _get_text(tree, file_id, path):
             if file_id is not None:
-                return tree.get_file(file_id).readlines()
+                return tree.get_file(file_id, path).readlines()
             else:
                 return []
         try:
-            from_text = _get_text(self.old_tree, from_file_id)
-            to_text = _get_text(self.new_tree, to_file_id)
+            from_text = _get_text(self.old_tree, from_file_id, from_path)
+            to_text = _get_text(self.new_tree, to_file_id, to_path)
             self.text_differ(from_label, from_text, to_label, to_text,
                              self.to_file)
         except errors.BinaryFile:
@@ -882,7 +886,7 @@
                 self.to_file.write("=== modified %s '%s'%s\n" % (kind[0],
                                    newpath_encoded, prop_str))
             if changed_content:
-                self.diff(file_id, oldpath, newpath)
+                self._diff(file_id, oldpath, newpath, kind[0], kind[1])
                 has_changes = 1
             if renamed:
                 has_changes = 1
@@ -903,7 +907,10 @@
             new_kind = self.new_tree.kind(file_id)
         except (errors.NoSuchId, errors.NoSuchFile):
             new_kind = None
-
+        self._diff(file_id, old_path, new_path, old_kind, new_kind)
+
+
+    def _diff(self, file_id, old_path, new_path, old_kind, new_kind):
         result = DiffPath._diff_many(self.differs, file_id, old_path,
                                        new_path, old_kind, new_kind)
         if result is DiffPath.CANNOT_DIFF:




More information about the bazaar-commits mailing list