Don't show the submit template and the diff first in less but show it in $editor right away
Signed-off-by: Simon Hausmann <simon@lst.de>
Simon Hausmann committed
Mar 21, 2007 at 21:04 UTC
53150250b13e7621c8ade1d59d19c946b745dd39
1 file changed
+8
-6
contrib/fast-import/git-p4.py
+8
-6
@@ -235,24 +235,26 @@ class P4Sync(Command):
235
diff += "+" + line
236
f.close()
237
238
- pipe = os.popen("less", "w")
239
- pipe.write(submitTemplate + diff)
240
- pipe.close()
238
+ separatorLine = "######## everything below this line is just the diff #######\n"
239
240
response = "e"
241
+ firstIteration = True
242
while response == "e":
244
- response = raw_input("Do you want to submit this change (y/e/n)? ")
243
+ if not firstIteration:
244
+ response = raw_input("Do you want to submit this change (y/e/n)? ")
245
+ firstIteration = False
246
if response == "e":
247
[handle, fileName] = tempfile.mkstemp()
248
tmpFile = os.fdopen(handle, "w+")
248
- tmpFile.write(submitTemplate)
249
+ tmpFile.write(submitTemplate + separatorLine + diff)
250
tmpFile.close()
251
editor = os.environ.get("EDITOR", "vi")
252
system(editor + " " + fileName)
253
tmpFile = open(fileName, "r")
253
- submitTemplate = tmpFile.read()
254
+ message = tmpFile.read()
255
tmpFile.close()
256
os.remove(fileName)
257
+ submitTemplate = message[:message.index(separatorLine)]
258
259
if response == "y" or response == "yes":
260
if self.dryRun: