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 09/12] git p4: revert deleted files after submit cancel
Date: Thu, 16 Aug 2012 19:35:11 -0400	[thread overview]
Message-ID: <1345160114-27654-10-git-send-email-pw@padd.com> (raw)
In-Reply-To: <1345160114-27654-1-git-send-email-pw@padd.com>

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

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

diff --git a/git-p4.py b/git-p4.py
index 0e874cb..02b4e44 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -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
diff --git a/t/t9815-git-p4-submit-fail.sh b/t/t9815-git-p4-submit-fail.sh
index 876b90f..d2e7e54 100755
--- a/t/t9815-git-p4-submit-fail.sh
+++ b/t/t9815-git-p4-submit-fail.sh
@@ -241,6 +241,125 @@ test_expect_success 'cleanup rename after submit fail' '
 	)
 '
 
+#
+# Cleanup after deciding not to submit during editTemplate.  This
+# involves unwinding more work, because files have been added, deleted
+# and chmod-ed now.  Same approach as above.
+#
+
+test_expect_success 'cleanup edit after submit cancel' '
+	test_when_finished cleanup_git &&
+	git p4 clone --dest="$git" //depot &&
+	(
+		cd "$git" &&
+		echo line >>text &&
+		git add text &&
+		git commit -m text &&
+		echo n | test_expect_code 1 git p4 submit &&
+		git reset --hard HEAD^
+	) &&
+	(
+		cd "$cli" &&
+		! p4 fstat -T action text &&
+		test_cmp "$git"/text text
+	)
+'
+
+test_expect_success 'cleanup add after submit cancel' '
+	test_when_finished cleanup_git &&
+	git p4 clone --dest="$git" //depot &&
+	(
+		cd "$git" &&
+		echo line >textnew &&
+		git add textnew &&
+		git commit -m textnew &&
+		echo n | test_expect_code 1 git p4 submit
+	) &&
+	(
+		cd "$cli" &&
+		test_path_is_missing textnew &&
+		p4 fstat -T action textnew 2>&1 | grep "no such file"
+	)
+'
+
+test_expect_success 'cleanup delete after submit cancel' '
+	test_when_finished cleanup_git &&
+	git p4 clone --dest="$git" //depot &&
+	(
+		cd "$git" &&
+		git rm text &&
+		git commit -m "rm text" &&
+		echo n | test_expect_code 1 git p4 submit
+	) &&
+	(
+		cd "$cli" &&
+		test_path_is_file text &&
+		! p4 fstat -T action text
+	)
+'
+
+test_expect_success 'cleanup copy after submit cancel' '
+	test_when_finished cleanup_git &&
+	git p4 clone --dest="$git" //depot &&
+	(
+		cd "$git" &&
+		cp text text2 &&
+		git add text2 &&
+		git commit -m text2 &&
+		git config git-p4.detectCopies true &&
+		git config git-p4.detectCopiesHarder true &&
+		git diff-tree -r -C --find-copies-harder HEAD | grep text2 | grep C100 &&
+		echo n | test_expect_code 1 git p4 submit
+	) &&
+	(
+		cd "$cli" &&
+		test_path_is_missing text2 &&
+		p4 fstat -T action text2 2>&1 | grep "no such file"
+	)
+'
+
+test_expect_success 'cleanup rename after submit cancel' '
+	test_when_finished cleanup_git &&
+	git p4 clone --dest="$git" //depot &&
+	(
+		cd "$git" &&
+		git mv text text2 &&
+		git commit -m text2 &&
+		git config git-p4.detectRenames true &&
+		git diff-tree -r -M HEAD | grep text2 | grep R100 &&
+		echo n | test_expect_code 1 git p4 submit
+	) &&
+	(
+		cd "$cli" &&
+		test_path_is_missing text2 &&
+		p4 fstat -T action text2 2>&1 | grep "no such file"
+		test_path_is_file text &&
+		! p4 fstat -T action text
+	)
+'
+
+test_expect_success 'cleanup chmod after submit cancel' '
+	test_when_finished cleanup_git &&
+	git p4 clone --dest="$git" //depot &&
+	(
+		cd "$git" &&
+		chmod u+x text &&
+		chmod u-x text+x &&
+		git add text text+x &&
+		git commit -m "chmod texts" &&
+		echo n | test_expect_code 1 git p4 submit
+	) &&
+	(
+		cd "$cli" &&
+		test_path_is_file text &&
+		! p4 fstat -T action text &&
+		stat --format=%A text | egrep ^-r-- &&
+		test_path_is_file text+x &&
+		! p4 fstat -T action text+x &&
+		stat --format=%A text+x | egrep ^-r-x
+	)
+'
+
 test_expect_success 'kill p4d' '
 	kill_p4d
 '
-- 
1.7.11.4

  parent reply	other threads:[~2012-08-16 23:38 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 ` [PATCH 05/12] git p4: move conflict prompt into run, use [c]ontinue and [q]uit Pete Wyckoff
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 ` Pete Wyckoff [this message]
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-10-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).