From: Simon Hausmann Date: Wed, 31 Jan 2007 21:31:28 +0000 (+0100) Subject: Ported the remaining functions that parsed p4 shell output over to the p4 python... X-Git-Tag: v1.5.3-rc0~65^2^2~234 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0dd0b9d01116d57c612a5fa90de803bdd836ce11;p=git.git Ported the remaining functions that parsed p4 shell output over to the p4 python interface. Signed-off-by: Simon Hausmann --- diff --git a/contrib/fast-import/p4-fast-export.py b/contrib/fast-import/p4-fast-export.py index d3e65f0f3..45d515796 100644 --- a/contrib/fast-import/p4-fast-export.py +++ b/contrib/fast-import/p4-fast-export.py @@ -57,47 +57,8 @@ def p4Cmd(cmd): result.update(entry) return result; -def describe(change): - describeOutput = p4Cmd("describe %s" % change) - - author = describeOutput["user"] - epoch = describeOutput["time"] - - log = describeOutput["desc"] - - changed = [] - removed = [] - - i = 0 - while describeOutput.has_key("depotFile%s" % i): - path = describeOutput["depotFile%s" % i] - rev = describeOutput["rev%s" % i] - action = describeOutput["action%s" % i] - path = path + "#" + rev - - if action == "delete": - removed.append(path) - else: - changed.append(path) - - i = i + 1 - - return author, log, epoch, changed, removed - -def p4Stat(path): - output = os.popen("p4 fstat -Ol \"%s\"" % path).readlines() - fileSize = 0 - mode = 644 - for line in output: - if line.startswith("... headType x"): - mode = 755 - elif line.startswith("... fileSize "): - fileSize = long(line[12:]) - return mode, fileSize - -def stripRevision(path): - hashPos = path.rindex("#") - return path[:hashPos] +def p4FileSize(path): + return int(p4Cmd("fstat -Ol \"%s\"" % path)["fileSize"]) def getUserMap(): users = {} @@ -127,38 +88,50 @@ gitOutput, gitStream, gitError = popen2.popen3("git-fast-import") cnt = 1 for change in changes: - [ author, log, epoch, changedFiles, removedFiles ] = describe(change) + description = p4Cmd("describe %s" % change) + sys.stdout.write("\rimporting revision %s (%s%%)" % (change, cnt * 100 / len(changes))) cnt = cnt + 1 + epoch = description["time"] + author = description["user"] + gitStream.write("commit refs/heads/master\n") if author in users: gitStream.write("committer %s %s %s\n" % (users[author], epoch, tz)) else: gitStream.write("committer %s %s %s\n" % (author, epoch, tz)) gitStream.write("data <