Rev 300: Work around a strange bug in the subversion code that will report an in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Tue Dec 26 02:41:24 GMT 2006


------------------------------------------------------------
revno: 300
revision-id: jelmer at samba.org-20061226023540-mimrjtt0za3exypm
parent: jelmer at samba.org-20061226005109-o98yfqhsc113z0vq
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2006-12-26 03:35:40 +0100
message:
  Work around a strange bug in the subversion code that will report an 
  add without a delete when an is being replaced and has the same filename and 
  origin.
modified:
  __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
  convert.py                     svn2bzr.py-20051018015439-cb4563bff29e632d
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
  tests/test_repos.py            test_repos.py-20060508151940-ddc49a59257ca712
=== modified file '__init__.py'
--- a/__init__.py	2006-12-26 00:51:09 +0000
+++ b/__init__.py	2006-12-26 02:35:40 +0000
@@ -123,7 +123,7 @@
     def run(self, url, output_dir, trees=False, shared=False, scheme="trunk"):
         from convert import convert_repository
 
-        convert_repository(url, output_dir, scheme_, shared, trees)
+        convert_repository(url, output_dir, scheme, shared, trees)
 
 
 register_command(cmd_svn_import)

=== modified file 'convert.py'
--- a/convert.py	2006-12-25 23:09:33 +0000
+++ b/convert.py	2006-12-26 02:35:40 +0000
@@ -62,19 +62,19 @@
             
         url = tmp_repos
 
-    if create_shared_repo:
-        try:
-            target_repos = Repository.open(output_dir)
-            assert target_repos.is_shared()
-        except NotBranchError:
-            if scheme.is_branch(""):
-                BzrDir.create_branch_and_repo(output_dir)
-            else:
-                BzrDir.create_repository(output_dir, shared=True)
-            target_repos = Repository.open(output_dir)
-        target_repos.set_make_working_trees(working_trees)
-
     try:
+        if create_shared_repo:
+            try:
+                target_repos = Repository.open(output_dir)
+                assert target_repos.is_shared()
+            except NotBranchError:
+                if scheme.is_branch(""):
+                    BzrDir.create_branch_and_repo(output_dir)
+                else:
+                    BzrDir.create_repository(output_dir, shared=True)
+                target_repos = Repository.open(output_dir)
+            target_repos.set_make_working_trees(working_trees)
+
         source_repos = SvnRepository.open(url)
 
         source_repos.set_branching_scheme(scheme)

=== modified file 'fetch.py'
--- a/fetch.py	2006-12-25 23:31:46 +0000
+++ b/fetch.py	2006-12-26 02:35:40 +0000
@@ -117,6 +117,12 @@
                 ie.revision = revision_id
                 return file_id
 
+            # there is a strange bug in the subversion editor that causes 
+            # it to not report deletes for files that are 
+            # being replaced (R) by an older copy of themselves
+            if copyfrom_path == path and base_file_id in self.inventory:
+                del self.inventory[base_file_id]
+
         self.dir_baserev[file_id] = []
         ie = self.inventory.add_path(path, 'directory', file_id)
         ie.revision = revision_id

=== modified file 'fileids.py'
--- a/fileids.py	2006-12-25 04:43:45 +0000
+++ b/fileids.py	2006-12-26 02:35:40 +0000
@@ -177,9 +177,6 @@
         for p in sorted_paths:
             data = changes[p]
 
-            # FIXME: If this was actually a replace from the same path earlier, 
-            # change data[0] to 'M'
-            
             if data[0] in ('D', 'R'):
                 assert map.has_key(p), "No map entry %s to delete/replace" % p
                 del map[p]
@@ -191,15 +188,13 @@
             if data[0] in ('A', 'R'):
                 map[p] = generate_file_id(revid, p), revid
 
-                if not data[1] is None:
+                if data[1] is not None:
                     mutter('%r:%s copied from %r:%s' % (p, revid, data[1], data[2]))
-                    if find_children is None:
-                        warn('incomplete data for %r' % p)
-                    else:
-                        for c in find_children(data[1], data[2]):
-                            path = c.replace(data[1], p, 1)
-                            map[path] = generate_file_id(revid, c), revid
-                            mutter('added mapping %r -> %r' % (path, map[path]))
+                    assert find_children is not None, 'incomplete data for %r' % p
+                    for c in find_children(data[1], data[2]):
+                        path = c.replace(data[1], p, 1)
+                        map[path] = generate_file_id(revid, c), revid
+                        mutter('added mapping %r -> %r' % (path, map[path]))
 
             elif data[0] == 'M':
                 if p == "":

=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py	2006-12-26 00:12:31 +0000
+++ b/tests/test_repos.py	2006-12-26 02:35:40 +0000
@@ -553,7 +553,7 @@
                 "svn-v%d:1@%s-" % (MAPPING_VERSION, oldrepos.uuid))
         inv2 = newrepos.get_inventory(
                 "svn-v%d:3@%s-" % (MAPPING_VERSION, oldrepos.uuid))
-        self.assertNotEqual(inv1.path2id("bla"), inv2.path2id("bla"))
+        self.assertEqual(inv1.path2id("bla"), inv2.path2id("bla"))
 
     def test_fetch_replace_backup(self):
         filename = os.path.join(self.test_dir, "dumpfile")
@@ -732,7 +732,7 @@
                 "svn-v%d:1@%s-" % (MAPPING_VERSION, oldrepos.uuid))
         inv2 = newrepos.get_inventory(
                 "svn-v%d:3@%s-" % (MAPPING_VERSION, oldrepos.uuid))
-        self.assertNotEqual(inv1.path2id("bla"), inv2.path2id("bla"))
+        self.assertEqual(inv1.path2id("bla"), inv2.path2id("bla"))
 
     def test_fetch_replace_unrelated(self):
         filename = os.path.join(self.test_dir, "dumpfile")
@@ -874,6 +874,168 @@
                 "svn-v%d:4@%s-" % (MAPPING_VERSION, oldrepos.uuid))
         self.assertNotEqual(inv1.path2id("x"), inv2.path2id("x"))
 
+    def test_fetch_replace_related(self):
+        filename = os.path.join(self.test_dir, "dumpfile")
+        open(filename, 'w').write("""SVN-fs-dump-format-version: 2
+
+UUID: 606c7b1f-987c-4826-b37d-eb456ceb87e1
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2006-12-26T00:04:55.850520Z
+PROPS-END
+
+Revision-number: 1
+Prop-content-length: 103
+Content-length: 103
+
+K 7
+svn:log
+V 3
+add
+K 10
+svn:author
+V 6
+jelmer
+K 8
+svn:date
+V 27
+2006-12-26T00:05:15.504335Z
+PROPS-END
+
+Node-path: x
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Revision-number: 2
+Prop-content-length: 102
+Content-length: 102
+
+K 7
+svn:log
+V 2
+rm
+K 10
+svn:author
+V 6
+jelmer
+K 8
+svn:date
+V 27
+2006-12-26T00:05:30.775369Z
+PROPS-END
+
+Node-path: x
+Node-action: delete
+
+
+Revision-number: 3
+Prop-content-length: 105
+Content-length: 105
+
+K 7
+svn:log
+V 5
+readd
+K 10
+svn:author
+V 6
+jelmer
+K 8
+svn:date
+V 27
+2006-12-26T00:05:43.584249Z
+PROPS-END
+
+Node-path: y
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 1
+Node-copyfrom-path: x
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Revision-number: 4
+Prop-content-length: 108
+Content-length: 108
+
+K 7
+svn:log
+V 8
+Replace
+
+K 10
+svn:author
+V 6
+jelmer
+K 8
+svn:date
+V 27
+2006-12-25T04:30:06.383777Z
+PROPS-END
+
+Node-path: y
+Node-action: delete
+
+
+Revision-number: 5
+Prop-content-length: 108
+Content-length: 108
+
+K 7
+svn:log
+V 8
+Replace
+
+K 10
+svn:author
+V 6
+jelmer
+K 8
+svn:date
+V 27
+2006-12-25T04:30:06.383777Z
+PROPS-END
+
+
+Node-path: y
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 1
+Node-copyfrom-path: x
+
+
+""")
+        os.mkdir("old")
+
+        load_dumpfile("dumpfile", "old")
+        oldrepos = Repository.open("old")
+        dir = BzrDir.create("f")
+        newrepos = dir.create_repository()
+        oldrepos.copy_content_into(newrepos)
+        self.assertTrue(newrepos.has_revision(
+            "svn-v%d:1@%s-" % (MAPPING_VERSION, oldrepos.uuid)))
+        self.assertTrue(newrepos.has_revision(
+            "svn-v%d:5@%s-" % (MAPPING_VERSION, oldrepos.uuid)))
+        inv1 = newrepos.get_inventory(
+                "svn-v%d:1@%s-" % (MAPPING_VERSION, oldrepos.uuid))
+        inv2 = newrepos.get_inventory(
+                "svn-v%d:5@%s-" % (MAPPING_VERSION, oldrepos.uuid))
+        self.assertNotEqual(inv1.path2id("y"), inv2.path2id("y"))
+
     # FIXME
     def notest_fetch_all(self):
         repos_url = self.make_client('d', 'dc')




More information about the bazaar-commits mailing list