@matheusbsbs / matheus-bagliano / commits / cb2c9db507
Fork 0

Different versions of p4 have different output for the where command ;(

Signed-off-by: Simon Hausmann <simon@lst.de>

Simon Hausmann committed Mar 24, 2007 at 09:15 UTC cb2c9db507cda6804f85ebbacb58a7458ab127a6
1 file changed +17 -5
contrib/fast-import/git-p4
+17 -5
@@ -36,6 +36,22 @@ def p4Cmd(cmd):
36 result.update(entry)
37 return result;
38
39 +def p4Where(depotPath):
40 + if not depotPath.endswith("/"):
41 + depotPath += "/"
42 + output = p4Cmd("where %s..." % depotPath)
43 + clientPath = ""
44 + if "path" in output:
45 + clientPath = output.get("path")
46 + elif "data" in output:
47 + data = output.get("data")
48 + lastSpace = data.rfind(" ")
49 + clientPath = data[lastSpace + 1:]
50 +
51 + if clientPath.endswith("..."):
52 + clientPath = clientPath[:-3]
53 + return clientPath
54 +
55 def die(msg):
56 sys.stderr.write(msg + "\n")
57 sys.exit(1)
@@ -318,11 +334,7 @@ class P4Sync(Command):
334 print "Internal error: cannot locate perforce depot path from existing branches"
335 sys.exit(128)
336
321 - if not depotPath.endswith("/"):
322 - depotPath += "/"
323 - clientPath = p4Cmd("where %s..." % depotPath).get("path")
324 - if clientPath.endswith("..."):
325 - clientPath = clientPath[:-3]
337 + clientPath = p4Where(depotPath)
338
339 if len(clientPath) == 0:
340 print "Error: Cannot locate perforce checkout of %s in client view" % depotPath