Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Diamand <luke@diamand.org>2018-10-15 14:14:08 +0300
committerJunio C Hamano <gitster@pobox.com>2018-10-16 07:28:49 +0300
commit89143ac28a61578487af7324c653a9efa5e40034 (patch)
tree149cba5b6bfcef8adef542d19814ca433b069b3a /t/t9832-unshelve.sh
parent088131273b7e781174eb1cffb7d4e0eb51066cba (diff)
git-p4: fully support unshelving changelists
The previous git-p4 unshelve support would check for changes in Perforce to the files being unshelved since the original shelve, and would complain if any were found. This was to ensure that the user wouldn't end up with both the shelved change delta, and some deltas from other changes in their git commit. e.g. given fileA: the quick brown fox change1: s/the/The/ <- p4 shelve this change change2: s/fox/Fox/ <- p4 submit this change git p4 unshelve 1 <- FAIL This change teaches the P4Unshelve class to always create a parent commit which matches the P4 tree (for the files being unshelved) at the point prior to the P4 shelve being created (which is reported in the p4 description for a shelved changelist). That then means git-p4 can always create a git commit matching the P4 shelve that was originally created, without any extra deltas. The user might still need to use the --origin option though - there is no way for git-p4 to work out the versions of all of the other *unchanged* files in the shelve, since this information is not recorded by Perforce. Additionally this fixes handling of shelved 'move' operations. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9832-unshelve.sh')
-rwxr-xr-xt/t9832-unshelve.sh69
1 files changed, 56 insertions, 13 deletions
diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
index c3d15ceea8..41c09f11f4 100755
--- a/t/t9832-unshelve.sh
+++ b/t/t9832-unshelve.sh
@@ -19,8 +19,10 @@ test_expect_success 'init depot' '
p4 add file1 &&
p4 submit -d "change 1" &&
: >file_to_delete &&
+ : >file_to_move &&
p4 add file_to_delete &&
- p4 submit -d "file to delete"
+ p4 add file_to_move &&
+ p4 submit -d "add files to delete"
)
'
@@ -36,6 +38,8 @@ test_expect_success 'create shelved changelist' '
echo "new file" >file2 &&
p4 add file2 &&
p4 delete file_to_delete &&
+ p4 edit file_to_move &&
+ p4 move file_to_move moved_file &&
p4 opened &&
p4 shelve -i <<EOF
Change: new
@@ -47,6 +51,8 @@ Files:
//depot/file1
//depot/file2
//depot/file_to_delete
+ //depot/file_to_move
+ //depot/moved_file
EOF
) &&
@@ -59,7 +65,9 @@ EOF
test_path_is_file file2 &&
test_cmp file1 "$cli"/file1 &&
test_cmp file2 "$cli"/file2 &&
- test_path_is_missing file_to_delete
+ test_path_is_missing file_to_delete &&
+ test_path_is_missing file_to_move &&
+ test_path_is_file moved_file
)
'
@@ -92,6 +100,18 @@ EOF
)
'
+shelve_one_file () {
+ description="Change to be unshelved" &&
+ file="$1" &&
+ p4 shelve -i <<EOF
+Change: new
+Description:
+ $description
+Files:
+ $file
+EOF
+}
+
# This is the tricky case where the shelved changelist base revision doesn't
# match git-p4's idea of the base revision
#
@@ -108,29 +128,52 @@ test_expect_success 'create shelved changelist based on p4 change ahead of p4/ma
p4 submit -d "change:foo" &&
p4 edit file1 &&
echo "bar" >>file1 &&
- p4 shelve -i <<EOF &&
-Change: new
-Description:
- Change to be unshelved
-Files:
- //depot/file1
-EOF
+ shelve_one_file //depot/file1 &&
change=$(last_shelved_change) &&
- p4 describe -S $change | grep -q "Change to be unshelved"
+ p4 describe -S $change >out.txt &&
+ grep -q "Change to be unshelved" out.txt
)
'
-# Now try to unshelve it. git-p4 should refuse to do so.
+# Now try to unshelve it.
test_expect_success 'try to unshelve the change' '
test_when_finished cleanup_git &&
(
change=$(last_shelved_change) &&
cd "$git" &&
- test_must_fail git p4 unshelve $change 2>out.txt &&
- grep -q "cannot unshelve" out.txt
+ git p4 unshelve $change >out.txt &&
+ grep -q "unshelved changelist $change" out.txt
)
'
+# Specify the origin. Create 2 unrelated files, and check that
+# we only get the one in HEAD~, not the one in HEAD.
+
+test_expect_success 'unshelve specifying the origin' '
+ (
+ cd "$cli" &&
+ : >unrelated_file0 &&
+ p4 add unrelated_file0 &&
+ p4 submit -d "unrelated" &&
+ : >unrelated_file1 &&
+ p4 add unrelated_file1 &&
+ p4 submit -d "unrelated" &&
+ : >file_to_shelve &&
+ p4 add file_to_shelve &&
+ shelve_one_file //depot/file_to_shelve
+ ) &&
+ test_when_finished cleanup_git &&
+ git p4 clone --dest="$git" //depot/@all &&
+ (
+ cd "$git" &&
+ change=$(last_shelved_change) &&
+ git p4 unshelve --origin HEAD~ $change &&
+ git checkout refs/remotes/p4-unshelved/$change &&
+ test_path_is_file unrelated_file0 &&
+ test_path_is_missing unrelated_file1 &&
+ test_path_is_file file_to_shelve
+ )
+'
test_expect_success 'kill p4d' '
kill_p4d
'