Implemented basic support for converting the date of the perforce change to the git format. The timezone isn't correctly set up yet though.
Signed-off-by: Simon Hausmann <shausman@trolltech.com>
This commit is contained in:
@ -5,8 +5,7 @@
|
|||||||
# Author: Simon Hausmann <hausmann@kde.org>
|
# Author: Simon Hausmann <hausmann@kde.org>
|
||||||
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
||||||
#
|
#
|
||||||
# TODO: - fix date parsing (how hard can it be?)
|
# TODO: - support integrations (at least p4i)
|
||||||
# - support integrations (at least p4i)
|
|
||||||
# - support incremental imports
|
# - support incremental imports
|
||||||
# - create tags
|
# - create tags
|
||||||
# - instead of reading all files into a variable try to pipe from
|
# - instead of reading all files into a variable try to pipe from
|
||||||
@ -15,7 +14,7 @@
|
|||||||
# - support p4 submit (hah!)
|
# - support p4 submit (hah!)
|
||||||
# - don't hardcode the import to master
|
# - don't hardcode the import to master
|
||||||
#
|
#
|
||||||
import os, string, sys
|
import os, string, sys, time
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
sys.stderr.write("usage: %s //depot/path[@revRange]\n" % sys.argv[0]);
|
sys.stderr.write("usage: %s //depot/path[@revRange]\n" % sys.argv[0]);
|
||||||
@ -44,22 +43,25 @@ def describe(change):
|
|||||||
|
|
||||||
firstLine = output[0]
|
firstLine = output[0]
|
||||||
|
|
||||||
author = firstLine.split(" ")[3]
|
splitted = firstLine.split(" ")
|
||||||
|
author = splitted[3]
|
||||||
author = author[:author.find("@")]
|
author = author[:author.find("@")]
|
||||||
|
tm = time.strptime(splitted[5] + " " + splitted[6] + time.tzname[0], "%Y/%m/%d %H:%M:%S %Z")
|
||||||
|
epoch = int(time.mktime(tm))
|
||||||
|
|
||||||
filesSection = 0
|
filesSection = 0
|
||||||
try:
|
try:
|
||||||
filesSection = output.index("Affected files ...\n")
|
filesSection = output.index("Affected files ...\n")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
sys.stderr.write("Change %s doesn't seem to affect any files. Weird.\n" % change)
|
sys.stderr.write("Change %s doesn't seem to affect any files. Weird.\n" % change)
|
||||||
return [], [], [], []
|
return [], [], [], [], []
|
||||||
|
|
||||||
differencesSection = 0
|
differencesSection = 0
|
||||||
try:
|
try:
|
||||||
differencesSection = output.index("Differences ...\n")
|
differencesSection = output.index("Differences ...\n")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
sys.stderr.write("Change %s doesn't seem to have a differences section. Weird.\n" % change)
|
sys.stderr.write("Change %s doesn't seem to have a differences section. Weird.\n" % change)
|
||||||
return [], [], [], []
|
return [], [], [], [], []
|
||||||
|
|
||||||
log = output[2:filesSection - 1]
|
log = output[2:filesSection - 1]
|
||||||
|
|
||||||
@ -85,7 +87,7 @@ def describe(change):
|
|||||||
else:
|
else:
|
||||||
changed.append(path)
|
changed.append(path)
|
||||||
|
|
||||||
return author, log, changed, removed
|
return author, log, epoch, changed, removed
|
||||||
|
|
||||||
def p4cat(path):
|
def p4cat(path):
|
||||||
return os.popen("p4 print -q \"%s\"" % path).read()
|
return os.popen("p4 print -q \"%s\"" % path).read()
|
||||||
@ -124,9 +126,9 @@ changes.reverse()
|
|||||||
|
|
||||||
sys.stderr.write("\n")
|
sys.stderr.write("\n")
|
||||||
|
|
||||||
cnt = 0
|
cnt = 1
|
||||||
for change in changes:
|
for change in changes:
|
||||||
[ author, log, changedFiles, removedFiles ] = describe(change)
|
[ author, log, epoch, changedFiles, removedFiles ] = describe(change)
|
||||||
sys.stderr.write("\rimporting revision %s (%s%%)" % (change, cnt * 100 / len(changes)))
|
sys.stderr.write("\rimporting revision %s (%s%%)" % (change, cnt * 100 / len(changes)))
|
||||||
cnt = cnt + 1
|
cnt = cnt + 1
|
||||||
# sys.stderr.write("%s\n" % log)
|
# sys.stderr.write("%s\n" % log)
|
||||||
@ -135,9 +137,9 @@ for change in changes:
|
|||||||
|
|
||||||
print "commit refs/heads/master"
|
print "commit refs/heads/master"
|
||||||
if author in users:
|
if author in users:
|
||||||
print "committer %s 1 2" % users[author]
|
print "committer %s %s +0000" % (users[author], epoch)
|
||||||
else:
|
else:
|
||||||
print "committer %s <a@b> 1 2" % author
|
print "committer %s <a@b> %s +0000" % (author, epoch)
|
||||||
print "data <<EOT"
|
print "data <<EOT"
|
||||||
for l in log:
|
for l in log:
|
||||||
print l[:len(l) - 1]
|
print l[:len(l) - 1]
|
||||||
@ -165,3 +167,5 @@ for change in changes:
|
|||||||
|
|
||||||
print ""
|
print ""
|
||||||
|
|
||||||
|
sys.stderr.write("\n")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user