Commits

Patrick Mézard committed 8417be7

pushmod: keep the root svn dir when emptying the hg repo (issue359)

Comments (0)

Files changed (2)

hgsubversion/pushmod.py

             added.append(d)
 
     for d in olddirs:
+        if not d:
+            # Do not remove the root directory when the hg repo becomes
+            # empty. hgsubversion cannot create branches, do not remove
+            # them.
+            continue
         if d not in newdirs and _isdir(svn, branchpath, d):
             deleted.append(d)
 

tests/test_push_command.py

         self.commitchanges(changes, parent=par)
         self.pushrevisions()
 
+    def test_push_emptying_changeset(self):
+        r = self.repo['tip']
+        changes = [
+                ('alpha', None, None),
+                ('beta', None, None),
+                ]
+        parent = self.repo['tip'].rev()
+        self.commitchanges(changes, parent=parent)
+        self.pushrevisions()
+        self.assertEqual({}, self.repo['tip'].manifest())
+
+        # Try to re-add a file after emptying the branch
+        changes = [
+                ('alpha', 'alpha', 'alpha'),
+                ]
+        self.commitchanges(changes, parent=self.repo['tip'].rev())
+        self.pushrevisions()
+        self.assertEqual(['alpha'], list(self.repo['tip'].manifest()))
+
 def suite():
     test_classes = [PushTests, ]
     all_tests = []