{"thread":{"id":"50225","subject":"[PATCHv2 0/2] git-p4: handle moved files when updating a P4 shelve","startedAt":"2019-01-14T23:55:35Z","lastAt":"2019-01-16T23:40:35Z","messageCount":4,"participants":["Luke Diamand","Mazo, Andrey"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"366688","messageId":"20190114235524.3947-1-luke@diamand.org","threadId":"50225","inReplyTo":null,"subject":"[PATCHv2 0/2] git-p4: handle moved files when updating a P4 shelve","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2019-01-14T23:55:22Z","receivedAt":"2019-01-14T23:55:35Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Updated as per comments from Junio, Eric.\n\nhttps://public-inbox.org/git/20190113135815.11286-1-luke@diamand.org/\n\nLuke Diamand (2):\n  git-p4: add failing test for shelved CL update involving move\n  git-p4: handle update of moved files when updating a shelve\n\n git-p4.py                |  1 +\n t/t9807-git-p4-submit.sh | 51 +++++++++++++++++++++++++++++++++++++---\n 2 files changed, 49 insertions(+), 3 deletions(-)\n\n-- \n2.20.1.100.g9ee79a14a8\n\n"},{"id":"366689","messageId":"20190114235524.3947-2-luke@diamand.org","threadId":"50225","inReplyTo":"20190114235524.3947-1-luke@diamand.org","subject":"[PATCHv2 1/2] git-p4: add failing test for shelved CL update involving move","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2019-01-14T23:55:23Z","receivedAt":"2019-01-14T23:55:36Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Updating a shelved P4 changelist where one or more files have\nbeen moved does not work. Add a test for this.\n\nThe problem is that P4 requires a complete list of the files being\nchanged, and move/rename only includes the _source_ in the case of\nupdating a shelved changelist. This results in errors from Perforce\nsuch as:\n\n  //depot/src - needs tofile //depot/dst\n  Submit aborted -- fix problems then use 'p4 submit -c 1234'\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n t/t9807-git-p4-submit.sh | 51 +++++++++++++++++++++++++++++++++++++---\n 1 file changed, 48 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh\nindex 2325599ee6..c390af56ad 100755\n--- a/t/t9807-git-p4-submit.sh\n+++ b/t/t9807-git-p4-submit.sh\n@@ -500,6 +500,10 @@ test_expect_success 'submit --shelve' '\n \t)\n '\n \n+last_shelve() {\n+\tp4 -G changes -s shelved -m 1 //depot/... | marshal_dump change\n+}\n+\n make_shelved_cl() {\n \ttest_commit \"$1\" >/dev/null &&\n \tgit p4 submit --origin HEAD^ --shelve >/dev/null &&\n@@ -533,12 +537,53 @@ test_expect_success 'submit --update-shelve' '\n \t) &&\n \t(\n \t\tcd \"$cli\" &&\n-\t\tchange=$(p4 -G changes -s shelved -m 1 //depot/... | \\\n-\t\t\t marshal_dump change) &&\n+\t\tchange=$(last_shelve) &&\n \t\tp4 unshelve -c $change -s $change &&\n \t\tgrep -q updated-line shelf.t &&\n \t\tp4 describe -S $change | grep added-file.t &&\n-\t\ttest_path_is_missing shelved-change-1.t\n+\t\ttest_path_is_missing shelved-change-1.t &&\n+\t\tp4 revert ...\n+\t)\n+'\n+\n+test_expect_failure 'update a shelve involving a moved file' '\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\t: >file_to_move &&\n+\t\tp4 add file_to_move &&\n+\t\tp4 submit -d \"change1\" &&\n+\t\tp4 edit file_to_move &&\n+\t\techo change >>file_to_move &&\n+\t\tp4 submit -d \"change2\" &&\n+\t\tp4 opened\n+\t) &&\n+\tgit p4 clone --dest=\"$git\" //depot &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\t\tmkdir moved &&\n+\t\tgit mv file_to_move moved/ &&\n+\t\tgit commit -m \"rename a file\" &&\n+\t\tgit p4 submit -M --shelve --origin HEAD^ &&\n+\t\t: >new_file &&\n+\t\tgit add new_file &&\n+\t\tgit commit --amend &&\n+\t\tgit show --stat HEAD &&\n+\t\tchange=$(last_shelve) &&\n+\t\tgit p4 submit -M --update-shelve $change --commit HEAD\n+\t) &&\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\tchange=$(last_shelve) &&\n+\t\techo change=$change &&\n+\t\tp4 unshelve -s $change &&\n+\t\tp4 submit -d \"Testing update-shelve\" &&\n+\t\ttest_path_is_file moved/file_to_move &&\n+\t\ttest_path_is_missing file_to_move &&\n+\t\ttest_path_is_file new_file &&\n+\t\techo \"unshelved and submitted change $change\" &&\n+\t\tp4 changes moved/file_to_move | grep \"Testing update-shelve\"\n \t)\n '\n \n-- \n2.20.1.100.g9ee79a14a8\n\n"},{"id":"366690","messageId":"20190114235524.3947-3-luke@diamand.org","threadId":"50225","inReplyTo":"20190114235524.3947-2-luke@diamand.org","subject":"[PATCHv2 2/2] git-p4: handle update of moved files when updating a shelve","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2019-01-14T23:55:24Z","receivedAt":"2019-01-14T23:55:39Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Perforce requires a complete list of files being operated on. If\ngit is updating an existing shelved changelist, then any files\nwhich are moved were not being added to this list.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n git-p4.py                | 1 +\n t/t9807-git-p4-submit.sh | 2 +-\n 2 files changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex 1998c3e141..20c5ce9903 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -1875,6 +1875,7 @@ def applyCommit(self, id):\n                 editedFiles.add(dest)\n             elif modifier == \"R\":\n                 src, dest = diff['src'], diff['dst']\n+                all_files.append(dest)\n                 if self.p4HasMoveCommand:\n                     p4_edit(src)        # src must be open before move\n                     p4_move(src, dest)  # opens for (move/delete, move/add)\ndiff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh\nindex c390af56ad..c4ddd28f41 100755\n--- a/t/t9807-git-p4-submit.sh\n+++ b/t/t9807-git-p4-submit.sh\n@@ -546,7 +546,7 @@ test_expect_success 'submit --update-shelve' '\n \t)\n '\n \n-test_expect_failure 'update a shelve involving a moved file' '\n+test_expect_success 'update a shelve involving a moved file' '\n \ttest_when_finished cleanup_git &&\n \t(\n \t\tcd \"$cli\" &&\n-- \n2.20.1.100.g9ee79a14a8\n\n"},{"id":"366890","messageId":"20190116234001.15234-1-amazo@checkvideo.com","threadId":"50225","inReplyTo":"20190114235524.3947-2-luke@diamand.org","subject":"Re: [PATCHv2 1/2] git-p4: add failing test for shelved CL update involving move","fromName":"Mazo, Andrey","fromEmail":"amazo@checkvideo.com","sentAt":"2019-01-16T23:40:23Z","receivedAt":"2019-01-16T23:40:35Z","isPatch":false,"sender":{"key":"amazo@checkvideo.com","avatar":null},"body":"> \n> Updating a shelved P4 changelist where one or more files have\n> been moved does not work. Add a test for this.\n> \n> The problem is that P4 requires a complete list of the files being\n> changed, and move/rename only includes the _source_ in the case of\n> updating a shelved changelist. This results in errors from Perforce\n> such as:\n> \n>   //depot/src - needs tofile //depot/dst\n>   Submit aborted -- fix problems then use 'p4 submit -c 1234'\n> \n\nShouldn't a similar test case and a fix be added for the \"copy\" case too?\nThe code looks very similar to the \"move\" case, so will probably fail in a similar way, right?\n\nFor the \"move\" test case and the fix, please, feel free to add my\nAcked-by: Andrey Mazo <amazo@checkvideo.com>\n(if it's of any use)\n\nThank you,\nAndrey\n"}]}