@matheusbsbs / matheus-bagliano / commits / 930d3cc94e
Fork 0

When trying to map p4 integrations to git merges just record it as a single merge with the newest p4 change as secondary parent.

Signed-off-by: Simon Hausmann <simon@lst.de>

Simon Hausmann committed Feb 12, 2007 at 22:05 UTC 930d3cc94e98ccecfa8762ef79f7c29af4a72769
1 file changed +23 -7
contrib/fast-import/p4-fast-export.py
+23 -7
@@ -172,7 +172,8 @@ def commit(details, files, branch, branchPrefix):
172 gitStream.write("from %s\n" % initialParent)
173 initialParent = ""
174
175 - mergedBranches = set()
175 + #mergedBranches = set()
176 + merge = 0
177
178 for file in files:
179 path = file["path"]
@@ -202,13 +203,28 @@ def commit(details, files, branch, branchPrefix):
203 if source.startswith(branchPrefix):
204 continue
205
205 - relPath = source[len(globalPrefix):]
206 + lastSourceRev = log["erev0,0"]
207
207 - for branch in knownBranches:
208 - if relPath.startswith(branch) and branch not in mergedBranches:
209 - gitStream.write("merge refs/heads/%s\n" % branch)
210 - mergedBranches.add(branch)
211 - break
208 + sourceLog = p4CmdList("filelog -m 1 \"%s%s\"" % (source, lastSourceRev))
209 + if len(sourceLog) != 1:
210 + print "eek! I got confused by the source filelog of %s%s" % (source, lastSourceRev)
211 + sys.exit(1);
212 + sourceLog = sourceLog[0]
213 +
214 + change = int(sourceLog["change0"])
215 + if change > merge:
216 + merge = change
217 +
218 +# relPath = source[len(globalPrefix):]
219 +#
220 +# for branch in knownBranches:
221 +# if relPath.startswith(branch) and branch not in mergedBranches:
222 +# gitStream.write("merge refs/heads/%s\n" % branch)
223 +# mergedBranches.add(branch)
224 +# break
225 +
226 + if merge != 0:
227 + gitStream.write("merge :%s\n" % merge)
228
229 for file in files:
230 path = file["path"]