changeset 1040:ada2400241c4

fixes for running under Mercurial 2.0
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Mon, 05 Aug 2013 20:27:31 +0200
parents 3df6ed4e7561
children 70090e2ee262
files hgsubversion/util.py hgsubversion/wrappers.py tests/test_push_command.py
diffstat 3 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -8,6 +8,7 @@ from mercurial import cmdutil
 from mercurial import error
 from mercurial import hg
 from mercurial import node
+from mercurial import repair
 from mercurial import util as hgutil
 
 try:
@@ -84,6 +85,14 @@ def islocalrepo(url):
         path = path.rsplit('/', 1)[0]
     return False
 
+def strip(ui, repo, changesets, *args , **opts):
+    try:
+        repair.strip(ui, repo, changesets, *args, **opts)
+    except TypeError:
+        # only 2.1.2 and later allow strip to take a list of nodes
+        for changeset in changesets:
+            repair.strip(ui, repo, changeset, *args, **opts)
+
 
 def version(ui):
     """Return version information if available."""
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -303,7 +303,7 @@ def push(repo, dest, force, revs):
             util.swap_out_encoding()
 
         # strip the original changesets since the push was successful
-        repair.strip(ui, repo, outgoing, "all")
+        util.strip(ui, repo, outgoing, "all")
     finally:
         try:
             # It's always safe to delete the temporary commits.
@@ -315,8 +315,7 @@ def push(repo, dest, force, revs):
                 parent = repo[None].p1()
                 if parent.node() in temporary_commits:
                     hg.update(repo, parent.p1().node())
-                for n in temporary_commits:
-                    repair.strip(ui, repo, n, backup=None)
+                util.strip(ui, repo, temporary_commits, backup=None)
         finally:
             util.swap_out_encoding(old_encoding)
     return 1 # so we get a sane exit status, see hg's commands.push
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -17,6 +17,8 @@ from mercurial import node
 from mercurial import revlog
 from mercurial import util as hgutil
 
+from hgsubversion import util
+
 import time
 
 
@@ -594,10 +596,12 @@ class PushTests(test_util.TestBase):
         # verify that the first commit is pushed, and the second is not
         commit2 = self.repo['tip']
         self.assertEqual(commit2.files(), ['delta', ])
-        self.assertTrue(commit2.mutable())
+        self.assertEqual(util.getsvnrev(commit2), None)
         commit1 = commit2.parents()[0]
         self.assertEqual(commit1.files(), ['gamma', ])
-        self.assertFalse(commit1.mutable())
+        prefix = 'svn:' + self.repo.svnmeta().uuid
+        self.assertEqual(util.getsvnrev(commit1),
+                         prefix + '/branches/the_branch@5')
 
     def test_push_two_that_modify_same_file(self):
         '''
@@ -623,10 +627,14 @@ class PushTests(test_util.TestBase):
         # verify that both commits are pushed
         commit1 = self.repo['tip']
         self.assertEqual(commit1.files(), ['delta', 'gamma'])
-        self.assertFalse(commit1.mutable())
+
+        prefix = 'svn:' + self.repo.svnmeta().uuid
+        self.assertEqual(util.getsvnrev(commit1),
+                         prefix + '/branches/the_branch@6')
         commit2 = commit1.parents()[0]
         self.assertEqual(commit2.files(), ['gamma'])
-        self.assertFalse(commit2.mutable())
+        self.assertEqual(util.getsvnrev(commit2),
+                         prefix + '/branches/the_branch@5')
 
     def test_push_in_subdir(self, commit=True):
         repo = self.repo