git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Cc: Luke Diamand <luke@diamand.org>
Subject: [PATCH 05/12] git p4: move conflict prompt into run, use [c]ontinue and [q]uit
Date: Thu, 16 Aug 2012 19:35:07 -0400	[thread overview]
Message-ID: <1345160114-27654-6-git-send-email-pw@padd.com> (raw)
In-Reply-To: <1345160114-27654-1-git-send-email-pw@padd.com>

When 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.

Remove the [s]kip option in favor of two new ones: [c]ontinue and
[q]uit.  Continue means the same as skip, but is more similar to
the --continue option of rebase.  Option [q]uit stops processing.
This is an improvement on the current requirement of ctrl-c, s an
explicit "quit" gives git p4 a chance to clean up, show the
applied-commit summary, and do tag export.

Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 git-p4.py                     | 41 +++++++++++++++++++++++++++++------------
 t/t9815-git-p4-submit-fail.sh | 37 ++++++++++++++++++++++++++++++-------
 2 files changed, 59 insertions(+), 19 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index e08fea1..1d5194d 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -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(
+                            "[c]ontinue to submit other patches, or [q]uit? ")
+                        if not response:
+                            continue
+                        if response[0] == "c":
+                            print "Continuing to submit the rest of the patches"
+                            break
+                        if response[0] == "q":
+                            print "Quitting"
+                            quit = True
+                            break
+                    if quit:
+                        break
 
         chdir(self.oldWorkingDirectory)
 
diff --git a/t/t9815-git-p4-submit-fail.sh b/t/t9815-git-p4-submit-fail.sh
index 8a02c3b..f6204eb 100755
--- a/t/t9815-git-p4-submit-fail.sh
+++ b/t/t9815-git-p4-submit-fail.sh
@@ -19,7 +19,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 &&
 	(
@@ -35,12 +35,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 &&
 	(
@@ -58,12 +58,12 @@ 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
 	)
 '
 
-test_expect_success 'conflict on first of two commits, skip' '
+test_expect_success 'conflict on first of two commits, continue' '
 	test_when_finished cleanup_git &&
 	git p4 clone --dest="$git" //depot &&
 	(
@@ -80,12 +80,35 @@ test_expect_success 'conflict on first of two commits, skip' '
 		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_commit "okay_commit_after_continue" &&
+		echo c | test_expect_code 1 git p4 submit >out &&
 		test_i18ngrep "Applied only the commits" out
 	)
 '
 
+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
 '
-- 
1.7.11.4

  parent reply	other threads:[~2012-08-16 23:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-16 23:35 [PATCH 00/12] git p4: submit conflict handling Pete Wyckoff
2012-08-16 23:35 ` [PATCH 01/12] git p4 test: remove bash-ism of combined export/assignment Pete Wyckoff
2012-08-17  3:08   ` Junio C Hamano
2012-08-16 23:35 ` [PATCH 02/12] git p4 test: use p4d -L option to suppress log messages Pete Wyckoff
2012-08-17  6:07   ` Luke Diamand
2012-08-16 23:35 ` [PATCH 03/12] git p4: gracefully fail if some commits could not be applied Pete Wyckoff
2012-08-17  6:53   ` Johannes Sixt
2012-08-17 11:49     ` Pete Wyckoff
2012-08-17  7:21   ` Luke Diamand
2012-08-17 11:58     ` Pete Wyckoff
2012-08-16 23:35 ` [PATCH 04/12] git p4: remove submit failure options [a]pply and [w]rite Pete Wyckoff
2012-08-16 23:35 ` Pete Wyckoff [this message]
2012-08-16 23:35 ` [PATCH 06/12] git p4: standardize submit cancel due to unchanged template Pete Wyckoff
2012-08-16 23:35 ` [PATCH 07/12] git p4: test clean-up after failed submit, fix added files Pete Wyckoff
2012-08-16 23:35 ` [PATCH 08/12] git p4: rearrange submit template construction Pete Wyckoff
2012-08-16 23:35 ` [PATCH 09/12] git p4: revert deleted files after submit cancel Pete Wyckoff
2012-08-16 23:35 ` [PATCH 10/12] git p4: accept -v for --verbose Pete Wyckoff
2012-08-16 23:35 ` [PATCH 11/12] git p4: add submit --dry-run option Pete Wyckoff
2012-08-16 23:35 ` [PATCH 12/12] git p4: add submit --prepare-p4-only option Pete Wyckoff
2012-08-17  6:04 ` [PATCH 00/12] git p4: submit conflict handling Luke Diamand
2012-08-17 12:21   ` Pete Wyckoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345160114-27654-6-git-send-email-pw@padd.com \
    --to=pw@padd.com \
    --cc=git@vger.kernel.org \
    --cc=luke@diamand.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).