convert/svn: fix changed files list upon directory replacements stable
authorPatrick Mezard <pmezard@gmail.com>
Mon, 29 Nov 2010 20:13:11 +0100
branchstable
changeset 13052 5fb924ee44d5
parent 13044 db1433e4bf5f
child 13053 2649be11ab0b
convert/svn: fix changed files list upon directory replacements When branch2/dir was replacing branch1/dir, we only marked branch2/dir files a changed. Add branch1/dir files as they may not exist in branch2.
hgext/convert/subversion.py
tests/svn/replace.svndump
tests/svn/svndump-replace.sh
tests/test-convert-svn-move.t
--- a/hgext/convert/subversion.py	Fri Nov 26 20:05:16 2010 -0600
+++ b/hgext/convert/subversion.py	Mon Nov 29 20:13:11 2010 +0100
@@ -656,13 +656,20 @@
                     # If the directory just had a prop change,
                     # then we shouldn't need to look for its children.
                     continue
-                elif ent.action == 'R' and parents:
+                if ent.action == 'R' and parents:
                     # If a directory is replacing a file, mark the previous
                     # file as deleted
                     pmodule, prevnum = self.revsplit(parents[0])[1:]
                     pkind = self._checkpath(entrypath, prevnum, pmodule)
                     if pkind == svn.core.svn_node_file:
                         removed.add(self.recode(entrypath))
+                    elif pkind == svn.core.svn_node_dir:
+                        # We do not know what files were kept or removed,
+                        # mark them all as changed.
+                        for childpath in self._iterfiles(pmodule, prevnum):
+                            childpath = self.getrelpath("/" + childpath)
+                            if childpath:
+                                changed.add(self.recode(childpath))
 
                 for childpath in self._iterfiles(path, revnum):
                     childpath = self.getrelpath("/" + childpath)
--- a/tests/svn/replace.svndump	Fri Nov 26 20:05:16 2010 -0600
+++ b/tests/svn/replace.svndump	Mon Nov 29 20:13:11 2010 +0100
@@ -1,6 +1,6 @@
 SVN-fs-dump-format-version: 2
 
-UUID: 4a895937-439c-4e56-b7b0-fa1c8acc0c20
+UUID: 97a955ef-0269-44f2-a58f-abd4ad400b2b
 
 Revision-number: 0
 Prop-content-length: 56
@@ -9,7 +9,7 @@
 K 8
 svn:date
 V 27
-2010-05-09T14:57:31.007802Z
+2010-11-26T18:01:12.912988Z
 PROPS-END
 
 Revision-number: 1
@@ -27,7 +27,7 @@
 K 8
 svn:date
 V 27
-2010-05-09T14:57:32.094732Z
+2010-11-26T18:01:13.106933Z
 PROPS-END
 
 Node-path: branches
@@ -83,6 +83,28 @@
 b
 
 
+Node-path: trunk/d2
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: trunk/d2/a
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3
+Text-content-sha1: 3f786850e387550fdab836ed7e6dc881de23001b
+Content-length: 12
+
+PROPS-END
+a
+
+
 Node-path: trunk/dlink
 Node-kind: file
 Node-action: add
@@ -146,7 +168,7 @@
 K 8
 svn:date
 V 27
-2010-05-09T14:57:33.071117Z
+2010-11-26T18:01:14.073483Z
 PROPS-END
 
 Node-path: trunk/dlink3
@@ -177,7 +199,7 @@
 K 8
 svn:date
 V 27
-2010-05-09T14:57:35.268057Z
+2010-11-26T18:01:16.205184Z
 PROPS-END
 
 Node-path: trunk/a
@@ -221,7 +243,7 @@
 K 8
 svn:date
 V 27
-2010-05-09T14:57:35.521816Z
+2010-11-26T18:01:16.395962Z
 PROPS-END
 
 Node-path: trunk/dlink3
@@ -239,3 +261,107 @@
 
 
 
+Revision-number: 5
+Prop-content-length: 106
+Content-length: 106
+
+K 7
+svn:log
+V 5
+adddb
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2010-11-26T18:01:16.445072Z
+PROPS-END
+
+Node-path: trunk/d2/b
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: 3b5d5c3712955042212316173ccf37be
+Text-content-sha1: 89e6c98d92887913cadf06b2adb97f26cde4849b
+Content-length: 12
+
+PROPS-END
+b
+
+
+Revision-number: 6
+Prop-content-length: 107
+Content-length: 107
+
+K 7
+svn:log
+V 6
+branch
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2010-11-26T18:01:19.075874Z
+PROPS-END
+
+Node-path: branches/branch
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 5
+Node-copyfrom-path: trunk
+
+
+Node-path: branches/branch/d2/c
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: 2cd6ee2c70b0bde53fbe6cac3c8b8bb1
+Text-content-sha1: 2b66fd261ee5c6cfc8de7fa466bab600bcfe4f69
+Content-length: 12
+
+PROPS-END
+c
+
+
+Node-path: branches/branch/d2/b
+Node-action: delete
+
+
+Revision-number: 7
+Prop-content-length: 109
+Content-length: 109
+
+K 7
+svn:log
+V 10
+clobberdir
+K 10
+svn:author
+V 4
+evil
+K 8
+svn:date
+V 27
+2010-11-26T18:01:21.202158Z
+PROPS-END
+
+Node-path: trunk/d2
+Node-kind: dir
+Node-action: delete
+
+Node-path: trunk/d2
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 6
+Node-copyfrom-path: branches/branch/d2
+
+
+
+
--- a/tests/svn/svndump-replace.sh	Fri Nov 26 20:05:16 2010 -0600
+++ b/tests/svn/svndump-replace.sh	Mon Nov 29 20:13:11 2010 +0100
@@ -17,6 +17,8 @@
 ln -s d dlink
 ln -s d dlink2
 ln -s d dlink3
+mkdir d2
+echo a > d2/a
 cd ..
 svn add *
 svn ci -m 'initial'
@@ -50,6 +52,30 @@
 
 python $RSVN --message=clobber2 --username=evil `pwd`/repo < clobber.rsvn
 
+# Create d2 in branch so d2 has 'a' is in branch/d2 and trunk/d2,
+# 'b' is in trunk/d2 and 'c' is in branch/d2
+cd wc/trunk
+echo b > d2/b
+svn add d2/b
+svn ci -m adddb
+cd ..
+svn up
+svn cp trunk branches/branch
+cd branches/branch
+svn rm d2/b
+echo c > d2/c
+svn add d2/c
+cd ../..
+svn ci -m branch
+svn up
+cd ..
+
+cat > clobber.rsvn <<EOF
+rdelete trunk/d2
+rcopy branches/branch/d2 trunk/d2
+EOF
+python $RSVN --message=clobberdir --username=evil `pwd`/repo < clobber.rsvn
+
 svn log -v file://`pwd`/repo
 
 svnadmin dump repo > ../replace.svndump
--- a/tests/test-convert-svn-move.t	Fri Nov 26 20:05:16 2010 -0600
+++ b/tests/test-convert-svn-move.t	Mon Nov 29 20:13:11 2010 +0100
@@ -103,10 +103,13 @@
   scanning source...
   sorting...
   converting...
-  3 initial
-  2 clobber symlink
-  1 clobber1
-  0 clobber2
+  6 initial
+  5 clobber symlink
+  4 clobber1
+  3 clobber2
+  2 adddb
+  1 branch
+  0 clobberdir
 
   $ cd hg-repo
 
@@ -115,6 +118,7 @@
   $ hg -v manifest -r 1
   644   a
   644   d/b
+  644   d2/a
   644 @ dlink
   644 @ dlink2
   644   dlink3
@@ -124,6 +128,7 @@
   $ hg -v manifest -r 2
   644   a/b
   644   d/b
+  644   d2/a
   644   dlink/b
   644 @ dlink2
   644   dlink3
@@ -133,6 +138,18 @@
   $ hg -v manifest -r 3
   644   a/b
   644   d/b
+  644   d2/a
+  644   dlink/b
+  644 @ dlink2
+  644 @ dlink3
+
+Manifest after clobberdir
+
+  $ hg -v manifest -r 6
+  644   a/b
+  644   d/b
+  644   d2/a
+  644   d2/c
   644   dlink/b
   644 @ dlink2
   644 @ dlink3
@@ -165,20 +182,24 @@
   scanning [  <=>                                                             ] 2
   scanning [   <=>                                                            ] 3
   scanning [    <=>                                                           ] 4
+  scanning [     <=>                                                          ] 5
+  scanning [      <=>                                                         ] 6
+  scanning [       <=>                                                        ] 7
                                                                                   
-  converting [                                                              ] 0/4
-  getting files [==========>                                                ] 1/5
-  getting files [======================>                                    ] 2/5
-  getting files [==================================>                        ] 3/5
-  getting files [==============================================>            ] 4/5
-  getting files [==========================================================>] 5/5
+  converting [                                                              ] 0/7
+  getting files [========>                                                  ] 1/6
+  getting files [==================>                                        ] 2/6
+  getting files [============================>                              ] 3/6
+  getting files [======================================>                    ] 4/6
+  getting files [================================================>          ] 5/6
+  getting files [==========================================================>] 6/6
                                                                                   
-  converting [==============>                                               ] 1/4
+  converting [=======>                                                      ] 1/7
   scanning paths [                                                          ] 0/1
                                                                                   
   getting files [==========================================================>] 1/1
                                                                                   
-  converting [==============================>                               ] 2/4
+  converting [================>                                             ] 2/7
   scanning paths [                                                          ] 0/2
   scanning paths [============================>                             ] 1/2
                                                                                   
@@ -187,16 +208,50 @@
   getting files [===========================================>               ] 3/4
   getting files [==========================================================>] 4/4
                                                                                   
-  converting [=============================================>                ] 3/4
+  converting [=========================>                                    ] 3/7
+  scanning paths [                                                          ] 0/1
+                                                                                  
+  getting files [==========================================================>] 1/1
+                                                                                  
+  converting [==================================>                           ] 4/7
   scanning paths [                                                          ] 0/1
                                                                                   
   getting files [==========================================================>] 1/1
                                                                                   
+  converting [===========================================>                  ] 5/7
+  scanning paths [                                                          ] 0/3
+  scanning paths [==================>                                       ] 1/3
+  scanning paths [=====================================>                    ] 2/3
+                                                                                  
+  getting files [======>                                                    ] 1/8
+  getting files [=============>                                             ] 2/8
+  getting files [=====================>                                     ] 3/8
+  getting files [============================>                              ] 4/8
+  getting files [===================================>                       ] 5/8
+  getting files [===========================================>               ] 6/8
+  getting files [==================================================>        ] 7/8
+  getting files [==========================================================>] 8/8
+                                                                                  
+  converting [====================================================>         ] 6/7
+  scanning paths [                                                          ] 0/1
+                                                                                  
+  getting files [======>                                                    ] 1/8
+  getting files [=============>                                             ] 2/8
+  getting files [=====================>                                     ] 3/8
+  getting files [============================>                              ] 4/8
+  getting files [===================================>                       ] 5/8
+  getting files [===========================================>               ] 6/8
+  getting files [==================================================>        ] 7/8
+  getting files [==========================================================>] 8/8
+                                                                                  
   initializing destination hg-progress repository
   scanning source...
   sorting...
   converting...
-  3 initial
-  2 clobber symlink
-  1 clobber1
-  0 clobber2
+  6 initial
+  5 clobber symlink
+  4 clobber1
+  3 clobber2
+  2 adddb
+  1 branch
+  0 clobberdir