1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-30 05:47:53 +01:00

Minor code cleanups and ported some p4 interfacing code over to the p4 python mode.

Signed-off-by: Simon Hausmann <hausmann@kde.org>
This commit is contained in:
Simon Hausmann 2007-01-31 22:13:17 +01:00
parent 701ce87633
commit f6148d9129

View file

@ -51,54 +51,30 @@ def p4Cmd(cmd):
return result return result
def describe(change): 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(" ") log = describeOutput["desc"]
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]
changed = [] changed = []
removed = [] removed = []
for line in lines: i = 0
# chop off "... " and trailing newline while describeOutput.has_key("depotFile%s" % i):
line = line[4:len(line) - 1] path = describeOutput["depotFile%s" % i]
rev = describeOutput["rev%s" % i]
action = describeOutput["action%s" % i]
path = path + "#" + rev
lastSpace = line.rfind(" ") if action == "delete":
if lastSpace == -1:
sys.stderr.write("trouble parsing line %s, skipping!\n" % line)
continue
operation = line[lastSpace + 1:]
path = line[:lastSpace]
if operation == "delete":
removed.append(path) removed.append(path)
else: else:
changed.append(path) changed.append(path)
i = i + 1
return author, log, epoch, changed, removed return author, log, epoch, changed, removed
def p4Stat(path): def p4Stat(path):
@ -161,8 +137,7 @@ def getUserMap():
else: else:
gitStream.write("committer %s <a@b> %s %s\n" % (author, epoch, tz)) gitStream.write("committer %s <a@b> %s %s\n" % (author, epoch, tz))
gitStream.write("data <<EOT\n") gitStream.write("data <<EOT\n")
for l in log: gitStream.write(log)
gitStream.write(l)
gitStream.write("EOT\n\n") gitStream.write("EOT\n\n")
for f in changedFiles: for f in changedFiles: