git p4: standardize submit cancel due to unchanged template
When editing the submit template, if no change was made to it, git p4 offers a prompt "Submit anyway?". Answering "no" cancels the submit. Previously, a "no" answer behaves like a "[s]kip" answer to the failed-patch prompt, in that it proceeded to try to apply the rest of the commits. Instead, put users back into the new "[s]kip / [c]ontinue" loop so that they can decide. This makes both cases of patch failure behave identically. The return code of git p4 after a "no" answer is now the same as that for a "skip" due to failed patch; update a test to understand this. Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pete Wyckoff committed
Sep 9, 2012 at 16:16 UTC
5a41c16a81927bbccbcb00895b168a6d560b8c2c
2 files changed
+4
-2
git-p4.py
+3
-1
@@ -1262,6 +1262,7 @@ class P4Submit(Command, P4UserMap):
1262
1263
if self.edit_template(fileName):
1264
# read the edited message and submit
1265
+ ret = True
1266
tmpFile = open(fileName, "rb")
1267
message = tmpFile.read()
1268
tmpFile.close()
@@ -1285,6 +1286,7 @@ class P4Submit(Command, P4UserMap):
1286
1287
else:
1288
# skip this patch
1289
+ ret = False
1290
print "Submission cancelled, undoing p4 changes."
1291
for f in editedFiles:
1292
p4_revert(f)
@@ -1293,7 +1295,7 @@ class P4Submit(Command, P4UserMap):
1295
os.remove(f)
1296
1297
os.remove(fileName)
1296
- return True # success
1298
+ return ret
1299
1300
# Export git tags as p4 labels. Create a p4 label and then tag
1301
# with that.
t/t9805-git-p4-skip-submit-edit.sh
+1
-1
@@ -38,7 +38,7 @@ test_expect_success 'no config, unedited, say no' '
38
cd "$git" &&
39
echo line >>file1 &&
40
git commit -a -m "change 3 (not really)" &&
41
- printf "bad response\nn\n" | git p4 submit &&
41
+ printf "bad response\nn\n" | test_expect_code 1 git p4 submit &&
42
p4 changes //depot/... >wc &&
43
test_line_count = 2 wc
44
)