@matheusbsbs / matheus-bagliano / commits / 654291a2ac
Fork 0

[PATCH] Introduce a 'die' function.

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>

Fredrik Kuivinen committed Sep 12, 2005 at 23:30 UTC 654291a2acb1c28b884cb9376a0d7eb5f8c090b5
2 files changed +13 -14
git-merge-fredrik.py
+5 -10
@@ -120,9 +120,8 @@ def unmergedCacheEntries():
120 e.stages[stage].mode = mode
121 e.stages[stage].sha1 = sha1
122 else:
123 - print 'Error: Merge program failed: Unexpected output from', \
124 - 'git-ls-files:', l
125 - sys.exit(2)
123 + die('Error: Merge program failed: Unexpected output from', \
124 + 'git-ls-files:', l)
125 return res
126
127 def mergeTrees(head, merge, common, branch1Name, branch2Name,
@@ -381,15 +380,12 @@ def processEntry(entry, branch1Name, branch2Name, files, dirs,
380 os.unlink(src1)
381 os.unlink(src2)
382 else:
384 - print 'ERROR: Fatal merge failure.'
385 - print "ERROR: Shouldn't happen"
386 - sys.exit(2)
383 + die("ERROR: Fatal merge failure, shouldn't happen.")
384
385 return cleanMerge
386
387 def usage():
391 - print 'Usage:', sys.argv[0], ' <base>... -- <head> <remote>..'
392 - sys.exit(2)
388 + die('Usage:', sys.argv[0], ' <base>... -- <head> <remote>..')
389
390 # main entry point as merge strategy module
391 # The first parameters up to -- are merge bases, and the rest are heads.
@@ -399,8 +395,7 @@ def usage():
395 for nextArg in xrange(1, len(sys.argv)):
396 if sys.argv[nextArg] == '--':
397 if len(sys.argv) != nextArg + 3:
402 - print 'Not handling anything other than two heads merge.'
403 - sys.exit(2)
398 + die('Not handling anything other than two heads merge.')
399 try:
400 h1 = firstBranch = sys.argv[nextArg + 1]
401 h2 = secondBranch = sys.argv[nextArg + 2]
gitMergeCommon.py
+8 -4
@@ -10,6 +10,10 @@ if sys.version_info[0] < 2 or \
10
11 import subprocess
12
13 +def die(*args):
14 + printList(args, sys.stderr)
15 + sys.exit(2)
16 +
17 # Debugging machinery
18 # -------------------
19
@@ -28,11 +32,11 @@ def debug(*args):
32 if funcName in functionsToDebug:
33 printList(args)
34
31 -def printList(list):
35 +def printList(list, file=sys.stdout):
36 for x in list:
33 - sys.stdout.write(str(x))
34 - sys.stdout.write(' ')
35 - sys.stdout.write('\n')
37 + file.write(str(x))
38 + file.write(' ')
39 + file.write('\n')
40
41 # Program execution
42 # -----------------