Create lightweight git tags (using the "reset" trick) for the incremental import instead of full-blown ones. Also fix parsing the output of git name-rev for figuring out the last imported p4 change number.
Signed-off-by: Simon Hausmann <simon@lst.de>
Simon Hausmann committed
Feb 11, 2007 at 18:04 UTC
fc21f8a1dab090ceb63c479705104cbb95585a2f
1 file changed
+10
-6
contrib/fast-import/p4-fast-export.py
+10
-6
@@ -170,9 +170,14 @@ if len(changeRange) == 0:
170
try:
171
sout, sin, serr = popen2.popen3("git-name-rev --tags `git-rev-parse %s`" % branch)
172
output = sout.read()
173
+ if output.endswith("\n"):
174
+ output = output[:-1]
175
tagIdx = output.index(" tags/p4/")
174
- caretIdx = output.index("^")
175
- rev = int(output[tagIdx + 9 : caretIdx]) + 1
176
+ caretIdx = output.find("^")
177
+ endPos = len(output)
178
+ if caretIdx != -1:
179
+ endPos = caretIdx
180
+ rev = int(output[tagIdx + 9 : endPos]) + 1
181
changeRange = "@%s,#head" % rev
182
initialParent = os.popen("git-rev-parse %s" % branch).read()[:-1]
183
initialTag = "p4/%s" % (int(rev) - 1)
@@ -247,10 +252,9 @@ else:
252
253
print ""
254
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")
255
+gitStream.write("reset refs/tags/p4/%s\n" % lastChange)
256
+gitStream.write("from %s\n\n" % branch);
257
+
258
259
gitStream.close()
260
gitOutput.close()