git p4: submit conflict handling
v2 cover git p4: submit conflict handling
Changes from v1, due to review from Luke and Hannes:
* Drop the patch to suppress of p4d log messages, it is sometimes useful to watch.
* Fix extra line before shebang in t9815. (Thanks Hannes.)
* Use "skip", not "continue" in the prompt about what to do next, just like before this series.
* Automate the interactive prompt when a submit conflict is detected, with "git p4 submit --conflict=skip" or config variable git-p4.conflict.
This does not try to fix the rebase path. It adds the auto-skip during the submit phase, but changes are needed in rebase to understand that skips happened. One approach is to skip the rebase, and just reset HEAD.
Luke: You have a patch for git-p4.skipConflictingChanges that I think might work with --conflict=skip or git-p4.skip. With this series, logging already happens in submit, so you might just quietly say "git rebase --skip". Let me know if you think this is a good approach, so that this series can go in, and you can handle the rebase part.
Version 1 of this series:
http://thread.gmane.org/gmane.comp.version-control.git/203570
Blurb (edited) from v1 follows.
These patches rework how git p4 deals with conflicts that arise during a "git p4 submit". These may arise due to changes that happened in p4 since the last "git p4 sync".
The part that needs the most attention is the interaction loop that happens when a commit failed. Currently, three options are offered:
[s]kip this commit, but continue to apply others [a]pply the commit forcefully, generating .rej files [w]rite the commit to a patch.txt file
and the implicit <ctrl-c> to stop
After this series, it offers two:
[s]kip this commit but apply the rest
[q]uit to stop
Other observable changes are new command-line options:
Alias -v for --verbose, similar to other git commands.
The --dry-run option addresses Luke's concern in
http://thread.gmane.org/gmane.comp.version-control.git/201004/focus=201022
when I removed an unused "self.interactive" variable that did a similar thing if you edited the code. It prints commits that would be applied to p4.
Option --prepare-p4-only is similar to --dry-run, in that it does not submit anything to p4, but it does prepare the p4 workspace, then prints long instructions about how to submit everything properly. It also serves, perhaps, as a replacement for the [a]pply option in the submit-conflict loop.
Option --conflict=skip (new in v2) automates the prompt handling when conflicts happen.
Pete Wyckoff (12):
git p4 test: remove bash-ism of combined export/assignment git p4: gracefully fail if some commits could not be applied git p4: remove submit failure options [a]pply and [w]rite git p4: move conflict prompt into run, add [q]uit input git p4: standardize submit cancel due to unchanged template git p4: test clean-up after failed submit, fix added files git p4: rearrange submit template construction
git p4: revert deleted files after submit cancel git p4: accept -v for --verbose
git p4: add submit --dry-run option
git p4: add submit --prepare-p4-only option
git-p4: add submit --conflict option and config varaiable
Documentation/git-p4.txt | 24 ++- git-p4.py | 239 ++++++++++++++++----- t/lib-git-p4.sh | 7 +- t/t9805-git-p4-skip-submit-edit.sh | 2 +- t/t9807-git-p4-submit.sh | 65 ++++++ t/t9810-git-p4-rcs.sh | 50 +---- t/t9815-git-p4-submit-fail.sh | 429 +++++++++++++++++++++++++++++++++++++ 7 files changed, 709 insertions(+), 107 deletions(-) create mode 100755 t/t9815-git-p4-submit-fail.sh
Signature · 1 line
1.7.12.rc2.111.g96f7c73
PATCH v2 1/12 git p4 test: remove bash-ism of combined export/assignment
--- t/lib-git-p4.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
t/lib-git-p4.sh +4 -3
@@ -26,9 +26,10 @@ testid=${this_test#t} git_p4_test_start=9800 P4DPORT=$((10669 + ($testid - $git_p4_test_start))) -export P4PORT=localhost:$P4DPORT -export P4CLIENT=client -export P4EDITOR=: +P4PORT=localhost:$P4DPORT +P4CLIENT=client +P4EDITOR=: +export P4PORT P4CLIENT P4EDITOR db="$TRASH_DIRECTORY/db" cli=$(test-path-utils real_path "$TRASH_DIRECTORY/cli")
Signature · 1 line
1.7.12.rc2.111.g96f7c73
Re: [PATCHv2 01/12] git p4 test: remove bash-ism of combined export/assignment
Looks good to me, ack.
Quoted 23 lines · Pete Wyckoff
Signed-off-by Pete Wyckoff<[email protected]>--- t/lib-git-p4.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)t/lib-git-p4.sh +4
-3@@ -26,9 +26,10 @@ testid=${this_test#t} git_p4_test_start=9800 P4DPORT=$((10669 + ($testid - $git_p4_test_start))) -export P4PORT=localhost:$P4DPORT -export P4CLIENT=client -export P4EDITOR=: +P4PORT=localhost:$P4DPORT +P4CLIENT=client +P4EDITOR=: +export P4PORT P4CLIENT P4EDITOR db="$TRASH_DIRECTORY/db" cli=$(test-path-utils real_path "$TRASH_DIRECTORY/cli")
Re: [PATCHv2 01/12] git p4 test: remove bash-ism of combined export/assignment
Quoted 1 line · Luke Diamand
Looks good to me, ack.
Thanks; is this an ack for the entire series, or are you expecting further back-and-forth with Pete before the whole thing is ready?
Re: [PATCHv2 01/12] git p4 test: remove bash-ism of combined export/assignment
Quoted 6 lines · Junio C Hamano
Quoted 1 line · Luke Diamand
Looks good to me, ack.
Thanks; is this an ack for the entire series, or are you expecting further back-and-forth with Pete before the whole thing is ready?
An ack for the whole series. I'm just going through the rest of the patches now but I don't expect to find any issues.
Re: [PATCHv2 01/12] git p4 test: remove bash-ism of combined export/assignment
Quoted 10 lines · Luke Diamand
Quoted 6 lines · Junio C Hamano
Quoted 1 line · Luke Diamand
Looks good to me, ack.
Thanks; is this an ack for the entire series, or are you expecting further back-and-forth with Pete before the whole thing is ready?
An ack for the whole series. I'm just going through the rest of the patches now but I don't expect to find any issues.
As long as the parties involved in the part of the system can agree that "this series is basically sound", I'd be happy to merge it down. Minor issues can be fixed up as follow-up patches.
Thanks. Will merge it to 'next'.
Re: [PATCHv2 01/12] git p4 test: remove bash-ism of combined export/assignment
Quoted 10 lines · Junio C Hamano
Quoted 8 lines · Luke Diamand
Quoted 6 lines · Junio C Hamano
Quoted 1 line · Luke Diamand
Looks good to me, ack.
Thanks; is this an ack for the entire series, or are you expecting further back-and-forth with Pete before the whole thing is ready?
Quoted 6 lines
Quoted 2 lines
An ack for the whole series. I'm just going through the rest of the patches now but I don't expect to find any issues.
As long as the parties involved in the part of the system can agree that "this series is basically sound", I'd be happy to merge it down. Minor issues can be fixed up as follow-up patches.
Basically sound as far as I'm concerned.
Quoted 3 lines
Thanks. Will merge it to 'next'.
PATCH v2 2/12 git p4: gracefully fail if some commits could not be applied
In reply to Pete WyckoffIf a commit fails to apply cleanly to the p4 tree, an interactive prompt asks what to do next. In all cases (skip, apply, write), the behavior after the prompt had a few problems.
Change it so that it does not claim erroneously that all commits were applied. Instead list the set of the patches under consideration, and mark with an asterisk those that were applied successfully. Like this example:
Applying 592f1f9 line5 in file1 will conflict
...
Unfortunately applying the change failed!
What do you want to do?
[s]kip this patch / [a]pply the patch forcibly and with .rej files / [w]rite the patch to a file (patch.txt) s Skipping! Good luck with the next patches...
//depot/file1#4 - was edit, reverted
Applying b8db1c6 okay_commit_after_skip
...
Change 6 submitted.
Applied only the commits marked with '*':
592f1f9 line5 in file1 will conflict
* b8db1c6 okay_commit_after_skip
Do not try to sync and rebase unless all patches were applied. If there was a conflict during the submit, there is sure to be one at the rebase. Let the user to do the sync and rebase manually.
This changes how a couple tets in t9810-git-p4-rcs.sh behave:
- git p4 now does not leave files open and edited in the client
- If a git commit contains a change to a file that was deleted in p4, the test used to check that the sync/rebase loop happened after the failure to apply the change. Since now sync/rebase does not happen after failure, do not test this. Normal rebase machinery, outside of git p4, will let rebase --skip work.
--- git-p4.py | 42 +++++++++++++++----- t/t9810-git-p4-rcs.sh | 50 ++--------------------- t/t9815-git-p4-submit-fail.sh | 92 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 56 deletions(-) create mode 100755 t/t9815-git-p4-submit-fail.sh
git-p4.py +33 -9
@@ -1088,7 +1088,10 @@ class P4Submit(Command, P4UserMap): return False def applyCommit(self, id): - print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id)) + """Apply one commit, return True if it succeeded.""" + + print "Applying", read_pipe(["git", "show", "-s", + "--format=format:%h %s", id]) (p4User, gitEmail) = self.p4UserForCommit(id)
@@ -1206,7 +1209,7 @@ class P4Submit(Command, P4UserMap): p4_revert(f) for f in filesToAdd: os.remove(f) - return + return False elif response == "a": os.system(applyPatchCmd) if len(filesToAdd) > 0:
@@ -1312,6 +1315,7 @@ class P4Submit(Command, P4UserMap): os.remove(f) os.remove(fileName) + return True # success # Export git tags as p4 labels. Create a p4 label and then tag # with that.
@@ -1487,14 +1491,16 @@ class P4Submit(Command, P4UserMap): if gitConfig("git-p4.detectCopiesHarder", "--bool") == "true": self.diffOpts += " --find-copies-harder" - while len(commits) > 0: - commit = commits[0] - commits = commits[1:] - self.applyCommit(commit) + applied = [] + for commit in commits: + ok = self.applyCommit(commit) + if ok: + applied.append(commit) - if len(commits) == 0: - print "All changes applied!" - chdir(self.oldWorkingDirectory) + chdir(self.oldWorkingDirectory) + + if len(commits) == len(applied): + print "All commits applied!" sync = P4Sync() sync.run([])
@@ -1502,6 +1508,20 @@ class P4Submit(Command, P4UserMap): rebase = P4Rebase() rebase.rebase() + else: + if len(applied) == 0: + print "No commits applied." + else: + print "Applied only the commits marked with '*':" + for c in commits: + if c in applied: + star = "*" + else: + star = " " + print star, read_pipe(["git", "show", "-s", + "--format=format:%h %s", c]) + print "You will have to do 'git p4 sync' and rebase." + if gitConfig("git-p4.exportLabels", "--bool") == "true": self.exportLabels = True
@@ -1512,6 +1532,10 @@ class P4Submit(Command, P4UserMap): missingGitTags = gitTags - p4Labels self.exportGitTags(missingGitTags) + # exit with error unless everything applied perfecly + if len(commits) != len(applied): + sys.exit(1) + return True class View(object):
t/t9810-git-p4-rcs.sh +3 -47
70 lines not on this page · raw message
t/t9815-git-p4-submit-fail.sh new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
1.7.12.rc2.111.g96f7c73
Re: [PATCHv2 02/12] git p4: gracefully fail if some commits could not be applied
I've only played around with this a bit, but it looks to be doing the right thing.
In practice, I think the normal workflow tends to be 'rebase, submit' and so this code path will only be taken in the case where a conflicting change is submitted to p4 in the window between rebasing and submitting (or you forget to rebase).
As your cover letter says though, I need to do something about rebasing.
Ack.
Quoted 311 lines · Pete Wyckoff
If a commit fails to apply cleanly to the p4 tree, an interactive prompt asks what to do next. In all cases (skip, apply, write), the behavior after the prompt had a few problems.
Change it so that it does not claim erroneously that all commits were applied. Instead list the set of the patches under consideration, and mark with an asterisk those that were applied successfully. Like this example:
Applying 592f1f9 line5 in file1 will conflict
...
Unfortunately applying the change failed!
What do you want to do?
[s]kip this patch / [a]pply the patch forcibly and with .rej files / [w]rite the patch to a file (patch.txt) s Skipping! Good luck with the next patches...
//depot/file1#4 - was edit, reverted
Applying b8db1c6okay_commit_after_skip
...
Change 6 submitted.
Applied only the commits marked with '*':
592f1f9 line5 in file1 will conflict
* b8db1c6okay_commit_after_skipDo not try to sync and rebase unless all patches were applied. If there was a conflict during the submit, there is sure to be one at the rebase. Let the user to do the sync and rebase manually.
This changes how a couple tets in
t9810-git-p4-rcs.shbehave:- git p4 now does not leave files open and edited in the client
- If a git commit contains a change to a file that was deleted in p4, the test used to check that the sync/rebase loop happened after the failure to apply the change. Since now sync/rebase does not happen after failure, do not test this. Normal rebase machinery, outside of git p4, will let rebase --skip work.
Signed-off-by Pete Wyckoff<[email protected]>--- git-p4.py | 42 +++++++++++++++----- t/t9810-git-p4-rcs.sh | 50 ++--------------------- t/t9815-git-p4-submit-fail.sh | 92 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 56 deletions(-)create mode 100755
t/t9815-git-p4-submit-fail.shgit-p4.py +33
-9@@ -1088,7 +1088,10 @@ class P4Submit(Command, P4UserMap): return False def applyCommit(self, id): - print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id)) + """Apply one commit, return True if it succeeded.""" + + print "Applying", read_pipe(["git", "show", "-s", + "--format=format:%h %s", id]) (p4User, gitEmail) = self.p4UserForCommit(id)@@ -1206,7 +1209,7 @@ class P4Submit(Command, P4UserMap): p4_revert(f) for f in filesToAdd: os.remove(f) - return + return False elif response == "a": os.system(applyPatchCmd) if len(filesToAdd)> 0:@@ -1312,6 +1315,7 @@ class P4Submit(Command, P4UserMap): os.remove(f) os.remove(fileName) + return True # success # Export git tags as p4 labels. Create a p4 label and then tag # with that.@@ -1487,14 +1491,16 @@ class P4Submit(Command, P4UserMap): if gitConfig("git-p4.detectCopiesHarder", "--bool") == "true": self.diffOpts += " --find-copies-harder" - while len(commits)> 0: - commit = commits[0] - commits = commits[1:] - self.applyCommit(commit) + applied = [] + for commit in commits: + ok = self.applyCommit(commit) + if ok: + applied.append(commit) - if len(commits) == 0: - print "All changes applied!" - chdir(self.oldWorkingDirectory) + chdir(self.oldWorkingDirectory) + + if len(commits) == len(applied): + print "All commits applied!" sync = P4Sync() sync.run([])@@ -1502,6 +1508,20 @@ class P4Submit(Command, P4UserMap): rebase = P4Rebase() rebase.rebase() + else: + if len(applied) == 0: + print "No commits applied." + else: + print "Applied only the commits marked with '*':" + for c in commits: + if c in applied: + star = "*" + else: + star = " " + print star, read_pipe(["git", "show", "-s", + "--format=format:%h %s", c]) + print "You will have to do 'git p4 sync' and rebase." + if gitConfig("git-p4.exportLabels", "--bool") == "true": self.exportLabels = True@@ -1512,6 +1532,10 @@ class P4Submit(Command, P4UserMap): missingGitTags = gitTags - p4Labels self.exportGitTags(missingGitTags) + # exit with error unless everything applied perfecly + if len(commits) != len(applied): + sys.exit(1) + return True class View(object):t/t9810-git-p4-rcs.sh +3
-47@@ -160,9 +160,6 @@ test_expect_success 'cleanup after failure' ' # the cli file so that submit will get a conflict. Make sure that # scrubbing doesn't make a mess of things. # -# Assumes that git-p4 exits leaving the p4 file open, with the -# conflict-generating patch unapplied. -# # This might happen only if the git repo is behind the p4 repo at # submit time, and there is a conflict. #@@ -181,14 +178,11 @@ test_expect_success 'do not scrub plain text' ' sed -i "s/^line5/line5 p4 edit/" file_text&& p4 submit -d "file5 p4 edit" )&& - ! git p4 submit&& + echo s | test_expect_code 1 git p4 submit&& ( - # exepct something like: - # file_text - file(s) not opened on this client - # but not copious diff output + # make sure the file is not left open cd "$cli"&& - p4 diff file_text>wc&& - test_line_count = 1 wc + ! p4 fstat -T action file_text ) ) '@@ -343,44 +337,6 @@ test_expect_failure 'Add keywords in git which do not match the default p4 value ) ' -# Check that the existing merge conflict handling still works. -# Modify kwfile1.c in git, and delete in p4. We should be able -# to skip the git commit. -# -test_expect_success 'merge conflict handling still works' ' - test_when_finished cleanup_git&& - ( - cd "$cli"&& - echo "Hello:\$Id\$">merge2.c&& - echo "World">>merge2.c&& - p4 add -t ktext merge2.c&& - p4 submit -d "add merge test file" - )&& - git p4 clone --dest="$git" //depot&& - ( - cd "$git"&& - sed -e "/Hello/d" merge2.c>merge2.c.tmp&& - mv merge2.c.tmp merge2.c&& - git add merge2.c&& - git commit -m "Modifying merge2.c" - )&& - ( - cd "$cli"&& - p4 delete merge2.c&& - p4 submit -d "remove merge test file" - )&& - ( - cd "$git"&& - test -f merge2.c&& - git config git-p4.skipSubmitEdit true&& - git config git-p4.attemptRCSCleanup true&& - !(echo "s" | git p4 submit)&& - git rebase --skip&& - ! test -f merge2.c - ) -' - - test_expect_success 'kill p4d' ' kill_p4d 't/t9815-git-p4-submit-fail.sh new file +92
-0@@ -0,0 +1,92 @@ +#!/bin/sh + +test_description='git p4 submit failure handling' + +. ./lib-git-p4.sh + +test_expect_success 'start p4d' ' + start_p4d +' + +test_expect_success 'init depot' ' + ( + cd "$cli"&& + p4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i&& + echo line1>file1&& + p4 add file1&& + p4 submit -d "line1 in file1" + ) +' + +test_expect_success 'conflict on one commit, skip' ' + test_when_finished cleanup_git&& + git p4 clone --dest="$git" //depot&& + ( + cd "$cli"&& + p4 open file1&& + echo line2>>file1&& + p4 submit -d "line2 in file1" + )&& + ( + # now this commit should cause a conflict + cd "$git"&& + git config git-p4.skipSubmitEdit true&& + echo line3>>file1&& + git add file1&& + git commit -m "line3 in file1 will conflict"&& + echo s | test_expect_code 1 git p4 submit>out&& + test_i18ngrep "No commits applied" out + ) +' + +test_expect_success 'conflict on second of two commits, skip' ' + test_when_finished cleanup_git&& + git p4 clone --dest="$git" //depot&& + ( + cd "$cli"&& + p4 open file1&& + echo line3>>file1&& + p4 submit -d "line3 in file1" + )&& + ( + cd "$git"&& + git config git-p4.skipSubmitEdit true&& + # this commit is okay + test_commit "first_commit_okay"&& + # now this submit should cause a conflict + echo line4>>file1&& + git add file1&& + git commit -m "line4 in file1 will conflict"&& + echo s | test_expect_code 1 git p4 submit>out&& + test_i18ngrep "Applied only the commits" out + ) +' + +test_expect_success 'conflict on first of two commits, skip' ' + test_when_finished cleanup_git&& + git p4 clone --dest="$git" //depot&& + ( + cd "$cli"&& + p4 open file1&& + echo line4>>file1&& + p4 submit -d "line4 in file1" + )&& + ( + cd "$git"&& + git config git-p4.skipSubmitEdit true&& + # this submit should cause a conflict + echo line5>>file1&& + git add file1&& + git commit -m "line5 in file1 will conflict"&& + # but this commit is okay + test_commit "okay_commit_after_skip"&& + echo s | test_expect_code 1 git p4 submit>out&& + test_i18ngrep "Applied only the commits" out + ) +' + +test_expect_success 'kill p4d' ' + kill_p4d +' + +test_done
PATCH v2 3/12 git p4: remove submit failure options [a]pply and [w]rite
In reply to Pete WyckoffWhen a patch failed to apply, these interactive options offered to:
1) apply the patch anyway, leaving reject (.rej) files around, or,
2) write the patch to a file (patch.txt)
In both cases it suggested to invoke "git p4 submit --continue", an unimplemented option.
While manually fixing the rejects and submitting the result might work, there are many steps that must be done to the job properly:
* apply patch
* invoke p4 add and delete
* change executable bits
* p4 sync -f renamed/copied files
* extract commit message into p4 change description and move Jobs lines out of description section
* set changelist owner for --preserve-user
Plus the following manual sync/rebase will cause conflicts too, which must be resolved once again.
Drop these workflows. Instead users should do a sync/rebase in git, fix the conflicts there, and do a clean "git p4 submit".
--- git-p4.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
git-p4.py +2 -18
@@ -1200,9 +1200,8 @@ class P4Submit(Command, P4UserMap): if not patch_succeeded: print "What do you want to do?" response = "x" - while response != "s" and response != "a" and response != "w": - response = raw_input("[s]kip this patch / [a]pply the patch forcibly " - "and with .rej files / [w]rite the patch to a file (patch.txt) ") + while response != "s": + response = raw_input("[s]kip this patch ") if response == "s": print "Skipping! Good luck with the next patches..." for f in editedFiles:
@@ -1210,21 +1209,6 @@ class P4Submit(Command, P4UserMap): for f in filesToAdd: os.remove(f) return False - elif response == "a": - os.system(applyPatchCmd) - if len(filesToAdd) > 0: - print "You may also want to call p4 add on the following files:" - print " ".join(filesToAdd) - if len(filesToDelete): - print "The following files should be scheduled for deletion with p4 delete:" - print " ".join(filesToDelete) - die("Please resolve and submit the conflict manually and " - + "continue afterwards with git p4 submit --continue") - elif response == "w": - system(diffcmd + " > patch.txt") - print "Patch saved to patch.txt in %s !" % self.clientPath - die("Please resolve and submit the conflict manually and " - "continue afterwards with git p4 submit --continue") system(applyPatchCmd)
Signature · 1 line
1.7.12.rc2.111.g96f7c73
Re: [PATCHv2 03/12] git p4: remove submit failure options [a]pply and [w]rite
git-p4 won't be quite the same without these completely misleading and confusing messages :-)
Ack.
Quoted 69 lines · Pete Wyckoff
When a patch failed to apply, these interactive options offered to:
1) apply the patch anyway, leaving reject (.rej) files around, or,
2) write the patch to a file (patch.txt)In both cases it suggested to invoke "git p4 submit --continue", an unimplemented option.
While manually fixing the rejects and submitting the result might work, there are many steps that must be done to the job properly:
* apply patch
* invoke p4 add and delete
* change executable bits
* p4 sync -f renamed/copied files
* extract commit message into p4 change description and move Jobs lines out of description section
* set changelist owner for --preserve-userPlus the following manual sync/rebase will cause conflicts too, which must be resolved once again.
Drop these workflows. Instead users should do a sync/rebase in git, fix the conflicts there, and do a clean "git p4 submit".
Signed-off-by Pete Wyckoff<[email protected]>--- git-p4.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)git-p4.py +2
-18@@ -1200,9 +1200,8 @@ class P4Submit(Command, P4UserMap): if not patch_succeeded: print "What do you want to do?" response = "x" - while response != "s" and response != "a" and response != "w": - response = raw_input("[s]kip this patch / [a]pply the patch forcibly " - "and with .rej files / [w]rite the patch to a file (patch.txt) ") + while response != "s": + response = raw_input("[s]kip this patch ") if response == "s": print "Skipping! Good luck with the next patches..." for f in editedFiles:@@ -1210,21 +1209,6 @@ class P4Submit(Command, P4UserMap): for f in filesToAdd: os.remove(f) return False - elif response == "a": - os.system(applyPatchCmd) - if len(filesToAdd)> 0: - print "You may also want to call p4 add on the following files:" - print " ".join(filesToAdd) - if len(filesToDelete): - print "The following files should be scheduled for deletion with p4 delete:" - print " ".join(filesToDelete) - die("Please resolve and submit the conflict manually and " - + "continue afterwards with git p4 submit --continue") - elif response == "w": - system(diffcmd + "> patch.txt") - print "Patch saved to patch.txt in %s !" % self.clientPath - die("Please resolve and submit the conflict manually and " - "continue afterwards with git p4 submit --continue") system(applyPatchCmd)
PATCH v2 4/12 git p4: move conflict prompt into run, add [q]uit input
In reply to Pete WyckoffWhen applying a commit to the p4 workspace fails, a prompt asks what to do next. This belongs up in run() instead of in applyCommit(), where run() can notice, for instance, that the prompt is unnecessary because this is the last commit.
Offer two options about how to continue at conflict: [s]kip or [q]uit. Having an explicit "quit" option gives git p4 a chance to clean up, show the applied-commit summary, and do tag export.
--- git-p4.py | 41 +++++++++++++++++++++++++++++------------ t/t9815-git-p4-submit-fail.sh | 31 +++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 16 deletions(-)
git-p4.py +29 -12
@@ -1198,17 +1198,11 @@ class P4Submit(Command, P4UserMap): patch_succeeded = True if not patch_succeeded: - print "What do you want to do?" - response = "x" - while response != "s": - response = raw_input("[s]kip this patch ") - if response == "s": - print "Skipping! Good luck with the next patches..." - for f in editedFiles: - p4_revert(f) - for f in filesToAdd: - os.remove(f) - return False + for f in editedFiles: + p4_revert(f) + for f in filesToAdd: + os.remove(f) + return False system(applyPatchCmd)
@@ -1475,11 +1469,34 @@ class P4Submit(Command, P4UserMap): if gitConfig("git-p4.detectCopiesHarder", "--bool") == "true": self.diffOpts += " --find-copies-harder" + # + # Apply the commits, one at a time. On failure, ask if should + # continue to try the rest of the patches, or quit. + # applied = [] - for commit in commits: + last = len(commits) - 1 + for i, commit in enumerate(commits): ok = self.applyCommit(commit) if ok: applied.append(commit) + else: + if i < last: + quit = False + while True: + print "What do you want to do?" + response = raw_input("[s]kip this commit but apply" + " the rest, or [q]uit? ") + if not response: + continue + if response[0] == "s": + print "Skipping this commit, but applying the rest" + break + if response[0] == "q": + print "Quitting" + quit = True + break + if quit: + break chdir(self.oldWorkingDirectory)
t/t9815-git-p4-submit-fail.sh +27 -4
@@ -18,7 +18,7 @@ test_expect_success 'init depot' ' ) ' -test_expect_success 'conflict on one commit, skip' ' +test_expect_success 'conflict on one commit' ' test_when_finished cleanup_git && git p4 clone --dest="$git" //depot && (
@@ -34,12 +34,12 @@ test_expect_success 'conflict on one commit, skip' ' echo line3 >>file1 && git add file1 && git commit -m "line3 in file1 will conflict" && - echo s | test_expect_code 1 git p4 submit >out && + test_expect_code 1 git p4 submit >out && test_i18ngrep "No commits applied" out ) ' -test_expect_success 'conflict on second of two commits, skip' ' +test_expect_success 'conflict on second of two commits' ' test_when_finished cleanup_git && git p4 clone --dest="$git" //depot && (
@@ -57,7 +57,7 @@ test_expect_success 'conflict on second of two commits, skip' ' echo line4 >>file1 && git add file1 && git commit -m "line4 in file1 will conflict" && - echo s | test_expect_code 1 git p4 submit >out && + test_expect_code 1 git p4 submit >out && test_i18ngrep "Applied only the commits" out ) '
@@ -85,6 +85,29 @@ test_expect_success 'conflict on first of two commits, skip' ' ) ' +test_expect_success 'conflict on first of two commits, quit' ' + test_when_finished cleanup_git && + git p4 clone --dest="$git" //depot && + ( + cd "$cli" && + p4 open file1 && + echo line7 >>file1 && + p4 submit -d "line7 in file1" + ) && + ( + cd "$git" && + git config git-p4.skipSubmitEdit true && + # this submit should cause a conflict + echo line8 >>file1 && + git add file1 && + git commit -m "line8 in file1 will conflict" && + # but this commit is okay + test_commit "okay_commit_after_quit" && + echo q | test_expect_code 1 git p4 submit >out && + test_i18ngrep "No commits applied" out + ) +' + test_expect_success 'kill p4d' ' kill_p4d '
Signature · 1 line
1.7.12.rc2.111.g96f7c73
Re: [PATCHv2 04/12] git p4: move conflict prompt into run, add [q]uit input
I'll need to supply a followup patch to ensure that a config option can override the prompt.
Ack.
Quoted 145 lines · Pete Wyckoff
When applying a commit to the p4 workspace fails, a prompt asks what to do next. This belongs up in
run()instead of inapplyCommit(), whererun()can notice, for instance, that the prompt is unnecessary because this is the last commit.Offer two options about how to continue at conflict: [s]kip or [q]uit. Having an explicit "quit" option gives git p4 a chance to clean up, show the applied-commit summary, and do tag export.
Signed-off-by Pete Wyckoff<[email protected]>--- git-p4.py | 41 +++++++++++++++++++++++++++++------------ t/t9815-git-p4-submit-fail.sh | 31 +++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 16 deletions(-)git-p4.py +29
-12@@ -1198,17 +1198,11 @@ class P4Submit(Command, P4UserMap): patch_succeeded = True if not patch_succeeded: - print "What do you want to do?" - response = "x" - while response != "s": - response = raw_input("[s]kip this patch ") - if response == "s": - print "Skipping! Good luck with the next patches..." - for f in editedFiles: - p4_revert(f) - for f in filesToAdd: - os.remove(f) - return False + for f in editedFiles: + p4_revert(f) + for f in filesToAdd: + os.remove(f) + return False system(applyPatchCmd)@@ -1475,11 +1469,34 @@ class P4Submit(Command, P4UserMap): if gitConfig("git-p4.detectCopiesHarder", "--bool") == "true": self.diffOpts += " --find-copies-harder" + # + # Apply the commits, one at a time. On failure, ask if should + # continue to try the rest of the patches, or quit. + # applied = [] - for commit in commits: + last = len(commits) - 1 + for i, commit in enumerate(commits): ok = self.applyCommit(commit) if ok: applied.append(commit) + else: + if i< last: + quit = False + while True: + print "What do you want to do?" + response = raw_input("[s]kip this commit but apply" + " the rest, or [q]uit? ") + if not response: + continue + if response[0] == "s": + print "Skipping this commit, but applying the rest" + break + if response[0] == "q": + print "Quitting" + quit = True + break + if quit: + break chdir(self.oldWorkingDirectory)t/t9815-git-p4-submit-fail.sh +27
-4@@ -18,7 +18,7 @@ test_expect_success 'init depot' ' ) ' -test_expect_success 'conflict on one commit, skip' ' +test_expect_success 'conflict on one commit' ' test_when_finished cleanup_git&& git p4 clone --dest="$git" //depot&& (@@ -34,12 +34,12 @@ test_expect_success 'conflict on one commit, skip' ' echo line3>>file1&& git add file1&& git commit -m "line3 in file1 will conflict"&& - echo s | test_expect_code 1 git p4 submit>out&& + test_expect_code 1 git p4 submit>out&& test_i18ngrep "No commits applied" out ) ' -test_expect_success 'conflict on second of two commits, skip' ' +test_expect_success 'conflict on second of two commits' ' test_when_finished cleanup_git&& git p4 clone --dest="$git" //depot&& (@@ -57,7 +57,7 @@ test_expect_success 'conflict on second of two commits, skip' ' echo line4>>file1&& git add file1&& git commit -m "line4 in file1 will conflict"&& - echo s | test_expect_code 1 git p4 submit>out&& + test_expect_code 1 git p4 submit>out&& test_i18ngrep "Applied only the commits" out ) '@@ -85,6 +85,29 @@ test_expect_success 'conflict on first of two commits, skip' ' ) ' +test_expect_success 'conflict on first of two commits, quit' ' + test_when_finished cleanup_git&& + git p4 clone --dest="$git" //depot&& + ( + cd "$cli"&& + p4 open file1&& + echo line7>>file1&& + p4 submit -d "line7 in file1" + )&& + ( + cd "$git"&& + git config git-p4.skipSubmitEdit true&& + # this submit should cause a conflict + echo line8>>file1&& + git add file1&& + git commit -m "line8 in file1 will conflict"&& + # but this commit is okay + test_commit "okay_commit_after_quit"&& + echo q | test_expect_code 1 git p4 submit>out&& + test_i18ngrep "No commits applied" out + ) +' + test_expect_success 'kill p4d' ' kill_p4d '
PATCH v2 5/12 git p4: standardize submit cancel due to unchanged template
In reply to Pete WyckoffWhen 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.
--- git-p4.py | 4 +++- t/t9805-git-p4-skip-submit-edit.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
git-p4.py +3 -1
@@ -1262,6 +1262,7 @@ class P4Submit(Command, P4UserMap): if self.edit_template(fileName): # read the edited message and submit + ret = True tmpFile = open(fileName, "rb") message = tmpFile.read() tmpFile.close()
@@ -1285,6 +1286,7 @@ class P4Submit(Command, P4UserMap): else: # skip this patch + ret = False print "Submission cancelled, undoing p4 changes." for f in editedFiles: p4_revert(f)
@@ -1293,7 +1295,7 @@ class P4Submit(Command, P4UserMap): 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.
t/t9805-git-p4-skip-submit-edit.sh +1 -1
@@ -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 )
Signature · 1 line
1.7.12.rc2.111.g96f7c73
Re: [PATCHv2 05/12] git p4: standardize submit cancel due to unchanged template
Ack.
Quoted 62 lines · Pete Wyckoff
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<[email protected]>--- git-p4.py | 4 +++- t/t9805-git-p4-skip-submit-edit.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)git-p4.py +3
-1@@ -1262,6 +1262,7 @@ class P4Submit(Command, P4UserMap): if self.edit_template(fileName): # read the edited message and submit + ret = True tmpFile = open(fileName, "rb") message = tmpFile.read() tmpFile.close()@@ -1285,6 +1286,7 @@ class P4Submit(Command, P4UserMap): else: # skip this patch + ret = False print "Submission cancelled, undoing p4 changes." for f in editedFiles: p4_revert(f)@@ -1293,7 +1295,7 @@ class P4Submit(Command, P4UserMap): 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.t/t9805-git-p4-skip-submit-edit.sh +1
-1@@ -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 )
PATCH v2 6/12 git p4: test clean-up after failed submit, fix added files
In reply to Pete WyckoffTest a variety of cases where a patch failed to apply to p4 and had to be cleaned up.
If the patch failed to apply cleanly, do not try to remove to-be-added files, as they have not really been added yet.
--- git-p4.py | 2 - t/t9815-git-p4-submit-fail.sh | 132 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 2 deletions(-)
git-p4.py +0 -2
@@ -1200,8 +1200,6 @@ class P4Submit(Command, P4UserMap): if not patch_succeeded: for f in editedFiles: p4_revert(f) - for f in filesToAdd: - os.remove(f) return False system(applyPatchCmd)
t/t9815-git-p4-submit-fail.sh +132 -0
138 lines not on this page · raw message
Signature · 1 line
1.7.12.rc2.111.g96f7c73
PATCH v2 7/12 git p4: rearrange submit template construction
In reply to Pete WyckoffPut all items in order as they appear, and add comments.
--- git-p4.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
git-p4.py +21 -8
@@ -1202,6 +1202,9 @@ class P4Submit(Command, P4UserMap): p4_revert(f) return False + # + # Apply the patch for real, and do add/delete/+x handling. + # system(applyPatchCmd) for f in filesToAdd:
@@ -1215,6 +1218,10 @@ class P4Submit(Command, P4UserMap): mode = filesToChangeExecBit[f] setP4ExecBit(f, mode) + # + # Build p4 change description, starting with the contents + # of the git commit message. + # logMessage = extractLogMessageFromGitCommit(id) logMessage = logMessage.strip() (logMessage, jobs) = self.separate_jobs_from_description(logMessage)
@@ -1223,8 +1230,16 @@ class P4Submit(Command, P4UserMap): submitTemplate = self.prepareLogMessage(template, logMessage, jobs) if self.preserveUser: - submitTemplate = submitTemplate + ("\n######## Actual user %s, modified after commit\n" % p4User) + submitTemplate += "\n######## Actual user %s, modified after commit\n" % p4User + + if self.checkAuthorship and not self.p4UserIsMe(p4User): + submitTemplate += "######## git author %s does not match your p4 account.\n" % gitEmail + submitTemplate += "######## Use option --preserve-user to modify authorship.\n" + submitTemplate += "######## Variable git-p4.skipUserNameCheck hides this message.\n" + + separatorLine = "######## everything below this line is just the diff #######\n" + # diff if os.environ.has_key("P4DIFF"): del(os.environ["P4DIFF"]) diff = ""
@@ -1232,6 +1247,7 @@ class P4Submit(Command, P4UserMap): diff += p4_read_pipe(['diff', '-du', wildcard_encode(editedFile)]) + # new file diff newdiff = "" for newFile in filesToAdd: newdiff += "==== new file ====\n"
@@ -1242,13 +1258,7 @@ class P4Submit(Command, P4UserMap): newdiff += "+" + line f.close() - if self.checkAuthorship and not self.p4UserIsMe(p4User): - submitTemplate += "######## git author %s does not match your p4 account.\n" % gitEmail - submitTemplate += "######## Use option --preserve-user to modify authorship.\n" - submitTemplate += "######## Variable git-p4.skipUserNameCheck hides this message.\n" - - separatorLine = "######## everything below this line is just the diff #######\n" - + # change description file: submitTemplate, separatorLine, diff, newdiff (handle, fileName) = tempfile.mkstemp() tmpFile = os.fdopen(handle, "w+") if self.isWindows:
@@ -1258,6 +1268,9 @@ class P4Submit(Command, P4UserMap): tmpFile.write(submitTemplate + separatorLine + diff + newdiff) tmpFile.close() + # + # Let the user edit the change description, then submit it. + # if self.edit_template(fileName): # read the edited message and submit ret = True
Signature · 1 line
1.7.12.rc2.111.g96f7c73
PATCH v2 8/12 git p4: revert deleted files after submit cancel
In reply to Pete WyckoffThe user can decide not to continue with a submission, by not saving the p4 submit template, then answering "no" to the "Submit anyway?" prompt. In this case, be sure to return the p4 client to its initial state.
Deleted files were not reverted; fix this and test all cases.
--- git-p4.py | 2 + t/t9815-git-p4-submit-fail.sh | 119 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+)
git-p4.py +2 -0
@@ -1304,6 +1304,8 @@ class P4Submit(Command, P4UserMap): for f in filesToAdd: p4_revert(f) os.remove(f) + for f in filesToDelete: + p4_revert(f) os.remove(fileName) return ret
t/t9815-git-p4-submit-fail.sh +119 -0
125 lines not on this page · raw message
Signature · 1 line
1.7.12.rc2.111.g96f7c73
PATCH v2 9/12 git p4: accept -v for --verbose
In reply to Pete WyckoffThe short form "-v" is common in many git commands as an alias for "--verbose".
--- Documentation/git-p4.txt | 2 +- git-p4.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/git-p4.txt +1 -1
@@ -163,7 +163,7 @@ All commands except clone accept these options. --git-dir <dir>:: Set the 'GIT_DIR' environment variable. See linkgit:git[1]. ---verbose:: +--verbose, -v:: Provide more progress information. Sync options
git-p4.py +1 -1
@@ -3028,7 +3028,7 @@ def main(): args = sys.argv[2:] - options.append(optparse.make_option("--verbose", dest="verbose", action="store_true")) + options.append(optparse.make_option("--verbose", "-v", dest="verbose", action="store_true")) if cmd.needsGit: options.append(optparse.make_option("--git-dir", dest="gitdir"))
Signature · 1 line
1.7.12.rc2.111.g96f7c73
PATCH v2 10/12 git p4: add submit --dry-run option
In reply to Pete WyckoffA new option, "git p4 submit --dry-run" can be used to verify what commits and labels would be moved into p4.
--- Documentation/git-p4.txt | 4 ++++ git-p4.py | 43 ++++++++++++++++++++++++++++++------------- t/t9807-git-p4-submit.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 13 deletions(-)
Documentation/git-p4.txt +4 -0
@@ -269,6 +269,10 @@ These options can be used to modify 'git p4 submit' behavior. Export tags from git as p4 labels. Tags found in git are applied to the perforce working directory. +--dry-run, -n:: + Show just what commits would be submitted to p4; do not change + state in git or p4. + Rebase options ~~~~~~~~~~~~~~ These options can be used to modify 'git p4 rebase' behavior.
git-p4.py +30 -13
85 lines not on this page · raw message
t/t9807-git-p4-submit.sh +41 -0
47 lines not on this page · raw message
Signature · 1 line
1.7.12.rc2.111.g96f7c73
PATCH v2 11/12 git p4: add submit --prepare-p4-only option
In reply to Pete WyckoffThis option can be used to prepare the client workspace for submission, only. It does not invoke the final "p4 submit". A message describes how to proceed, either submitting the changes or reverting.
--- Documentation/git-p4.txt | 7 +++++++ git-p4.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ t/t9807-git-p4-submit.sh | 24 ++++++++++++++++++++++++ 3 files changed, 77 insertions(+)
Documentation/git-p4.txt +7 -0
@@ -273,6 +273,13 @@ These options can be used to modify 'git p4 submit' behavior. Show just what commits would be submitted to p4; do not change state in git or p4. +--prepare-p4-only:: + Apply a commit to the p4 workspace, opening, adding and deleting + files in p4 as for a normal submit operation. Do not issue the + final "p4 submit", but instead print a message about how to + submit manually or revert. This option always stops after the + first (oldest) commit. Git tags are not exported to p4. + Rebase options ~~~~~~~~~~~~~~ These options can be used to modify 'git p4 rebase' behavior.
git-p4.py +46 -0
82 lines not on this page · raw message
t/t9807-git-p4-submit.sh +24 -0
@@ -375,6 +375,30 @@ test_expect_success 'description with Jobs section and bogus following text' ' make_job $(cat jobname) && test_must_fail git p4 submit 2>err && test_i18ngrep "Unknown field name" err + ) && + ( + cd "$cli" && + p4 revert desc6 && + rm desc6 + ) +' + +test_expect_success 'submit --prepare-p4-only' ' + test_when_finished cleanup_git && + git p4 clone --dest="$git" //depot && + ( + cd "$git" && + echo prep-only-add >prep-only-add && + git add prep-only-add && + git commit -m "prep only add" && + git p4 submit --prepare-p4-only >out && + test_i18ngrep "prepared for submission" out && + test_i18ngrep "must be deleted" out + ) && + ( + cd "$cli" && + test_path_is_file prep-only-add && + p4 fstat -T action prep-only-add | grep -w add ) '
Signature · 1 line
1.7.12.rc2.111.g96f7c73
PATCH v2 12/12 git-p4: add submit --conflict option and config varaiable
In reply to Pete WyckoffThis allows specifying what to do when a conflict happens when applying a commit to p4, automating the interactive prompt.
--- Documentation/git-p4.txt | 11 ++++++++ git-p4.py | 36 +++++++++++++++++++++---- t/t9815-git-p4-submit-fail.sh | 63 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 5 deletions(-)
Documentation/git-p4.txt +11 -0
@@ -280,6 +280,13 @@ These options can be used to modify 'git p4 submit' behavior. submit manually or revert. This option always stops after the first (oldest) commit. Git tags are not exported to p4. +--conflict=(ask|skip|quit):: + Conflicts can occur when applying a commit to p4. When this + happens, the default behavior ("ask") is to prompt whether to + skip this commit and continue, or quit. This option can be used + to bypass the prompt, causing conflicting commits to be automatically + skipped, or to quit trying to apply commits, without prompting. + Rebase options ~~~~~~~~~~~~~~ These options can be used to modify 'git p4 rebase' behavior.
@@ -530,6 +537,10 @@ git-p4.labelExportRegexp:: Only p4 labels matching this regular expression will be exported. The default value is '[a-zA-Z0-9_\-.]+$'. +git-p4.conflict:: + Specify submit behavior when a conflict with p4 is found, as per + --conflict. The default behavior is 'ask'. + IMPLEMENTATION DETAILS ---------------------- * Changesets from p4 are imported using git fast-import.
git-p4.py +31 -5
@@ -844,6 +844,9 @@ class P4RollBack(Command): return True class P4Submit(Command, P4UserMap): + + conflict_behavior_choices = ("ask", "skip", "quit") + def __init__(self): Command.__init__(self) P4UserMap.__init__(self)
@@ -855,6 +858,8 @@ class P4Submit(Command, P4UserMap): optparse.make_option("--export-labels", dest="exportLabels", action="store_true"), optparse.make_option("--dry-run", "-n", dest="dry_run", action="store_true"), optparse.make_option("--prepare-p4-only", dest="prepare_p4_only", action="store_true"), + optparse.make_option("--conflict", dest="conflict_behavior", + choices=self.conflict_behavior_choices) ] self.description = "Submit changes from git to the perforce depot." self.usage += " [name of git branch to submit into perforce depot]"
@@ -863,6 +868,7 @@ class P4Submit(Command, P4UserMap): self.preserveUser = gitConfig("git-p4.preserveUser").lower() == "true" self.dry_run = False self.prepare_p4_only = False + self.conflict_behavior = None self.isWindows = (platform.system() == "Windows") self.exportLabels = False self.p4HasMoveCommand = p4_has_command("move")
@@ -1445,6 +1451,16 @@ class P4Submit(Command, P4UserMap): if not self.canChangeChangelists(): die("Cannot preserve user names without p4 super-user or admin permissions") + # if not set from the command line, try the config file + if self.conflict_behavior is None: + val = gitConfig("git-p4.conflict") + if val: + if val not in self.conflict_behavior_choices: + die("Invalid value '%s' for config git-p4.conflict" % val) + else: + val = "ask" + self.conflict_behavior = val + if self.verbose: print "Origin branch is " + self.origin
@@ -1557,11 +1573,21 @@ class P4Submit(Command, P4UserMap): if i < last: quit = False while True: - print "What do you want to do?" - response = raw_input("[s]kip this commit but apply" - " the rest, or [q]uit? ") - if not response: - continue + # prompt for what to do, or use the option/variable + if self.conflict_behavior == "ask": + print "What do you want to do?" + response = raw_input("[s]kip this commit but apply" + " the rest, or [q]uit? ") + if not response: + continue + elif self.conflict_behavior == "skip": + response = "s" + elif self.conflict_behavior == "quit": + response = "q" + else: + die("Unknown conflict_behavior '%s'" % + self.conflict_behavior) + if response[0] == "s": print "Skipping this commit, but applying the rest" break
t/t9815-git-p4-submit-fail.sh +63 -0
69 lines not on this page · raw message
Signature · 1 line
1.7.12.rc2.111.g96f7c73