chiark / gitweb /
Set exit code to 3 on merge conflict
authorKarl Hasselström <kha@treskal.com>
Wed, 12 Dec 2007 20:56:42 +0000 (21:56 +0100)
committerKarl Hasselström <kha@treskal.com>
Wed, 9 Jan 2008 23:37:13 +0000 (00:37 +0100)
Signed-off-by: Karl Hasselström <kha@treskal.com>
stgit/commands/coalesce.py
stgit/commands/goto.py
stgit/lib/transaction.py
stgit/main.py
stgit/utils.py

index 2330231033eda69172e2b85e2bb410e8d7f54031..d2cba3ee8c5a17b5a3e853a7d8ba80730c62d45a 100644 (file)
@@ -110,7 +110,7 @@ def _coalesce(stack, iw, name, msg, save_template, patches):
         return
     except transaction.TransactionHalted:
         pass
-    trans.run(iw)
+    return trans.run(iw)
 
 def func(parser, options, args):
     stack = directory.repository.current_stack
@@ -118,5 +118,5 @@ def func(parser, options, args):
                                           + list(stack.patchorder.unapplied)))
     if len(patches) < 2:
         raise common.CmdException('Need at least two patches')
-    _coalesce(stack, stack.repository.default_iw(),
-              options.name, options.message, options.save_template, patches)
+    return _coalesce(stack, stack.repository.default_iw(), options.name,
+                     options.message, options.save_template, patches)
index d78929d341ec026d65f8746b485c09357cfce7fd..763a8aff29bc16c8d251d384b39848c8e6e8ddc1 100644 (file)
@@ -48,4 +48,4 @@ def func(parser, options, args):
             pass
     else:
         raise common.CmdException('Patch "%s" does not exist' % patch)
-    trans.run(iw)
+    return trans.run(iw)
index 663d393f1860debbe38b64ae7cc2106fddc87a18..0ca647eb228b2950a4a9e2f85426a68c6e4cf9f0 100644 (file)
@@ -1,4 +1,4 @@
-from stgit import exception
+from stgit import exception, utils
 from stgit.out import *
 from stgit.lib import git
 
@@ -111,6 +111,11 @@ class StackTransaction(object):
         self.__stack.patchorder.applied = self.__applied
         self.__stack.patchorder.unapplied = self.__unapplied
 
+        if self.__error:
+            return utils.STGIT_CONFLICT
+        else:
+            return utils.STGIT_SUCCESS
+
     def __halt(self, msg):
         self.__error = msg
         raise TransactionHalted(msg)
index 4281062d16e1294805e2f9a7b3ad7b0420cdc5e1..79044b038e2a02673fa2cbbcfbfccfb5adb10930 100644 (file)
@@ -275,7 +275,7 @@ def main():
             else:
                 command.crt_series = Series()
 
-        command.func(parser, options, args)
+        ret = command.func(parser, options, args)
     except (StgException, IOError, ParsingError, NoSectionError), err:
         out.error(str(err), title = '%s %s' % (prog, cmd))
         if debug_level > 0:
@@ -285,4 +285,4 @@ def main():
     except KeyboardInterrupt:
         sys.exit(utils.STGIT_GENERAL_ERROR)
 
-    sys.exit(utils.STGIT_SUCCESS)
+    sys.exit(ret or utils.STGIT_SUCCESS)
index 6568da5912f32b8e723b21a0c89f3854d16124ff..2ff1d74229b7bc36ae3575966f42cadfcbc7c5f5 100644 (file)
@@ -317,6 +317,7 @@ def make_message_options():
 STGIT_SUCCESS = 0        # everything's OK
 STGIT_GENERAL_ERROR = 1  # seems to be non-command-specific error
 STGIT_COMMAND_ERROR = 2  # seems to be a command that failed
+STGIT_CONFLICT = 3       # merge conflict, otherwise OK
 
 def strip_leading(prefix, s):
     """Strip leading prefix from a string. Blow up if the prefix isn't