changeset 626:8e621dbb82d4 1.1.1

push: return reasonable status codes to the end user
author Augie Fackler <durin42@gmail.com>
date Sun, 27 Jun 2010 21:18:47 -0500
parents 96552e855d7e
children faba8e636960 4375d37fea1e
files hgsubversion/wrappers.py tests/test_push_command.py tests/test_util.py
diffstat 3 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -129,21 +129,21 @@ def push(repo, dest, force, revs):
     # 1. Find all outgoing commits from this head
     if len(repo.parents()) != 1:
         ui.status('Cowardly refusing to push branch merge\n')
-        return 1
+        return 0 # results in nonzero exit status, see hg's commands.py
     workingrev = repo.parents()[0]
     ui.status('searching for changes\n')
     hashes = meta.revmap.hashes()
     outgoing = util.outgoing_revisions(repo, hashes, workingrev.node())
     if not (outgoing and len(outgoing)):
         ui.status('no changes found\n')
-        return 0
+        return 1 # so we get a sane exit status, see hg's commands.push
     while outgoing:
         oldest = outgoing.pop(-1)
         old_ctx = repo[oldest]
         if len(old_ctx.parents()) != 1:
             ui.status('Found a branch merge, this needs discussion and '
                       'implementation.\n')
-            return 1
+            return 0 # results in nonzero exit status, see hg's commands.py
         base_n = old_ctx.parents()[0].node()
         old_children = repo[base_n].children()
         svnbranch = repo[base_n].branch()
@@ -198,7 +198,7 @@ def push(repo, dest, force, revs):
         meta = repo.svnmeta(svn.uuid)
         hashes = meta.revmap.hashes()
     util.swap_out_encoding(old_encoding)
-    return 0
+    return 1 # so we get a sane exit status, see hg's commands.push
 
 
 def pull(repo, source, heads=[], force=False):
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -271,7 +271,8 @@ class PushTests(test_util.TestBase):
         wc2path = self.wc_path + '_clone'
         u = self.repo.ui
         hg.clone(self.repo.ui, self.wc_path, wc2path, update=False)
-        self.pushrevisions()
+        res = self.pushrevisions()
+        self.assertEqual(0, res)
         oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc'))
         hgrc = oldf.read()
         oldf.close()
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -213,9 +213,10 @@ class TestBase(unittest.TestCase):
     def pushrevisions(self, stupid=False, expected_extra_back=0):
         before = len(self.repo)
         self.repo.ui.setconfig('hgsubversion', 'stupid', str(stupid))
-        commands.push(self.repo.ui, self.repo)
+        res = commands.push(self.repo.ui, self.repo)
         after = len(self.repo)
         self.assertEqual(expected_extra_back, after - before)
+        return res
 
     def svnls(self, path, rev='HEAD'):
         path = self.repo_path + '/' + path