From: Gary Gibbons Date: Mon, 2 Jan 2012 23:05:51 +0000 (-0500) Subject: git-p4: sort client views by reverse View number X-Git-Tag: v1.7.9-rc0~4^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=df5ed9077f18985a73f00fe2bacc2961598f73dc;p=git.git 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 Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4 index c144c8960..2fd4d3b2a 100755 --- a/contrib/fast-import/git-p4 +++ b/contrib/fast-import/git-p4 @@ -1924,10 +1924,17 @@ class P4Sync(Command, P4UserMap): else: include = len(v) - temp[v] = (include, cv) + # store the View #number for sorting + # and the View string itself (this last for documentation) + temp[v] = (include, cv, int(k[4:]),k) self.clientSpecDirs = temp.items() - self.clientSpecDirs.sort( lambda x, y: abs( y[1][0] ) - abs( x[1][0] ) ) + # Perforce ViewNN with higher #numbers override those with lower + # reverse sort on the View #number + self.clientSpecDirs.sort( lambda x, y: y[1][2] - x[1][2] ) + if self.verbose: + for val in self.clientSpecDirs: + print "clientSpecDirs: %s %s" % (val[0],val[1]) def run(self, args): self.depotPaths = [] diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index cbf2213e9..06652cbf4 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -133,7 +133,7 @@ test_expect_failure 'single file map' ' git_verify $files ' -test_expect_failure 'later mapping takes precedence (entire repo)' ' +test_expect_success 'later mapping takes precedence (entire repo)' ' client_view "//depot/dir1/... //client/cli1/..." \ "//depot/... //client/cli2/..." && files="cli2/dir1/file11 cli2/dir1/file12