changeset 785:40ddf8213fa2

pushmod: do not delete the whole branch when deleting .hgsub When deleting .hgsub, and only .hgsub, the root directory '' was marked as changed. Since it was not listed in the existing directory list, this single record was enough to trigger a deletion of the current branch. We changed the directory parser to always emit the '' element.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 13 Feb 2011 20:14:01 +0100
parents f214fb3f92cd
children 607f43a0f09c
files hgsubversion/pushmod.py tests/test_externals.py
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/pushmod.py
+++ b/hgsubversion/pushmod.py
@@ -33,12 +33,16 @@ def _getdirchanges(svn, branchpath, pare
     in either list.
     """
     def finddirs(path, includeself=False):
-        if includeself:
+        if includeself and path:
             yield path
         pos = path.rfind('/')
         while pos != -1:
             yield path[:pos]
             pos = path.rfind('/', 0, pos)
+        # Include the root path, properties can be set explicitely on it
+        # (like externals), and you want to preserve it if there are any
+        # other child item still existing.
+        yield ''
 
     def getctxdirs(ctx, keptdirs, extdirs):
         dirs = {}
--- a/tests/test_externals.py
+++ b/tests/test_externals.py
@@ -362,6 +362,20 @@ HEAD subdir1/deps/project2
         self.assertTrue('subdir2/a' in self.repo['tip'])
         self.assertTrue('subdir1/a' not in self.repo['tip'])
 
+        # Move the externals so they are defined on the base directory,
+        # this used to cause full branch removal when deleting the .hgsub
+        changes = [
+            ('.hgsub', '.hgsub', """\
+subdir1/deps/project1 = [hgsubversion] :^/externals/project1 subdir1/deps/project1
+"""),
+            ('.hgsubstate', '.hgsubstate', """\
+HEAD subdir1/deps/project1
+"""),
+            ]
+        self.commitchanges(changes)
+        self.pushrevisions(stupid)
+        self.assertchanges(changes, self.repo['tip'])
+
         # Test externals removal
         changes = [
             ('.hgsub', None, None),