Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git p4 fetching changes in multiple blocks' |
| 4 | |
| 5 | . ./lib-git-p4.sh |
| 6 | |
| 7 | test_expect_success 'start p4d' ' |
| 8 | start_p4d |
| 9 | ' |
| 10 | |
Luke Diamand | 6ba9e2c | 2015-06-07 22:35:04 +0100 | [diff] [blame] | 11 | create_restricted_group() { |
| 12 | p4 group -i <<-EOF |
| 13 | Group: restricted |
| 14 | MaxResults: 7 |
| 15 | MaxScanRows: 40 |
| 16 | Users: author |
| 17 | EOF |
| 18 | } |
| 19 | |
| 20 | test_expect_success 'Create group with limited maxrows' ' |
| 21 | create_restricted_group |
| 22 | ' |
| 23 | |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 24 | test_expect_success 'Create a repo with many changes' ' |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 25 | ( |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 26 | client_view "//depot/included/... //client/included/..." \ |
| 27 | "//depot/excluded/... //client/excluded/..." && |
| 28 | mkdir -p "$cli/included" "$cli/excluded" && |
| 29 | cd "$cli/included" && |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 30 | >file.txt && |
| 31 | p4 add file.txt && |
| 32 | p4 submit -d "Add file.txt" && |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 33 | for i in $(test_seq 0 5) |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 34 | do |
| 35 | >outer$i.txt && |
| 36 | p4 add outer$i.txt && |
| 37 | p4 submit -d "Adding outer$i.txt" && |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 38 | for j in $(test_seq 0 5) |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 39 | do |
| 40 | p4 edit file.txt && |
| 41 | echo $i$j >file.txt && |
| 42 | p4 submit -d "Commit $i$j" || exit |
| 43 | done || exit |
| 44 | done |
| 45 | ) |
| 46 | ' |
| 47 | |
Luke Diamand | 6ba9e2c | 2015-06-07 22:35:04 +0100 | [diff] [blame] | 48 | test_expect_success 'Default user cannot fetch changes' ' |
| 49 | ! p4 changes -m 1 //depot/... |
| 50 | ' |
| 51 | |
Luke Diamand | 1051ef0 | 2015-06-10 08:30:59 +0100 | [diff] [blame] | 52 | test_expect_success 'Clone the repo' ' |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 53 | git p4 clone --dest="$git" --changes-block-size=7 --verbose //depot/included@all |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 54 | ' |
| 55 | |
Luke Diamand | 1051ef0 | 2015-06-10 08:30:59 +0100 | [diff] [blame] | 56 | test_expect_success 'All files are present' ' |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 57 | echo file.txt >expected && |
| 58 | test_write_lines outer0.txt outer1.txt outer2.txt outer3.txt outer4.txt >>expected && |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 59 | test_write_lines outer5.txt >>expected && |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 60 | ls "$git" >current && |
| 61 | test_cmp expected current |
| 62 | ' |
| 63 | |
Luke Diamand | 1051ef0 | 2015-06-10 08:30:59 +0100 | [diff] [blame] | 64 | test_expect_success 'file.txt is correct' ' |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 65 | echo 55 >expected && |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 66 | test_cmp expected "$git/file.txt" |
| 67 | ' |
| 68 | |
Luke Diamand | 1051ef0 | 2015-06-10 08:30:59 +0100 | [diff] [blame] | 69 | test_expect_success 'Correct number of commits' ' |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 70 | (cd "$git" && git log --oneline) >log && |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 71 | wc -l log && |
| 72 | test_line_count = 43 log |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 73 | ' |
| 74 | |
Luke Diamand | 1051ef0 | 2015-06-10 08:30:59 +0100 | [diff] [blame] | 75 | test_expect_success 'Previous version of file.txt is correct' ' |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 76 | (cd "$git" && git checkout HEAD^^) && |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 77 | echo 53 >expected && |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 78 | test_cmp expected "$git/file.txt" |
| 79 | ' |
| 80 | |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 81 | # Test git-p4 sync, with some files outside the client specification. |
| 82 | |
| 83 | p4_add_file() { |
| 84 | (cd "$cli" && |
| 85 | >$1 && |
| 86 | p4 add $1 && |
Luke Diamand | 785e70f | 2015-12-13 20:07:13 +0000 | [diff] [blame] | 87 | p4 submit -d "Added file $1" $1 |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 88 | ) |
| 89 | } |
| 90 | |
| 91 | test_expect_success 'Add some more files' ' |
| 92 | for i in $(test_seq 0 10) |
| 93 | do |
| 94 | p4_add_file "included/x$i" && |
| 95 | p4_add_file "excluded/x$i" |
| 96 | done && |
| 97 | for i in $(test_seq 0 10) |
| 98 | do |
| 99 | p4_add_file "excluded/y$i" |
| 100 | done |
| 101 | ' |
| 102 | |
| 103 | # This should pick up the 10 new files in "included", but not be confused |
| 104 | # by the additional files in "excluded" |
Luke Diamand | 1051ef0 | 2015-06-10 08:30:59 +0100 | [diff] [blame] | 105 | test_expect_success 'Syncing files' ' |
Luke Diamand | 755113b | 2015-06-07 22:35:03 +0100 | [diff] [blame] | 106 | ( |
| 107 | cd "$git" && |
| 108 | git p4 sync --changes-block-size=7 && |
| 109 | git checkout p4/master && |
| 110 | ls -l x* > log && |
| 111 | test_line_count = 11 log |
| 112 | ) |
| 113 | ' |
| 114 | |
Luke Diamand | 785e70f | 2015-12-13 20:07:13 +0000 | [diff] [blame] | 115 | # Handling of multiple depot paths: |
| 116 | # git p4 clone //depot/pathA //depot/pathB |
| 117 | # |
| 118 | test_expect_success 'Create a repo with multiple depot paths' ' |
| 119 | client_view "//depot/pathA/... //client/pathA/..." \ |
| 120 | "//depot/pathB/... //client/pathB/..." && |
| 121 | mkdir -p "$cli/pathA" "$cli/pathB" && |
| 122 | for p in pathA pathB |
| 123 | do |
| 124 | for i in $(test_seq 1 10) |
| 125 | do |
| 126 | p4_add_file "$p/file$p$i" |
| 127 | done |
| 128 | done |
| 129 | ' |
| 130 | |
Sam Hocevar | 1f90a64 | 2015-12-19 09:39:40 +0000 | [diff] [blame] | 131 | test_expect_success 'Clone repo with multiple depot paths' ' |
Luke Diamand | 3deed5e | 2018-06-08 21:32:48 +0100 | [diff] [blame] | 132 | test_when_finished cleanup_git && |
Luke Diamand | 785e70f | 2015-12-13 20:07:13 +0000 | [diff] [blame] | 133 | ( |
| 134 | cd "$git" && |
| 135 | git p4 clone --changes-block-size=4 //depot/pathA@all //depot/pathB@all \ |
| 136 | --destination=dest && |
| 137 | ls -1 dest >log && |
| 138 | test_line_count = 20 log |
| 139 | ) |
| 140 | ' |
| 141 | |
Luke Diamand | 3deed5e | 2018-06-08 21:32:48 +0100 | [diff] [blame] | 142 | test_expect_success 'Clone repo with self-sizing block size' ' |
| 143 | test_when_finished cleanup_git && |
| 144 | git p4 clone --changes-block-size=1000000 //depot@all --destination="$git" && |
| 145 | git -C "$git" log --oneline >log && |
| 146 | test_line_count \> 10 log |
| 147 | ' |
| 148 | |
Lex Spoon | 96b2d54 | 2015-04-20 11:00:20 -0400 | [diff] [blame] | 149 | test_done |