# HG changeset patch # User Augie Fackler # Date 1277691527 18000 # Node ID 8e621dbb82d4363a85317638ad237e2817c56347 # Parent 96552e855d7e1143bf88d143e47f1d16ce1e68e0 push: return reasonable status codes to the end user diff --git a/hgsubversion/wrappers.py b/hgsubversion/wrappers.py --- 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): 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 @@ -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() diff --git a/tests/test_util.py b/tests/test_util.py --- 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