Skip to content

Commit 58c8bc7

Browse files
Pete Wyckoffgitster
authored andcommitted
git-p4: honor --changesfile option and test
When an explicit list of changes is given, it makes no sense to use @ALL or @3,5 or any of the other p4 revision specifiers. Make the code notice when this happens, instead of just ignoring --changesfile. Test it. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1471c6b commit 58c8bc7

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

contrib/fast-import/git-p4

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,17 @@ class P4Sync(Command, P4UserMap):
20242024
revision = ""
20252025
self.users = {}
20262026

2027+
# Make sure no revision specifiers are used when --changesfile
2028+
# is specified.
2029+
bad_changesfile = False
2030+
if len(self.changesFile) > 0:
2031+
for p in self.depotPaths:
2032+
if p.find("@") >= 0 or p.find("#") >= 0:
2033+
bad_changesfile = True
2034+
break
2035+
if bad_changesfile:
2036+
die("Option --changesfile is incompatible with revision specifiers")
2037+
20272038
newPaths = []
20282039
for p in self.depotPaths:
20292040
if p.find("@") != -1:
@@ -2040,7 +2051,10 @@ class P4Sync(Command, P4UserMap):
20402051
revision = p[hashIdx:]
20412052
p = p[:hashIdx]
20422053
elif self.previousDepotPaths == []:
2043-
revision = "#head"
2054+
# pay attention to changesfile, if given, else import
2055+
# the entire p4 tree at the head revision
2056+
if len(self.changesFile) == 0:
2057+
revision = "#head"
20442058

20452059
p = re.sub ("\.\.\.$", "", p)
20462060
if not p.endswith("/"):

t/t9806-git-p4-options.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ test_expect_success 'clone --branch' '
3838
)
3939
'
4040

41+
test_expect_success 'clone --changesfile' '
42+
cf="$TRASH_DIRECTORY/cf" &&
43+
test_when_finished "rm \"$cf\"" &&
44+
printf "1\n3\n" >"$cf" &&
45+
"$GITP4" clone --changesfile="$cf" --dest="$git" //depot &&
46+
test_when_finished cleanup_git &&
47+
(
48+
cd "$git" &&
49+
git log --oneline p4/master >lines &&
50+
test_line_count = 2 lines
51+
test_path_is_file file1 &&
52+
test_path_is_missing file2 &&
53+
test_path_is_file file3
54+
)
55+
'
56+
57+
test_expect_success 'clone --changesfile, @all' '
58+
cf="$TRASH_DIRECTORY/cf" &&
59+
test_when_finished "rm \"$cf\"" &&
60+
printf "1\n3\n" >"$cf" &&
61+
test_must_fail "$GITP4" clone --changesfile="$cf" --dest="$git" //depot@all
62+
'
63+
4164
test_expect_success 'kill p4d' '
4265
kill_p4d
4366
'

0 commit comments

Comments
 (0)