changeset 11205:d26f662bfbf5

rebase: add error codes Suggested by Dirk Hasselbalch
author Matt Mackall <mpm@selenic.com>
date Thu, 20 May 2010 15:58:16 -0500
parents 54e93b86a9e3
children 1d714c1546b5
files hgext/rebase.py tests/test-rebase-parameters.out
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Thu May 20 15:20:25 2010 -0500
+++ b/hgext/rebase.py	Thu May 20 15:58:16 2010 -0500
@@ -69,6 +69,8 @@
 
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
+
+    Returns 0 on success, 1 if nothing to rebase.
     """
     originalwd = target = None
     external = nullrev
@@ -115,8 +117,7 @@
             (originalwd, target, state, collapsef, keepf,
                                 keepbranchesf, external) = restorestatus(repo)
             if abortf:
-                abort(repo, originalwd, target, state)
-                return
+                return abort(repo, originalwd, target, state)
         else:
             if srcf and basef:
                 raise error.ParseError('rebase', _('cannot specify both a '
@@ -134,7 +135,7 @@
             if not result:
                 # Empty state built, nothing to rebase
                 ui.status(_('nothing to rebase\n'))
-                return
+                return 1
             else:
                 originalwd, target, state = result
                 if collapsef:
@@ -428,6 +429,7 @@
     if set(repo.changelog.descendants(target)) - set(state.values()):
         repo.ui.warn(_("warning: new changesets detected on target branch, "
                                                     "can't abort\n"))
+        return -1
     else:
         # Strip from the first rebased revision
         merge.update(repo, repo[originalwd].rev(), False, True, False)
@@ -438,6 +440,7 @@
             repair.strip(repo.ui, repo, repo[strippoint].node())
         clearstatus(repo)
         repo.ui.status(_('rebase aborted\n'))
+        return 0
 
 def buildstate(repo, dest, src, base, detach):
     'Define which revisions are going to be rebased and where'
--- a/tests/test-rebase-parameters.out	Thu May 20 15:20:25 2010 -0500
+++ b/tests/test-rebase-parameters.out	Thu May 20 15:58:16 2010 -0500
@@ -47,6 +47,8 @@
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
 
+    Returns 0 on success, 1 if nothing to rebase.
+
 options:
 
  -s --source        rebase from the specified changeset
@@ -111,6 +113,8 @@
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
 
+    Returns 0 on success, 1 if nothing to rebase.
+
 options:
 
  -s --source        rebase from the specified changeset
@@ -175,6 +179,8 @@
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
 
+    Returns 0 on success, 1 if nothing to rebase.
+
 options:
 
  -s --source        rebase from the specified changeset
@@ -239,6 +245,8 @@
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
 
+    Returns 0 on success, 1 if nothing to rebase.
+
 options:
 
  -s --source        rebase from the specified changeset