git-p4: Fix bug in p4Where method.
When running: p4 where //depot/SomePath/... The result can in some situations look like: //depot/SomePath/... //client/SomePath/... /home/user/p4root/SomePath/... -//depot/SomePath/UndesiredSubdir/... //client/SomePath/UndesiredSubdir/... /home/user/p4root/SomePath/UndesiredSubdir/... This depends on the users Client view. The current p4Where method will now return /home/user/p4root/SomePath/UndesiredSubdir/... which is not what we want. This patch loops through the results from "p4 where", and picks the one where the depotFile exactly matches the given depotPath (//depot/SomePath/... in this example). Signed-off-by: Tor Arvid Lund <torarvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tor Arvid Lund committed
Dec 4, 2008 at 14:37 UTC
7f705dc3686c2b1c77172b6847c1406eb66a20c3
1 file changed
+9
-1
contrib/fast-import/git-p4
+9
-1
@@ -245,7 +245,15 @@ def p4Cmd(cmd):
245
def p4Where(depotPath):
246
if not depotPath.endswith("/"):
247
depotPath += "/"
248
- output = p4Cmd("where %s..." % depotPath)
248
+ depotPath = depotPath + "..."
249
+ outputList = p4CmdList("where %s" % depotPath)
250
+ output = None
251
+ for entry in outputList:
252
+ if entry["depotFile"] == depotPath:
253
+ output = entry
254
+ break
255
+ if output == None:
256
+ return ""
257
if output["code"] == "error":
258
return ""
259
clientPath = ""