# HG changeset patch # User Patrick Mezard # Date 1347199948 -7200 # Node ID 8417be758047c55fb711aeffc57a695df33e58a3 # Parent d99ed94f476040aea5f2406a7278f675f06a0457 pushmod: keep the root svn dir when emptying the hg repo (issue359) diff --git a/hgsubversion/pushmod.py b/hgsubversion/pushmod.py --- a/hgsubversion/pushmod.py +++ b/hgsubversion/pushmod.py @@ -82,6 +82,11 @@ def _getdirchanges(svn, branchpath, pare 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) diff --git a/tests/test_push_command.py b/tests/test_push_command.py --- a/tests/test_push_command.py +++ b/tests/test_push_command.py @@ -503,6 +503,25 @@ class PushTests(test_util.TestBase): 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 = []