convert/svn: remove dead code from entry deletion code path
authorPatrick Mezard <pmezard@gmail.com>
Sun, 21 Jun 2009 23:04:02 +0200
changeset 8884 8b603c7c808e
parent 8883 ede2247e61aa
child 8885 2c184bd2b37a
convert/svn: remove dead code from entry deletion code path It was made obsolete when multi-branches commit were split into multiple Mercurial commits.
hgext/convert/subversion.py
tests/svn/branches.svndump
tests/svn/move.svndump
tests/svn/svndump-branches.sh
tests/svn/svndump-move.sh
tests/test-convert-svn-branches.out
tests/test-convert-svn-move.out
--- a/hgext/convert/subversion.py	Sun Jun 21 23:04:02 2009 +0200
+++ b/hgext/convert/subversion.py	Sun Jun 21 23:04:02 2009 +0200
@@ -644,70 +644,34 @@
                 copies[self.recode(entry)] = self.recode(copyfrom_path)
             elif kind == 0: # gone, but had better be a deleted *file*
                 self.ui.debug(_("gone from %s\n") % ent.copyfrom_rev)
-
-                # if a branch is created but entries are removed in
-                # the same changeset, get the right fromrev
-                # parents cannot be empty here, you cannot remove
-                # things from a root revision.
-                uuid, old_module, fromrev = self.revsplit(parents[0])
-
-                basepath = old_module + "/" + self.getrelpath(path)
-                entrypath = basepath
-
-                def lookup_parts(p):
-                    rc = None
-                    parts = p.split("/")
-                    for i in range(len(parts)):
-                        part = "/".join(parts[:i])
-                        info = part, copyfrom.get(part, None)
-                        if info[1] is not None:
-                            self.ui.debug(_("found parent directory %s\n") % info[1])
-                            rc = info
-                    return rc
-
-                self.ui.debug(_("base, entry %s %s\n") % (basepath, entrypath))
-
-                frompath, froment = lookup_parts(entrypath) or (None, revnum - 1)
-
-                # need to remove fragment from lookup_parts and
-                # replace with copyfrom_path
-                if frompath is not None:
-                    self.ui.debug(_("munge-o-matic\n"))
-                    self.ui.debug(entrypath + '\n')
-                    self.ui.debug(entrypath[len(frompath):] + '\n')
-                    entrypath = froment.copyfrom_path + entrypath[len(frompath):]
-                    fromrev = froment.copyfrom_rev
-                    self.ui.debug(_("info: %s %s %s %s\n") % (frompath, froment, ent, entrypath))
+                pmodule, prevnum = self.revsplit(parents[0])[1:]
+                parentpath = pmodule + "/" + entrypath
+                self.ui.debug(_("entry %s\n") % parentpath)
 
                 # We can avoid the reparent calls if the module has
                 # not changed but it probably does not worth the pain.
                 prevmodule = self.reparent('')
-                fromkind = svn.ra.check_path(self.ra, entrypath.strip('/'), fromrev)
+                fromkind = svn.ra.check_path(self.ra, parentpath.strip('/'), prevnum)
                 self.reparent(prevmodule)
 
                 if fromkind == svn.core.svn_node_file:
                     entries.append(self.recode(entry))
                 elif fromkind == svn.core.svn_node_dir:
-                    # Sometimes this is tricky. For example: in The
-                    # Subversion Repository revision 6940 a dir was
-                    # copied and one of its files was deleted from the
-                    # new location in the same commit. This code can't
-                    # deal with that yet.
                     if ent.action == 'C':
-                        children = self._find_children(path, fromrev)
+                        children = self._find_children(path, prevnum)
                     else:
-                        oroot = entrypath.strip('/')
+                        oroot = parentpath.strip('/')
                         nroot = path.strip('/')
-                        children = self._find_children(oroot, fromrev)
+                        children = self._find_children(oroot, prevnum)
                         children = [s.replace(oroot,nroot) for s in children]
 
                     for child in children:
-                        entrypath = self.getrelpath("/" + child, old_module)
-                        if not entrypath:
+                        childpath = self.getrelpath("/" + child, pmodule)
+                        if not childpath:
                             continue
-                        if entrypath in copies:
-                            del copies[entrypath]
-                        entries.append(entrypath)
+                        if childpath in copies:
+                            del copies[childpath]
+                        entries.append(childpath)
                 else:
                     self.ui.debug(_('unknown path in revision %d: %s\n') % \
                                   (revnum, path))
--- a/tests/svn/branches.svndump	Sun Jun 21 23:04:02 2009 +0200
+++ b/tests/svn/branches.svndump	Sun Jun 21 23:04:02 2009 +0200
@@ -1,6 +1,6 @@
 SVN-fs-dump-format-version: 2
 
-UUID: 7b60030a-5a1f-4344-a009-73f0c1c2adf2
+UUID: 3c3c228a-b3dd-467c-a766-896f4b7cd0af
 
 Revision-number: 0
 Prop-content-length: 56
@@ -9,7 +9,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:47:52.296168Z
+2009-06-21T12:38:53.023457Z
 PROPS-END
 
 Revision-number: 1
@@ -27,7 +27,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:47:52.342238Z
+2009-06-21T12:38:53.111986Z
 PROPS-END
 
 Node-path: branches
@@ -72,7 +72,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:47:53.190046Z
+2009-06-21T12:38:54.182594Z
 PROPS-END
 
 Node-path: branches/notinbranch
@@ -81,6 +81,7 @@
 Prop-content-length: 10
 Text-content-length: 2
 Text-content-md5: e29311f6f1bf1af907f9ef9f44b8328b
+Text-content-sha1: e983f374794de9c64e3d1c1de1d490c0756eeeff
 Content-length: 12
 
 PROPS-END
@@ -93,6 +94,7 @@
 Prop-content-length: 10
 Text-content-length: 2
 Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3
+Text-content-sha1: 3f786850e387550fdab836ed7e6dc881de23001b
 Content-length: 12
 
 PROPS-END
@@ -105,6 +107,7 @@
 Prop-content-length: 10
 Text-content-length: 2
 Text-content-md5: 3b5d5c3712955042212316173ccf37be
+Text-content-sha1: 89e6c98d92887913cadf06b2adb97f26cde4849b
 Content-length: 12
 
 PROPS-END
@@ -117,20 +120,43 @@
 Prop-content-length: 10
 Text-content-length: 2
 Text-content-md5: 2cd6ee2c70b0bde53fbe6cac3c8b8bb1
+Text-content-sha1: 2b66fd261ee5c6cfc8de7fa466bab600bcfe4f69
 Content-length: 12
 
 PROPS-END
 c
 
 
+Node-path: trunk/dir
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: trunk/dir/e
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: 9ffbf43126e33be52cd2bf7e01d627f9
+Text-content-sha1: 094e3afb2fe8dfe82f63731cdcd3b999f4856cff
+Content-length: 12
+
+PROPS-END
+e
+
+
 Revision-number: 3
-Prop-content-length: 124
-Content-length: 124
+Prop-content-length: 132
+Content-length: 132
 
 K 7
 svn:log
-V 22
-branch trunk, remove c
+V 30
+branch trunk, remove c and dir
 K 10
 svn:author
 V 7
@@ -138,38 +164,22 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:47:55.188535Z
+2009-06-21T12:38:57.166484Z
 PROPS-END
 
 Node-path: branches/old
 Node-kind: dir
 Node-action: add
-Node-copyfrom-rev: 1
+Node-copyfrom-rev: 2
 Node-copyfrom-path: trunk
-Prop-content-length: 34
-Content-length: 34
-
-K 13
-svn:mergeinfo
-V 0
-
-PROPS-END
 
 
-Node-path: branches/old/a
-Node-kind: file
-Node-action: add
-Node-copyfrom-rev: 2
-Node-copyfrom-path: trunk/a
-Text-copy-source-md5: 60b725f10c9c85c70d97880dfe8191b3
+Node-path: branches/old/dir
+Node-action: delete
 
 
-Node-path: branches/old/b
-Node-kind: file
-Node-action: add
-Node-copyfrom-rev: 2
-Node-copyfrom-path: trunk/b
-Text-copy-source-md5: 3b5d5c3712955042212316173ccf37be
+Node-path: branches/old/c
+Node-action: delete
 
 
 Revision-number: 4
@@ -187,7 +197,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:47:57.146347Z
+2009-06-21T12:38:59.084420Z
 PROPS-END
 
 Node-path: trunk/a
@@ -195,6 +205,7 @@
 Node-action: change
 Text-content-length: 4
 Text-content-md5: 0d227f1abf8c2932d342e9b99cc957eb
+Text-content-sha1: d7c8127a20a396cff08af086a1c695b0636f0c29
 Content-length: 4
 
 a
@@ -216,7 +227,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:47:58.150124Z
+2009-06-21T12:39:00.093201Z
 PROPS-END
 
 Node-path: branches/old/b
@@ -224,6 +235,7 @@
 Node-action: change
 Text-content-length: 4
 Text-content-md5: 06ac26ed8b614fc0b141e4542aa067c2
+Text-content-sha1: f6980469e74f7125178e88ec571e06fe6ce86e95
 Content-length: 4
 
 b
@@ -245,7 +257,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:48:00.161336Z
+2009-06-21T12:39:02.078633Z
 PROPS-END
 
 Node-path: branches/old/c
@@ -254,16 +266,12 @@
 Node-copyfrom-rev: 3
 Node-copyfrom-path: trunk/b
 Text-copy-source-md5: 3b5d5c3712955042212316173ccf37be
-Prop-content-length: 34
+Text-copy-source-sha1: 89e6c98d92887913cadf06b2adb97f26cde4849b
 Text-content-length: 4
 Text-content-md5: 33cb6785d50937d8d307ebb66d6259a7
-Content-length: 38
+Text-content-sha1: 7a6478264aa11a0f4befef356c03e83f2b1f6eba
+Content-length: 4
 
-K 13
-svn:mergeinfo
-V 0
-
-PROPS-END
 b
 c
 
@@ -287,7 +295,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:48:01.153724Z
+2009-06-21T12:39:03.065537Z
 PROPS-END
 
 Node-path: branches/old/b
@@ -295,6 +303,7 @@
 Node-action: change
 Text-content-length: 6
 Text-content-md5: cdcfb41554e2d092c13f5e6839e63577
+Text-content-sha1: 17ac58cabedebea235d1b5605531d5b1559797e9
 Content-length: 6
 
 b
@@ -317,7 +326,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:48:04.150915Z
+2009-06-21T12:39:06.070275Z
 PROPS-END
 
 Node-path: branches/old2
@@ -346,7 +355,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:48:06.149560Z
+2009-06-21T12:39:08.082539Z
 PROPS-END
 
 Node-path: branches/old
@@ -375,7 +384,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:48:07.268498Z
+2009-06-21T12:39:09.073290Z
 PROPS-END
 
 Node-path: trunk/a
@@ -383,6 +392,7 @@
 Node-action: change
 Text-content-length: 2
 Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3
+Text-content-sha1: 3f786850e387550fdab836ed7e6dc881de23001b
 Content-length: 2
 
 a
@@ -403,7 +413,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T12:48:09.151702Z
+2009-06-21T12:39:11.070264Z
 PROPS-END
 
 Node-path: branches/old3
--- a/tests/svn/move.svndump	Sun Jun 21 23:04:02 2009 +0200
+++ b/tests/svn/move.svndump	Sun Jun 21 23:04:02 2009 +0200
@@ -1,6 +1,6 @@
 SVN-fs-dump-format-version: 2
 
-UUID: 0682b859-320d-4a69-a164-a7cab5695072
+UUID: 9de99ecc-876b-46e5-bc59-bff9b2b58b1e
 
 Revision-number: 0
 Prop-content-length: 56
@@ -9,7 +9,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:36.768573Z
+2009-06-21T14:32:26.678698Z
 PROPS-END
 
 Revision-number: 1
@@ -27,7 +27,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:37.083146Z
+2009-06-21T14:32:27.278689Z
 PROPS-END
 
 Node-path: trunk
@@ -45,6 +45,7 @@
 Prop-content-length: 10
 Text-content-length: 2
 Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3
+Text-content-sha1: 3f786850e387550fdab836ed7e6dc881de23001b
 Content-length: 12
 
 PROPS-END
@@ -66,6 +67,7 @@
 Prop-content-length: 10
 Text-content-length: 2
 Text-content-md5: 3b5d5c3712955042212316173ccf37be
+Text-content-sha1: 89e6c98d92887913cadf06b2adb97f26cde4849b
 Content-length: 12
 
 PROPS-END
@@ -78,6 +80,7 @@
 Prop-content-length: 10
 Text-content-length: 2
 Text-content-md5: 2cd6ee2c70b0bde53fbe6cac3c8b8bb1
+Text-content-sha1: 2b66fd261ee5c6cfc8de7fa466bab600bcfe4f69
 Content-length: 12
 
 PROPS-END
@@ -99,6 +102,7 @@
 Prop-content-length: 10
 Text-content-length: 2
 Text-content-md5: e29311f6f1bf1af907f9ef9f44b8328b
+Text-content-sha1: e983f374794de9c64e3d1c1de1d490c0756eeeff
 Content-length: 12
 
 PROPS-END
@@ -120,7 +124,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:38.152773Z
+2009-06-21T14:32:28.312955Z
 PROPS-END
 
 Node-path: trunk/a
@@ -128,6 +132,7 @@
 Node-action: change
 Text-content-length: 4
 Text-content-md5: 0d227f1abf8c2932d342e9b99cc957eb
+Text-content-sha1: d7c8127a20a396cff08af086a1c695b0636f0c29
 Content-length: 4
 
 a
@@ -139,6 +144,7 @@
 Node-action: change
 Text-content-length: 4
 Text-content-md5: 63fad9092ad37713ebe26b3193f89c41
+Text-content-sha1: ccfb93b7bac6f1520f0adc0eebc2cafe9da80f42
 Content-length: 4
 
 c
@@ -160,7 +166,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:39.146388Z
+2009-06-21T14:32:29.183467Z
 PROPS-END
 
 Node-path: subproject
@@ -189,7 +195,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:40.179944Z
+2009-06-21T14:32:30.300975Z
 PROPS-END
 
 Node-path: subproject/trunk
@@ -216,7 +222,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:41.184505Z
+2009-06-21T14:32:31.354398Z
 PROPS-END
 
 Node-path: subproject/branches
@@ -243,7 +249,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:42.153312Z
+2009-06-21T14:32:32.121901Z
 PROPS-END
 
 Node-path: subproject/trunk/d1
@@ -272,7 +278,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:42.206313Z
+2009-06-21T14:32:32.317815Z
 PROPS-END
 
 Node-path: subproject/trunk/d2
@@ -301,7 +307,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:43.182355Z
+2009-06-21T14:32:33.418320Z
 PROPS-END
 
 Node-path: subproject/trunk/d1/b
@@ -309,6 +315,7 @@
 Node-action: change
 Text-content-length: 4
 Text-content-md5: 06ac26ed8b614fc0b141e4542aa067c2
+Text-content-sha1: f6980469e74f7125178e88ec571e06fe6ce86e95
 Content-length: 4
 
 b
@@ -334,7 +341,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:44.153682Z
+2009-06-21T14:32:34.126542Z
 PROPS-END
 
 Node-path: subproject/branches/d1
@@ -363,7 +370,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:44.298011Z
+2009-06-21T14:32:34.436015Z
 PROPS-END
 
 Node-path: subproject/trunk/d
@@ -372,6 +379,7 @@
 Node-copyfrom-rev: 7
 Node-copyfrom-path: subproject/trunk/d2/d
 Text-copy-source-md5: e29311f6f1bf1af907f9ef9f44b8328b
+Text-copy-source-sha1: e983f374794de9c64e3d1c1de1d490c0756eeeff
 
 
 Revision-number: 11
@@ -389,7 +397,7 @@
 K 8
 svn:date
 V 27
-2008-12-06T13:33:44.349920Z
+2009-06-21T14:32:34.803189Z
 PROPS-END
 
 Node-path: subproject/trunk/d2
@@ -399,3 +407,94 @@
 Node-copyfrom-path: subproject/trunk/d2
 
 
+Revision-number: 12
+Prop-content-length: 107
+Content-length: 107
+
+K 7
+svn:log
+V 6
+add d3
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2009-06-21T14:32:36.531735Z
+PROPS-END
+
+Node-path: subproject/trunk/d3
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: subproject/trunk/d3/d31
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: subproject/trunk/d3/d31/e
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: 9ffbf43126e33be52cd2bf7e01d627f9
+Text-content-sha1: 094e3afb2fe8dfe82f63731cdcd3b999f4856cff
+Content-length: 12
+
+PROPS-END
+e
+
+
+Node-path: subproject/trunk/d3/f
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: 9a8ad92c50cae39aa2c5604fd0ab6d8c
+Text-content-sha1: a9fcd54b25e7e863d72cd47c08af46e61b74b561
+Content-length: 12
+
+PROPS-END
+f
+
+
+Revision-number: 13
+Prop-content-length: 128
+Content-length: 128
+
+K 7
+svn:log
+V 26
+copy dir and remove subdir
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2009-06-21T14:32:38.281829Z
+PROPS-END
+
+Node-path: subproject/trunk/d3/d31
+Node-action: delete
+
+
+Node-path: subproject/trunk/d4
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 12
+Node-copyfrom-path: subproject/trunk/d3
+
+
--- a/tests/svn/svndump-branches.sh	Sun Jun 21 23:04:02 2009 +0200
+++ b/tests/svn/svndump-branches.sh	Sun Jun 21 23:04:02 2009 +0200
@@ -22,15 +22,19 @@
 echo a > trunk/a
 echo b > trunk/b
 echo c > trunk/c
+mkdir trunk/dir
+echo e > trunk/dir/e
 # Add a file within branches, used to confuse branch detection
 echo d > branches/notinbranch
-svn add trunk/a trunk/b trunk/c branches/notinbranch
+svn add trunk/a trunk/b trunk/c trunk/dir branches/notinbranch
 svn ci -m hello
+svn up
 
 # Branch to old
 svn copy trunk branches/old
 svn rm branches/old/c
-svn ci -m "branch trunk, remove c"
+svn rm branches/old/dir
+svn ci -m "branch trunk, remove c and dir"
 svn up
 
 # Update trunk
--- a/tests/svn/svndump-move.sh	Sun Jun 21 23:04:02 2009 +0200
+++ b/tests/svn/svndump-move.sh	Sun Jun 21 23:04:02 2009 +0200
@@ -57,6 +57,17 @@
     # Copy a directory from a past revision
     svn copy -r 7 $svnurl/subproject/trunk/d2 $svnurl/subproject/trunk -m copydirfrompast
 fi
+
+# Copy a directory while removing a subdirectory
+svn up
+mkdir -p subproject/trunk/d3/d31
+echo e > subproject/trunk/d3/d31/e
+echo f > subproject/trunk/d3/f
+svn add subproject/trunk/d3
+svn ci -m "add d3"
+svn copy subproject/trunk/d3 subproject/trunk/d4
+svn rm subproject/trunk/d3/d31
+svn ci -m "copy dir and remove subdir"
 cd ..
 
 svnadmin dump svn-repo > ../move.svndump
\ No newline at end of file
--- a/tests/test-convert-svn-branches.out	Sun Jun 21 23:04:02 2009 +0200
+++ b/tests/test-convert-svn-branches.out	Sun Jun 21 23:04:02 2009 +0200
@@ -5,7 +5,7 @@
 converting...
 10 init projA
 9 hello
-8 branch trunk, remove c
+8 branch trunk, remove c and dir
 7 change a
 6 change b
 5 move and update c
@@ -37,9 +37,9 @@
 | | |
 | o |  branch= 3 change a files: a
 | | |
-+---o  branch=old 2 branch trunk, remove c files: a b
-| |
-| o  branch= 1 hello files: a b c
+| | o  branch=old 2 branch trunk, remove c and dir files: c
+| |/
+| o  branch= 1 hello files: a b c dir/e
 |/
 o  branch= 0 init projA files:
 
--- a/tests/test-convert-svn-move.out	Sun Jun 21 23:04:02 2009 +0200
+++ b/tests/test-convert-svn-move.out	Sun Jun 21 23:04:02 2009 +0200
@@ -3,16 +3,22 @@
 scanning source...
 sorting...
 converting...
-9 createtrunk
-8 moved1
-7 moved1
-6 moved2
-5 changeb and rm d2
-4 changeb and rm d2
-3 moved1again
-2 moved1again
-1 copyfilefrompast
-0 copydirfrompast
+11 createtrunk
+10 moved1
+9 moved1
+8 moved2
+7 changeb and rm d2
+6 changeb and rm d2
+5 moved1again
+4 moved1again
+3 copyfilefrompast
+2 copydirfrompast
+1 add d3
+0 copy dir and remove subdir
+o  11 copy dir and remove subdir files: d3/d31/e d4/d31/e d4/f
+|
+o  10 add d3 files: d3/d31/e d3/f
+|
 o  9 copydirfrompast files: d2/d
 |
 o  8 copyfilefrompast files: d
@@ -33,5 +39,5 @@
 |
 o  0 createtrunk files:
 
-default                        9:
+default                       11:
 d1                             6: