Instead of parsing the output of "p4 users" use the python objects of "p4 -G users".
Signed-off-by: Simon Hausmann <hausmann@kde.org>
Simon Hausmann committed
Jan 31, 2007 at 22:19 UTC
a39811b46e213737b9aaf34157f41fd1ac8a8a9e
1 file changed
+14
-14
contrib/fast-import/p4-fast-export.py
+14
-14
@@ -38,18 +38,25 @@ except ValueError:
38
if not prefix.endswith("/"):
39
prefix += "/"
40
41
-def p4Cmd(cmd):
41
+def p4CmdList(cmd):
42
pipe = os.popen("p4 -G %s" % cmd, "rb")
43
- result = {}
43
+ result = []
44
try:
45
while True:
46
entry = marshal.load(pipe)
47
- result.update(entry)
47
+ result.append(entry)
48
except EOFError:
49
pass
50
pipe.close()
51
return result
52
53
+def p4Cmd(cmd):
54
+ list = p4CmdList(cmd)
55
+ result = {}
56
+ for entry in list:
57
+ result.update(entry)
58
+ return result;
59
+
60
def describe(change):
61
describeOutput = p4Cmd("describe %s" % change)
62
@@ -94,18 +101,11 @@ def stripRevision(path):
101
102
def getUserMap():
103
users = {}
97
- output = os.popen("p4 users")
98
- for line in output:
99
- firstSpace = line.index(" ")
100
- secondSpace = line.index(" ", firstSpace + 1)
101
- key = line[:firstSpace]
102
- email = line[firstSpace + 1:secondSpace]
103
- openParenPos = line.index("(", secondSpace)
104
- closedParenPos = line.index(")", openParenPos)
105
- name = line[openParenPos + 1:closedParenPos]
106
-
107
- users[key] = name + " " + email
104
105
+ for output in p4CmdList("users"):
106
+ if not output.has_key("User"):
107
+ continue
108
+ users[output["User"]] = output["FullName"] + " <" + output["Email"] + ">"
109
return users
110
111
users = getUserMap()