Simplify the incremental import by elimination the need for a temporary import branch.
It turns out that git fast-import can "resume" from an existing branch just fine. Signed-off-by: Simon Hausmann <hausmann@kde.org>
Simon Hausmann committed
Feb 1, 2007 at 08:23 UTC
f16255f559c96b8c5fb096b00c94a69f5fcc498f
1 file changed
+3
-18
contrib/fast-import/p4-fast-export.py
+3
-18
@@ -7,11 +7,7 @@
7
#
8
# TODO:
9
# - support integrations (at least p4i)
10
-# - support incremental imports
11
-# - create tags
12
-# - instead of reading all files into a variable try to pipe from
10
# - support p4 submit (hah!)
14
-# - don't hardcode the import to master
11
#
12
import os, string, sys, time
13
import marshal, popen2
@@ -26,8 +22,7 @@ if len(sys.argv) != 2:
22
print ""
23
sys.exit(1)
24
29
-master = "refs/heads/p4"
30
-branch = "refs/heads/p4-import"
25
+branch = "refs/heads/p4"
26
prefix = sys.argv[1]
27
changeRange = ""
28
try:
@@ -74,24 +69,18 @@ def getUserMap():
69
users = getUserMap()
70
topMerge = ""
71
77
-incremental = 0
78
-# try incremental import
72
if len(changeRange) == 0:
73
try:
81
- sout, sin, serr = popen2.popen3("git-name-rev --tags `git-rev-parse %s`" % master)
74
+ sout, sin, serr = popen2.popen3("git-name-rev --tags `git-rev-parse %s`" % branch)
75
output = sout.read()
76
tagIdx = output.index(" tags/p4/")
77
caretIdx = output.index("^")
78
revision = int(output[tagIdx + 9 : caretIdx]) + 1
79
changeRange = "@%s,#head" % revision
87
- topMerge = os.popen("git-rev-parse %s" % master).read()[:-1]
88
- incremental = 1
80
+ topMerge = os.popen("git-rev-parse %s" % branch).read()[:-1]
81
except:
82
pass
83
92
-if incremental == 0:
93
- branch = master
94
-
84
output = os.popen("p4 changes %s...%s" % (prefix, changeRange)).readlines()
85
86
changes = []
@@ -181,8 +170,4 @@ gitStream.close()
170
gitOutput.close()
171
gitError.close()
172
184
-if incremental == 1:
185
- os.popen("git rebase p4-import p4")
186
- os.popen("git branch -d p4-import")
187
-
173
print ""