Skip to content

Commit df5ed90

Browse files
ggibbonsgitster
authored andcommitted
git-p4: sort client views by reverse View number
Correct view sorting to support the Perforce order, where client views are ordered and later views override earlier view mappings. [pw: one test now succeeds] Signed-off-by: Gary Gibbons <[email protected]> Signed-off-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b10048d commit df5ed90

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

contrib/fast-import/git-p4

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,10 +1924,17 @@ class P4Sync(Command, P4UserMap):
19241924
else:
19251925
include = len(v)
19261926

1927-
temp[v] = (include, cv)
1927+
# store the View #number for sorting
1928+
# and the View string itself (this last for documentation)
1929+
temp[v] = (include, cv, int(k[4:]),k)
19281930

19291931
self.clientSpecDirs = temp.items()
1930-
self.clientSpecDirs.sort( lambda x, y: abs( y[1][0] ) - abs( x[1][0] ) )
1932+
# Perforce ViewNN with higher #numbers override those with lower
1933+
# reverse sort on the View #number
1934+
self.clientSpecDirs.sort( lambda x, y: y[1][2] - x[1][2] )
1935+
if self.verbose:
1936+
for val in self.clientSpecDirs:
1937+
print "clientSpecDirs: %s %s" % (val[0],val[1])
19311938

19321939
def run(self, args):
19331940
self.depotPaths = []

t/t9809-git-p4-client-view.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ test_expect_failure 'single file map' '
133133
git_verify $files
134134
'
135135

136-
test_expect_failure 'later mapping takes precedence (entire repo)' '
136+
test_expect_success 'later mapping takes precedence (entire repo)' '
137137
client_view "//depot/dir1/... //client/cli1/..." \
138138
"//depot/... //client/cli2/..." &&
139139
files="cli2/dir1/file11 cli2/dir1/file12

0 commit comments

Comments
 (0)