diff options
author | Fredrik Kuivinen <freku045@student.liu.se> | 2005-09-12 23:30:47 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-09-12 14:53:58 -0700 |
commit | 654291a2acb1c28b884cb9376a0d7eb5f8c090b5 (patch) | |
tree | 7e88e8a4369465bf419360dbda6bca111a110ffd | |
parent | [PATCH] Exit with status code 2 if we get an exception. (diff) | |
download | tgif-654291a2acb1c28b884cb9376a0d7eb5f8c090b5.tar.xz |
[PATCH] Introduce a 'die' function.
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-x | git-merge-fredrik.py | 15 | ||||
-rw-r--r-- | gitMergeCommon.py | 12 |
2 files changed, 13 insertions, 14 deletions
diff --git a/git-merge-fredrik.py b/git-merge-fredrik.py index a5ca076021..e4c6fe3c61 100755 --- a/git-merge-fredrik.py +++ b/git-merge-fredrik.py @@ -120,9 +120,8 @@ def unmergedCacheEntries(): e.stages[stage].mode = mode e.stages[stage].sha1 = sha1 else: - print 'Error: Merge program failed: Unexpected output from', \ - 'git-ls-files:', l - sys.exit(2) + die('Error: Merge program failed: Unexpected output from', \ + 'git-ls-files:', l) return res def mergeTrees(head, merge, common, branch1Name, branch2Name, @@ -381,15 +380,12 @@ def processEntry(entry, branch1Name, branch2Name, files, dirs, os.unlink(src1) os.unlink(src2) else: - print 'ERROR: Fatal merge failure.' - print "ERROR: Shouldn't happen" - sys.exit(2) + die("ERROR: Fatal merge failure, shouldn't happen.") return cleanMerge def usage(): - print 'Usage:', sys.argv[0], ' <base>... -- <head> <remote>..' - sys.exit(2) + die('Usage:', sys.argv[0], ' <base>... -- <head> <remote>..') # main entry point as merge strategy module # The first parameters up to -- are merge bases, and the rest are heads. @@ -399,8 +395,7 @@ def usage(): for nextArg in xrange(1, len(sys.argv)): if sys.argv[nextArg] == '--': if len(sys.argv) != nextArg + 3: - print 'Not handling anything other than two heads merge.' - sys.exit(2) + die('Not handling anything other than two heads merge.') try: h1 = firstBranch = sys.argv[nextArg + 1] h2 = secondBranch = sys.argv[nextArg + 2] diff --git a/gitMergeCommon.py b/gitMergeCommon.py index dfa49ff7ec..7e7f317119 100644 --- a/gitMergeCommon.py +++ b/gitMergeCommon.py @@ -10,6 +10,10 @@ if sys.version_info[0] < 2 or \ import subprocess +def die(*args): + printList(args, sys.stderr) + sys.exit(2) + # Debugging machinery # ------------------- @@ -28,11 +32,11 @@ def debug(*args): if funcName in functionsToDebug: printList(args) -def printList(list): +def printList(list, file=sys.stdout): for x in list: - sys.stdout.write(str(x)) - sys.stdout.write(' ') - sys.stdout.write('\n') + file.write(str(x)) + file.write(' ') + file.write('\n') # Program execution # ----------------- |