Skip to content

Commit

Permalink
git p4: standardize submit cancel due to unchanged template
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pete Wyckoff authored and Junio C Hamano committed Sep 17, 2012
1 parent 7e5dd9f commit 5a41c16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion git-p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@ def applyCommit(self, id):

if self.edit_template(fileName):
# read the edited message and submit
ret = True
tmpFile = open(fileName, "rb")
message = tmpFile.read()
tmpFile.close()
Expand All @@ -1285,6 +1286,7 @@ def applyCommit(self, id):

else:
# skip this patch
ret = False
print "Submission cancelled, undoing p4 changes."
for f in editedFiles:
p4_revert(f)
Expand All @@ -1293,7 +1295,7 @@ def applyCommit(self, id):
os.remove(f)

os.remove(fileName)
return True # success
return ret

# Export git tags as p4 labels. Create a p4 label and then tag
# with that.
Expand Down
2 changes: 1 addition & 1 deletion t/t9805-git-p4-skip-submit-edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test_expect_success 'no config, unedited, say no' '
cd "$git" &&
echo line >>file1 &&
git commit -a -m "change 3 (not really)" &&
printf "bad response\nn\n" | git p4 submit &&
printf "bad response\nn\n" | test_expect_code 1 git p4 submit &&
p4 changes //depot/... >wc &&
test_line_count = 2 wc
)
Expand Down

0 comments on commit 5a41c16

Please sign in to comment.