changeset 1509:8c7dae2e0f54

svnwrap: don't add paths to revision outside of subdir It prevents from closing the default branch on some occasional removal of directory from outside of subdir in a single layout.
author Ivan Lezhankin <ilezhankin@yandex-team.ru>
date Tue, 23 May 2017 15:09:02 +0300
parents 5441a9d1fd50
children d4eb7b064085
files hgsubversion/svnwrap/common.py tests/fixtures/dir_removal.svndump tests/test_fetch_dir_removal.py
diffstat 3 files changed, 122 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnwrap/common.py
+++ b/hgsubversion/svnwrap/common.py
@@ -55,7 +55,8 @@ class Revision(tuple):
         _paths = {}
         if paths:
             for p in paths:
-                _paths[p[len(strip_path):]] = paths[p]
+                if p.startswith(strip_path):
+                    _paths[p[len(strip_path):]] = paths[p]
         return tuple.__new__(self,
                              (revnum, author, message, date, _paths))
 
new file mode 100644
--- /dev/null
+++ b/tests/fixtures/dir_removal.svndump
@@ -0,0 +1,103 @@
+SVN-fs-dump-format-version: 2
+
+UUID: 5554378f-55cc-437f-9045-6148f657307d
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2017-05-23T11:48:49.399395Z
+PROPS-END
+
+Revision-number: 1
+Prop-content-length: 103
+Content-length: 103
+
+K 10
+svn:author
+V 8
+testuser
+K 8
+svn:date
+V 27
+2017-05-23T11:49:53.974692Z
+K 7
+svn:log
+V 1
+1
+PROPS-END
+
+Node-path: dir1
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: dir1/1.txt
+Node-kind: file
+Node-action: add
+Text-content-md5: d41d8cd98f00b204e9800998ecf8427e
+Text-content-sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
+Prop-content-length: 10
+Text-content-length: 0
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: dir2
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: dir2/2.txt
+Node-kind: file
+Node-action: add
+Text-content-md5: d41d8cd98f00b204e9800998ecf8427e
+Text-content-sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
+Prop-content-length: 10
+Text-content-length: 0
+Content-length: 10
+
+PROPS-END
+
+
+Revision-number: 2
+Prop-content-length: 103
+Content-length: 103
+
+K 10
+svn:author
+V 8
+testuser
+K 8
+svn:date
+V 27
+2017-05-23T11:50:14.852941Z
+K 7
+svn:log
+V 1
+2
+PROPS-END
+
+Node-path: dir1/dir2
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 1
+Node-copyfrom-path: dir2
+
+
+Node-path: dir2
+Node-action: delete
+
+
new file mode 100644
--- /dev/null
+++ b/tests/test_fetch_dir_removal.py
@@ -0,0 +1,17 @@
+import test_util
+
+import sys
+import unittest
+
+class TestFetchDirectoryRemoval(test_util.TestBase):
+    stupid_mode_tests = True
+
+    def test_removal(self):
+        repo = self._load_fixture_and_fetch('dir_removal.svndump',
+                                            layout='single',
+                                            subdir='dir1')
+        self.assertEqual(sorted(repo['tip'].manifest().keys()),
+                         ['1.txt', 'dir2/2.txt'])
+        extra = repo['tip'].extra().copy()
+        extra.pop('convert_revision', None)
+        self.assertEqual(extra, {'branch': 'default'})