Commits

Augie Fackler  committed 8e621db

push: return reasonable status codes to the end user

  • Participants
  • Parent commits 96552e8
  • Tags 1.1.1

Comments (0)

Files changed (3)

File hgsubversion/wrappers.py

     # 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()
         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):

File tests/test_push_command.py

         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()

File tests/test_util.py

     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