changeset 145:b37c401b7f92

hg_delta_editor: reset properties of deleted entries Otherwise, in case of entry replacement the properties are incorrectly inherited.
author Patrick Mezard <pmezard@gmail.com>
date Mon, 15 Dec 2008 21:57:10 -0600
parents 19aabf67c792
children 4da9f20aef01
files hg_delta_editor.py tests/fixtures/symlinks.sh tests/fixtures/symlinks.svndump tests/test_fetch_symlinks.py
diffstat 4 files changed, 54 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hg_delta_editor.py
+++ b/hg_delta_editor.py
@@ -200,6 +200,13 @@ class HgChangeReceiver(delta.Editor):
         if path in self.deleted_files:
             del self.deleted_files[path]
 
+    def delete_file(self, path):
+        self.deleted_files[path] = True
+        self.current_files[path] = ''
+        self.current_files_exec[path] = False
+        self.current_files_symlink[path] = False
+        self.ui.status('D %s\n' % path)
+
     def _normalize_path(self, path):
         '''Normalize a path to strip of leading slashes and our subdir if we
         have one.
@@ -516,12 +523,8 @@ class HgChangeReceiver(delta.Editor):
                 for f in ctx.walk(our_util.PrefixMatch(br_path2)):
                     f_p = '%s/%s' % (path, f[len(br_path2):])
                     if f_p not in self.current_files:
-                        self.deleted_files[f_p] = True
-                        self.current_files[f_p] = ''
-                        self.ui.status('D %s\n' % f_p)
-            self.deleted_files[path] = True
-            self.current_files[path] = ''
-            self.ui.status('D %s\n' % path)
+                        self.delete_file(f_p)
+            self.delete_file(path)
 
     @stash_exception_on_self
     def open_file(self, path, parent_baton, base_revision, p=None):
--- a/tests/fixtures/symlinks.sh
+++ b/tests/fixtures/symlinks.sh
@@ -20,9 +20,10 @@ svn co $svnurl project
 cd project/trunk
 echo a > a
 ln -s a linka
+ln -s a linka2
 mkdir d
 ln -s a d/linka
-svn add a linka d
+svn add a linka linka2 d
 svn ci -m "add symlinks"
 # Move symlinks
 svn mv linka linkaa
@@ -39,6 +40,12 @@ svn ci -m "update symlinks"
 rm linkaa
 echo data > linkaa
 svn propdel svn:special linkaa
+# Replace another symlink with a regular file in another way
+# It should mark linka2 as R(eplaced)
+svn rm linka2
+echo data2 > linka2
+svn add linka2
+svn propdel svn:special linka2
 svn rm d2/linka
 svn ci -m "undo link"
 cd ../..
--- a/tests/fixtures/symlinks.svndump
+++ b/tests/fixtures/symlinks.svndump
@@ -1,6 +1,6 @@
 SVN-fs-dump-format-version: 2
 
-UUID: f4b30fa8-841e-4d12-8994-eb41ecdeab2e
+UUID: bcc1a3f4-ccae-49ba-b1c5-003ce86e3e31
 
 Revision-number: 0
 Prop-content-length: 56
@@ -9,7 +9,7 @@ Content-length: 56
 K 8
 svn:date
 V 27
-2008-12-07T12:10:46.975375Z
+2008-12-15T21:58:13.685247Z
 PROPS-END
 
 Revision-number: 1
@@ -27,7 +27,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-12-07T12:10:47.047283Z
+2008-12-15T21:58:13.747067Z
 PROPS-END
 
 Node-path: branches
@@ -63,7 +63,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-12-07T12:10:48.218632Z
+2008-12-15T21:58:14.243223Z
 PROPS-END
 
 Node-path: trunk/a
@@ -117,6 +117,21 @@ V 1
 PROPS-END
 link a
 
+Node-path: trunk/linka2
+Node-kind: file
+Node-action: add
+Prop-content-length: 33
+Text-content-length: 6
+Text-content-md5: c118dba188202a1efc975bef6064180b
+Content-length: 39
+
+K 11
+svn:special
+V 1
+*
+PROPS-END
+link a
+
 Revision-number: 3
 Prop-content-length: 117
 Content-length: 117
@@ -132,7 +147,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-12-07T12:10:51.153329Z
+2008-12-15T21:58:17.162148Z
 PROPS-END
 
 Node-path: trunk/d2
@@ -193,7 +208,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-12-07T12:10:52.174562Z
+2008-12-15T21:58:18.188491Z
 PROPS-END
 
 Node-path: trunk/d2/linka
@@ -229,13 +244,25 @@ pmezard
 K 8
 svn:date
 V 27
-2008-12-07T12:10:53.200258Z
+2008-12-15T21:58:19.297689Z
 PROPS-END
 
 Node-path: trunk/d2/linka
 Node-action: delete
 
 
+Node-path: trunk/linka2
+Node-kind: file
+Node-action: replace
+Prop-content-length: 10
+Text-content-length: 6
+Text-content-md5: edc3d3797971f12c7f5e1d106dd5cee2
+Content-length: 16
+
+PROPS-END
+data2
+
+
 Node-path: trunk/linkaa
 Node-kind: file
 Node-action: change
--- a/tests/test_fetch_symlinks.py
+++ b/tests/test_fetch_symlinks.py
@@ -21,14 +21,17 @@ class TestFetchSymlinks(test_util.TestBa
         links = {
             0: {
                 'linka': 'a',
+                'linka2': 'a',
                 'd/linka': 'a',
                 },
             1: {
                 'linkaa': 'a',
+                'linka2': 'a',
                 'd2/linka': 'a',
                 },
             2: {
                 'linkaa': 'b',
+                'linka2': 'a',
                 'd2/linka': 'b',
                 },
             3: {