[PATCHv2,1/2] git-p4: add failing test for shelved CL update involving move
diff mbox series

Message ID 20190114235524.3947-2-luke@diamand.org
State New
Headers show
Series
  • git-p4: handle moved files when updating a P4 shelve
Related show

Commit Message

Luke Diamand Jan. 14, 2019, 11:55 p.m. UTC
Updating a shelved P4 changelist where one or more files have
been moved does not work. Add a test for this.

The problem is that P4 requires a complete list of the files being
changed, and move/rename only includes the _source_ in the case of
updating a shelved changelist. This results in errors from Perforce
such as:

  //depot/src - needs tofile //depot/dst
  Submit aborted -- fix problems then use 'p4 submit -c 1234'

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 t/t9807-git-p4-submit.sh | 51 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 48 insertions(+), 3 deletions(-)

Comments

Mazo, Andrey Jan. 16, 2019, 11:40 p.m. UTC | #1
> 
> Updating a shelved P4 changelist where one or more files have
> been moved does not work. Add a test for this.
> 
> The problem is that P4 requires a complete list of the files being
> changed, and move/rename only includes the _source_ in the case of
> updating a shelved changelist. This results in errors from Perforce
> such as:
> 
>   //depot/src - needs tofile //depot/dst
>   Submit aborted -- fix problems then use 'p4 submit -c 1234'
> 

Shouldn't a similar test case and a fix be added for the "copy" case too?
The code looks very similar to the "move" case, so will probably fail in a similar way, right?

For the "move" test case and the fix, please, feel free to add my
Acked-by: Andrey Mazo <amazo@checkvideo.com>
(if it's of any use)

Thank you,
Andrey

Patch
diff mbox series

diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh
index 2325599ee6..c390af56ad 100755
--- a/t/t9807-git-p4-submit.sh
+++ b/t/t9807-git-p4-submit.sh
@@ -500,6 +500,10 @@  test_expect_success 'submit --shelve' '
 	)
 '
 
+last_shelve() {
+	p4 -G changes -s shelved -m 1 //depot/... | marshal_dump change
+}
+
 make_shelved_cl() {
 	test_commit "$1" >/dev/null &&
 	git p4 submit --origin HEAD^ --shelve >/dev/null &&
@@ -533,12 +537,53 @@  test_expect_success 'submit --update-shelve' '
 	) &&
 	(
 		cd "$cli" &&
-		change=$(p4 -G changes -s shelved -m 1 //depot/... | \
-			 marshal_dump change) &&
+		change=$(last_shelve) &&
 		p4 unshelve -c $change -s $change &&
 		grep -q updated-line shelf.t &&
 		p4 describe -S $change | grep added-file.t &&
-		test_path_is_missing shelved-change-1.t
+		test_path_is_missing shelved-change-1.t &&
+		p4 revert ...
+	)
+'
+
+test_expect_failure 'update a shelve involving a moved file' '
+	test_when_finished cleanup_git &&
+	(
+		cd "$cli" &&
+		: >file_to_move &&
+		p4 add file_to_move &&
+		p4 submit -d "change1" &&
+		p4 edit file_to_move &&
+		echo change >>file_to_move &&
+		p4 submit -d "change2" &&
+		p4 opened
+	) &&
+	git p4 clone --dest="$git" //depot &&
+	(
+		cd "$git" &&
+		git config git-p4.skipSubmitEdit true &&
+		mkdir moved &&
+		git mv file_to_move moved/ &&
+		git commit -m "rename a file" &&
+		git p4 submit -M --shelve --origin HEAD^ &&
+		: >new_file &&
+		git add new_file &&
+		git commit --amend &&
+		git show --stat HEAD &&
+		change=$(last_shelve) &&
+		git p4 submit -M --update-shelve $change --commit HEAD
+	) &&
+	(
+		cd "$cli" &&
+		change=$(last_shelve) &&
+		echo change=$change &&
+		p4 unshelve -s $change &&
+		p4 submit -d "Testing update-shelve" &&
+		test_path_is_file moved/file_to_move &&
+		test_path_is_missing file_to_move &&
+		test_path_is_file new_file &&
+		echo "unshelved and submitted change $change" &&
+		p4 changes moved/file_to_move | grep "Testing update-shelve"
 	)
 '