Rev 323: Only determine file ids of changed files. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Fri Dec 29 02:05:06 GMT 2006


------------------------------------------------------------
revno: 323
revision-id: jelmer at samba.org-20061229020414-tqbmu19p0fup7sdg
parent: jelmer at samba.org-20061229005920-5fqkse7ru9l5we5l
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Fri 2006-12-29 03:04:14 +0100
message:
  Only determine file ids of changed files.
modified:
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/test_fileids.py          test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
=== modified file 'fetch.py'
--- a/fetch.py	2006-12-28 17:02:28 +0000
+++ b/fetch.py	2006-12-29 02:04:14 +0000
@@ -63,6 +63,8 @@
 
         self.pool = Pool()
 
+        mutter('q %r' % self.id_map)
+
     def _get_revision(self, revid):
         if self._parent_ids is None:
             self._parent_ids = ""
@@ -118,10 +120,14 @@
         return file_id
 
     def open_directory(self, path, parent_baton, base_revnum, pool):
-        file_id, revision_id = self.id_map[path]
         assert base_revnum >= 0
         base_file_id = self.old_inventory.path2id(path)
         base_revid = self.old_inventory[base_file_id].revision
+        if self.id_map.has_key(path):
+            file_id, revision_id = self.id_map[path]
+        else:
+            file_id = base_file_id
+            revision_id = base_rev_id
         if file_id == base_file_id:
             self.dir_baserev[file_id] = [base_revid]
             ie = self.inventory[file_id]
@@ -195,7 +201,11 @@
     def open_file(self, path, parent_id, base_revnum, pool):
         base_file_id = self.old_inventory.path2id(path)
         base_revid = self.old_inventory[base_file_id].revision
-        file_id, revid = self.id_map[path]
+        if self.id_map.has_key(path):
+            file_id, revid = self.id_map[path]
+        else:
+            file_id = base_file_id
+            revid = base_rev_id
         self.is_executable = None
         self.is_symlink = (self.inventory[base_file_id].kind == 'symlink')
         file_weave = self.weave_store.get_weave_or_empty(base_file_id, self.transact)
@@ -220,7 +230,11 @@
         actual_checksum = md5_strings(lines)
         assert checksum is None or checksum == actual_checksum
 
-        file_id, revision_id = self.id_map[path]
+        if self.id_map.has_key(path):
+            file_id, revision_id = self.id_map[path]
+        else:
+            file_id = self.old_inventory.path2id(path)
+            revision_id = self.old_inventory[file_id].revision
         file_weave = self.weave_store.get_weave_or_empty(file_id, self.transact)
         if not file_weave.has_version(revision_id):
             file_weave.add_lines(revision_id, self.file_parents, lines)
@@ -326,17 +340,14 @@
                 parent_branch = None
 
             if parent_revid is None:
-                id_map = self.source.get_fileid_map(revnum, branch)
                 parent_inv = Inventory(ROOT_ID)
             elif prev_revid != parent_revid:
-                id_map = self.source.get_fileid_map(revnum, branch)
                 parent_inv = self.target.get_inventory(parent_revid)
             else:
-                self.source.transform_fileid_map(self.source.uuid, 
-                                        revnum, branch, 
-                                        changes, id_map)
                 parent_inv = prev_inv
 
+            id_map = self.source.transform_fileid_map(self.source.uuid, 
+                                        revnum, branch, changes)
 
             editor = RevisionBuildEditor(self.source, self.target, branch, 
                                          revnum, parent_inv, revid, 

=== modified file 'fileids.py'
--- a/fileids.py	2006-12-27 00:21:59 +0000
+++ b/fileids.py	2006-12-29 02:04:14 +0000
@@ -109,7 +109,7 @@
 
         return map
 
-    def apply_changes(self, uuid, revnum, branch, global_changes, map):
+    def apply_changes(self, uuid, revnum, branch, global_changes):
         """Change file id map to incorporate specified changes.
 
         :param uuid: UUID of repository changes happen in
@@ -127,7 +127,7 @@
 
         revid = generate_svn_revision_id(uuid, revnum, branch)
 
-        return self._apply_changes(map, revid, changes, find_children)
+        return self._apply_changes(revid, changes, find_children)
 
     def get_map(self, uuid, revnum, branch, pb=None):
         """Make sure the map is up to date until revnum."""
@@ -166,7 +166,7 @@
                     yield self.repos.scheme.unprefix(p)[1]
 
             parent_revs = next_parent_revs
-            map = self._apply_changes(map, revid, changes, find_children)
+            map = self._apply_changes(revid, changes, find_children, map)
             next_parent_revs = [revid]
             i = i + 1
 
@@ -179,9 +179,7 @@
 
 class SimpleFileIdMap(FileIdMap):
     @staticmethod
-    def _apply_changes(map, revid, changes, find_children=None):
-        map[""] = (ROOT_ID, revid)
-
+    def _apply_changes(revid, changes, find_children=None, map={}):
         sorted_paths = changes.keys()
         sorted_paths.sort()
         for p in sorted_paths:

=== modified file 'repository.py'
--- a/repository.py	2006-12-29 00:59:20 +0000
+++ b/repository.py	2006-12-29 02:04:14 +0000
@@ -255,8 +255,8 @@
     def get_fileid_map(self, revnum, path, pb=None):
         return self.fileid_map.get_map(self.uuid, revnum, path, pb)
 
-    def transform_fileid_map(self, uuid, revnum, branch, changes, map):
-        return self.fileid_map.apply_changes(uuid, revnum, branch, changes, map)
+    def transform_fileid_map(self, uuid, revnum, branch, changes):
+        return self.fileid_map.apply_changes(uuid, revnum, branch, changes)
 
     def path_to_file_id(self, revnum, path):
         """Generate a bzr file id from a Subversion file name. 

=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py	2006-10-16 11:59:48 +0000
+++ b/tests/test_fileids.py	2006-12-29 02:04:14 +0000
@@ -153,12 +153,18 @@
         revids = mappings.keys()
         revids.sort()
         for r in revids:
-            map = SimpleFileIdMap._apply_changes(map, r, mappings[r], 
-                                                 find_children)
+            map = SimpleFileIdMap._apply_changes(r, mappings[r], 
+                                                 find_children, map)
         return map
 
     def test_simple(self):
         map = self.apply_mappings({"svn-v%d:1 at uuid-" % MAPPING_VERSION: {"foo": ('A', None, None)}})
+        self.assertEqual({ 'foo': ("svn-v%d:1 at uuid--foo" % MAPPING_VERSION, 
+                                       "svn-v%d:1 at uuid-" % MAPPING_VERSION)
+                         }, map)
+
+    def test_simple_add(self):
+        map = self.apply_mappings({"svn-v%d:1 at uuid-" % MAPPING_VERSION: {"": ('A', None, None), "foo": ('A', None, None)}})
         self.assertEqual({'': ('TREE_ROOT', "svn-v%d:1 at uuid-" % MAPPING_VERSION), 
                                'foo': ("svn-v%d:1 at uuid--foo" % MAPPING_VERSION, 
                                        "svn-v%d:1 at uuid-" % MAPPING_VERSION)




More information about the bazaar-commits mailing list