@matheusbsbs / matheus-bagliano / commits / 157dc07368
Fork 0

merge-recursive: cleanup setIndexStages

Fredrik points out there is a useful wrapper runProgram() used everywhere that we can use to feed input into subprocess. Use it to catch errors from the subprocess; it is a good cleanup as well. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 11, 2005 at 01:55 UTC 157dc07368faf6537af1d2ce676a4f2dda2f71a6
1 file changed +5 -12
git-merge-recursive.py
+5 -12
@@ -284,17 +284,11 @@ def setIndexStages(path,
284 oSHA1, oMode,
285 aSHA1, aMode,
286 bSHA1, bMode):
287 - prog = ['git-update-index', '-z', '--index-info']
288 - proc = subprocess.Popen(prog, stdin=subprocess.PIPE)
289 - pipe = proc.stdin
290 - # Clear stages first.
291 - pipe.write("0 " + ("0" * 40) + "\t" + path + "\0")
292 - # Set stages
293 - pipe.write("%o %s %d\t%s\0" % (oMode, oSHA1, 1, path))
294 - pipe.write("%o %s %d\t%s\0" % (aMode, aSHA1, 2, path))
295 - pipe.write("%o %s %d\t%s\0" % (bMode, bSHA1, 3, path))
296 - pipe.close()
297 - proc.wait()
287 + runProgram(['git-update-index', '-z', '--index-info'],
288 + input="0 " + ("0" * 40) + "\t" + path + "\0" + \
289 + "%o %s %d\t%s\0" % (oMode, oSHA1, 1, path) + \
290 + "%o %s %d\t%s\0" % (aMode, aSHA1, 2, path) + \
291 + "%o %s %d\t%s\0" % (bMode, bSHA1, 3, path))
292
293 def removeFile(clean, path):
294 updateCache = cacheOnly or clean
@@ -724,7 +718,6 @@ def processRenames(renamesA, renamesB, branchNameA, branchNameB):
718 cleanMerge = False
719
720 if not cacheOnly:
727 - # Stuff stage1/2/3
721 setIndexStages(ren1.dstName,
722 oSHA1, oMode,
723 aSHA1, aMode,