summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Simon Hausmann <hausmann@kde.org>2007-01-31 22:13:17 +0100
committerLibravatar Simon Hausmann <hausmann@kde.org>2007-01-31 22:13:17 +0100
commitf6148d912965686f8bb081a53107ad21a9227007 (patch)
treebd6a8d0cbea1348bb7d88b5dac85d154d2fd8485
parentChanged the import mechanism to write to git fast-import through a pipe inste... (diff)
downloadtgif-f6148d912965686f8bb081a53107ad21a9227007.tar.xz
Minor code cleanups and ported some p4 interfacing code over to the p4 python mode.
Signed-off-by: Simon Hausmann <hausmann@kde.org>
-rw-r--r--contrib/fast-import/p4-fast-export.py53
1 files changed, 14 insertions, 39 deletions
diff --git a/contrib/fast-import/p4-fast-export.py b/contrib/fast-import/p4-fast-export.py
index 662dd01d8d..3ccef526eb 100644
--- a/contrib/fast-import/p4-fast-export.py
+++ b/contrib/fast-import/p4-fast-export.py
@@ -51,54 +51,30 @@ def p4Cmd(cmd):
return result
def describe(change):
- output = os.popen("p4 describe %s" % change).readlines()
+ describeOutput = p4Cmd("describe %s" % change)
- firstLine = output[0]
+ author = describeOutput["user"]
+ epoch = describeOutput["time"]
- splitted = firstLine.split(" ")
- author = splitted[3]
- author = author[:author.find("@")]
- tm = time.strptime(splitted[5] + " " + splitted[6], "%Y/%m/%d %H:%M:%S ")
- epoch = int(time.mktime(tm))
-
- filesSection = 0
- try:
- filesSection = output.index("Affected files ...\n")
- except ValueError:
- sys.stderr.write("Change %s doesn't seem to affect any files. Weird.\n" % change)
- return [], [], [], [], []
-
- differencesSection = 0
- try:
- differencesSection = output.index("Differences ...\n")
- except ValueError:
- sys.stderr.write("Change %s doesn't seem to have a differences section. Weird.\n" % change)
- return [], [], [], [], []
-
- log = output[2:filesSection - 1]
-
- lines = output[filesSection + 2:differencesSection - 1]
+ log = describeOutput["desc"]
changed = []
removed = []
- for line in lines:
- # chop off "... " and trailing newline
- line = line[4:len(line) - 1]
-
- lastSpace = line.rfind(" ")
- if lastSpace == -1:
- sys.stderr.write("trouble parsing line %s, skipping!\n" % line)
- continue
+ 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
- operation = line[lastSpace + 1:]
- path = line[:lastSpace]
-
- if operation == "delete":
+ if action == "delete":
removed.append(path)
else:
changed.append(path)
+ i = i + 1
+
return author, log, epoch, changed, removed
def p4Stat(path):
@@ -161,8 +137,7 @@ for change in changes:
else:
gitStream.write("committer %s <a@b> %s %s\n" % (author, epoch, tz))
gitStream.write("data <<EOT\n")
- for l in log:
- gitStream.write(l)
+ gitStream.write(log)
gitStream.write("EOT\n\n")
for f in changedFiles: