Avoid the excessive use of git tags for every perforce change and instead just create one git tag for the last imported change.
Signed-off-by: Simon Hausmann <simon@lst.de>
Simon Hausmann committed
Feb 10, 2007 at 10:05 UTC
8718f3ec9a550c8c2419576a3765c20189029c99
1 file changed
+15
-5
contrib/fast-import/p4-fast-export.py
+15
-5
@@ -49,6 +49,9 @@ changeRange = ""
49
revision = ""
50
users = {}
51
initialParent = ""
52
+lastChange = ""
53
+lastCommitter = ""
54
+initialTag = ""
55
56
if prefix.find("@") != -1:
57
atIdx = prefix.index("@")
@@ -94,6 +97,8 @@ def p4Cmd(cmd):
97
def commit(details):
98
global initialParent
99
global users
100
+ global lastChange
101
+ global lastCommitter
102
103
epoch = details["time"]
104
author = details["user"]
@@ -147,11 +152,8 @@ def commit(details):
152
153
gitStream.write("\n")
154
150
- gitStream.write("tag p4/%s\n" % details["change"])
151
- gitStream.write("from %s\n" % branch);
152
- gitStream.write("tagger %s\n" % committer);
153
- gitStream.write("data 0\n\n")
154
-
155
+ lastChange = details["change"]
156
+ lastCommitter = committer
157
158
def getUserMap():
159
users = {}
@@ -173,6 +175,7 @@ if len(changeRange) == 0:
175
rev = int(output[tagIdx + 9 : caretIdx]) + 1
176
changeRange = "@%s,#head" % rev
177
initialParent = os.popen("git-rev-parse %s" % branch).read()[:-1]
178
+ initialTag = "p4/%s" % (int(rev) - 1)
179
except:
180
pass
181
@@ -244,10 +247,17 @@ else:
247
248
print ""
249
250
+gitStream.write("tag p4/%s\n" % lastChange)
251
+gitStream.write("from %s\n" % branch);
252
+gitStream.write("tagger %s\n" % lastCommitter);
253
+gitStream.write("data 0\n\n")
254
+
255
gitStream.close()
256
gitOutput.close()
257
gitError.close()
258
259
os.popen("git-repo-config p4.depotpath %s" % prefix).read()
260
+if len(initialTag) > 0:
261
+ os.popen("git tag -d %s" % initialTag).read()
262
263
sys.exit(0)