changeset 963:64d961130a07

editor: do not record invalid path deletion
author Patrick Mezard <patrick@mezard.eu>
date Mon, 15 Oct 2012 22:24:29 +0200
parents 8648ccfb8325
children 27fec8bf9273
files hgsubversion/editor.py tests/fixtures/copies.sh tests/fixtures/copies.svndump tests/test_fetch_mappings.py
diffstat 4 files changed, 50 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/editor.py
+++ b/hgsubversion/editor.py
@@ -225,7 +225,8 @@ class HgEditor(svnwrap.Editor):
                 'opened directory: %s != %s' % (self._opendirs[-1][0], baton))
 
     def _deletefile(self, path):
-        self._deleted.add(path)
+        if self.meta.is_path_valid(path):
+            self._deleted.add(path)
         if path in self._svncopies:
             del self._svncopies[path]
         self._missing.discard(path)
--- a/tests/fixtures/copies.sh
+++ b/tests/fixtures/copies.sh
@@ -21,6 +21,9 @@ svn ci -m 'copy/edit trunk/dir/a'
 svn up
 svn cp trunk/dir2 trunk/dir3
 svn ci -m 'copy dir2 to dir3'
+svn rm trunk/dir3/a
+svn cp trunk/dir2/a trunk/dir3/a
+svn ci -m 'copy and remove'
 cd ..
 
 svnadmin dump testrepo > ../copies.svndump
--- a/tests/fixtures/copies.svndump
+++ b/tests/fixtures/copies.svndump
@@ -1,6 +1,6 @@
 SVN-fs-dump-format-version: 2
 
-UUID: f9962aa6-eec5-4335-8af9-9ae89f4b18b2
+UUID: 6f377846-a035-4244-a154-e87a9351a653
 
 Revision-number: 0
 Prop-content-length: 56
@@ -9,7 +9,7 @@ Content-length: 56
 K 8
 svn:date
 V 27
-2012-10-14T14:22:33.372222Z
+2012-10-15T19:02:56.936694Z
 PROPS-END
 
 Revision-number: 1
@@ -23,7 +23,7 @@ pmezard
 K 8
 svn:date
 V 27
-2012-10-14T14:22:33.393643Z
+2012-10-15T19:02:56.958201Z
 K 7
 svn:log
 V 4
@@ -72,7 +72,7 @@ pmezard
 K 8
 svn:date
 V 27
-2012-10-14T14:22:35.042430Z
+2012-10-15T19:02:58.046478Z
 K 7
 svn:log
 V 21
@@ -109,7 +109,7 @@ pmezard
 K 8
 svn:date
 V 27
-2012-10-14T14:22:38.041919Z
+2012-10-15T19:03:01.045897Z
 K 7
 svn:log
 V 17
@@ -123,3 +123,36 @@ Node-copyfrom-rev: 2
 Node-copyfrom-path: trunk/dir2
 
 
+Revision-number: 4
+Prop-content-length: 117
+Content-length: 117
+
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2012-10-15T19:03:03.046654Z
+K 7
+svn:log
+V 15
+copy and remove
+PROPS-END
+
+Node-path: trunk/dir3/a
+Node-kind: file
+Node-action: delete
+
+Node-path: trunk/dir3/a
+Node-kind: file
+Node-action: add
+Node-copyfrom-rev: 2
+Node-copyfrom-path: trunk/dir2/a
+Text-copy-source-md5: dd8c6a395b5dd36c56d23275028f526c
+Text-copy-source-sha1: 05dec960e24d918b8a73a1c53bcbbaac2ee5c2e0
+
+
+
+
--- a/tests/test_fetch_mappings.py
+++ b/tests/test_fetch_mappings.py
@@ -152,14 +152,14 @@ class MapTests(test_util.TestBase):
         # directory.
         repo = self._loadwithfilemap('copies.svndump', "exclude dir2\n",
                 failonmissing=False)
-        self.assertEqual(['dir/a', 'dir3/a'], list(repo['tip']))
+        self.assertEqual(['dir/a', 'dir3/a'], list(repo[2]))
 
     def test_file_map_exclude_copy_source_and_dest(self):
         # dir3 is excluded and copied from dir2 which is also excluded.
         # dir3 files should not be marked as missing and fetched.
         repo = self._loadwithfilemap('copies.svndump',
                 "exclude dir2\nexclude dir3\n")
-        self.assertEqual(['dir/a'], list(repo['tip']))
+        self.assertEqual(['dir/a'], list(repo[2]))
 
     def test_file_map_include_file_exclude_dir(self):
         # dir3 is excluded but we want dir3/a, which is also copied from
@@ -167,7 +167,11 @@ class MapTests(test_util.TestBase):
         repo = self._loadwithfilemap('copies.svndump',
                 "include .\nexclude dir2\nexclude dir3\ninclude dir3/a\n",
                 failonmissing=False)
-        self.assertEqual(['dir/a', 'dir3/a'], list(repo['tip']))
+        self.assertEqual(['dir/a', 'dir3/a'], list(repo[2]))
+
+    def test_file_map_delete_dest(self):
+        repo = self._loadwithfilemap('copies.svndump', 'exclude dir3\n')
+        self.assertEqual(['dir/a', 'dir2/a'], list(repo[3]))
 
     def test_branchmap(self, stupid=False):
         repo_path = self.load_svndump('branchmap.svndump')