summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 79799d5)
raw | patch | inline | side by side (parent: 79799d5)
author | Simon Hausmann <hausmann@kde.org> | |
Wed, 31 Jan 2007 23:08:51 +0000 (00:08 +0100) | ||
committer | Simon Hausmann <hausmann@kde.org> | |
Wed, 31 Jan 2007 23:08:51 +0000 (00:08 +0100) |
Try to find the last imported p4 change number from the git tags and try to pass the right parent for commits to git fast-import.
Signed-off-by: Simon Hausmann <hausmann@kde.org>
Signed-off-by: Simon Hausmann <hausmann@kde.org>
contrib/fast-import/p4-fast-export.py | patch | blob | history |
index 588554d67262238ad0259396e372038c7affd077..da3eb35841c5bdb807dab4c929daa4320a39956f 100755 (executable)
print ""
sys.exit(1)
+master = "refs/heads/p4"
+branch = "refs/heads/p4-import"
prefix = sys.argv[1]
changeRange = ""
try:
return users
users = getUserMap()
+topMerge = ""
+
+incremental = 0
+# try incremental import
+if len(changeRange) == 0:
+ try:
+ sout, sin, serr = popen2.popen3("git-name-rev --tags `git-rev-parse %s`" % master)
+ output = sout.read()
+ tagIdx = output.index(" tags/p4/")
+ caretIdx = output.index("^")
+ revision = int(output[tagIdx + 9 : caretIdx]) + 1
+ changeRange = "@%s,#head" % revision
+ topMerge = os.popen("git-rev-parse %s" % master).read()[:-1]
+ incremental = 1
+ except:
+ pass
+
+if incremental == 0:
+ branch = master
output = os.popen("p4 changes %s...%s" % (prefix, changeRange)).readlines()
changes.reverse()
+if len(changes) == 0:
+ print "no changes to import!"
+ sys.exit(1)
+
sys.stderr.write("\n")
tz = - time.timezone / 36
epoch = description["time"]
author = description["user"]
- gitStream.write("commit refs/heads/master\n")
+ gitStream.write("commit %s\n" % branch)
committer = ""
if author in users:
committer = "%s %s %s" % (users[author], epoch, tz)
gitStream.write("\n[ imported from %s; change %s ]\n" % (prefix, change))
gitStream.write("EOT\n\n")
+ if len(topMerge) > 0:
+ gitStream.write("merge %s\n" % topMerge)
+ topMerge = ""
+
fnum = 0
while description.has_key("depotFile%s" % fnum):
path = description["depotFile%s" % fnum]
gitStream.write("\n")
gitStream.write("tag p4/%s\n" % change)
- gitStream.write("from refs/heads/master\n");
+ gitStream.write("from %s\n" % branch);
gitStream.write("tagger %s\n" % committer);
gitStream.write("data 0\n\n")
gitOutput.close()
gitError.close()
+if incremental == 1:
+ os.popen("git rebase p4-import p4")
+ os.popen("git branch -d p4-import")
+
print ""