@@ -2041,10 +2041,9 @@ def streamTag(self, gitStream, labelName, labelDetails, commit, epoch):
2041
2041
gitStream .write (description )
2042
2042
gitStream .write ("\n " )
2043
2043
2044
- def commit (self , details , files , branch , branchPrefixes , parent = "" ):
2044
+ def commit (self , details , files , branch , parent = "" ):
2045
2045
epoch = details ["time" ]
2046
2046
author = details ["user" ]
2047
- self .branchPrefixes = branchPrefixes
2048
2047
2049
2048
if self .verbose :
2050
2049
print "commit into %s" % branch
@@ -2053,7 +2052,7 @@ def commit(self, details, files, branch, branchPrefixes, parent = ""):
2053
2052
# create a commit.
2054
2053
new_files = []
2055
2054
for f in files :
2056
- if [p for p in branchPrefixes if p4PathStartsWith (f ['path' ], p )]:
2055
+ if [p for p in self . branchPrefixes if p4PathStartsWith (f ['path' ], p )]:
2057
2056
new_files .append (f )
2058
2057
else :
2059
2058
sys .stderr .write ("Ignoring file outside of prefix: %s\n " % f ['path' ])
@@ -2070,8 +2069,8 @@ def commit(self, details, files, branch, branchPrefixes, parent = ""):
2070
2069
2071
2070
self .gitStream .write ("data <<EOT\n " )
2072
2071
self .gitStream .write (details ["desc" ])
2073
- self .gitStream .write ("\n [git-p4: depot-paths = \" %s\" : change = %s"
2074
- % (',' .join ( branchPrefixes ), details ["change" ]))
2072
+ self .gitStream .write ("\n [git-p4: depot-paths = \" %s\" : change = %s" %
2073
+ (',' .join ( self . branchPrefixes ), details ["change" ]))
2075
2074
if len (details ['options' ]) > 0 :
2076
2075
self .gitStream .write (": options = %s" % details ['options' ])
2077
2076
self .gitStream .write ("]\n EOT\n \n " )
@@ -2094,7 +2093,7 @@ def commit(self, details, files, branch, branchPrefixes, parent = ""):
2094
2093
print "Change %s is labelled %s" % (change , labelDetails )
2095
2094
2096
2095
files = p4CmdList (["files" ] + ["%s...@%s" % (p , change )
2097
- for p in branchPrefixes ])
2096
+ for p in self . branchPrefixes ])
2098
2097
2099
2098
if len (files ) == len (labelRevisions ):
2100
2099
@@ -2405,6 +2404,7 @@ def importChanges(self, changes):
2405
2404
for branch in branches .keys ():
2406
2405
## HACK --hwn
2407
2406
branchPrefix = self .depotPaths [0 ] + branch + "/"
2407
+ self .branchPrefixes = [ branchPrefix ]
2408
2408
2409
2409
parent = ""
2410
2410
@@ -2449,19 +2449,19 @@ def importChanges(self, changes):
2449
2449
tempBranch = os .path .join (self .tempBranchLocation , "%d" % (change ))
2450
2450
if self .verbose :
2451
2451
print "Creating temporary branch: " + tempBranch
2452
- self .commit (description , filesForCommit , tempBranch , [ branchPrefix ] )
2452
+ self .commit (description , filesForCommit , tempBranch )
2453
2453
self .tempBranches .append (tempBranch )
2454
2454
self .checkpoint ()
2455
2455
blob = self .searchParent (parent , branch , tempBranch )
2456
2456
if blob :
2457
- self .commit (description , filesForCommit , branch , [ branchPrefix ], blob )
2457
+ self .commit (description , filesForCommit , branch , blob )
2458
2458
else :
2459
2459
if self .verbose :
2460
2460
print "Parent of %s not found. Committing into head of %s" % (branch , parent )
2461
- self .commit (description , filesForCommit , branch , [ branchPrefix ], parent )
2461
+ self .commit (description , filesForCommit , branch , parent )
2462
2462
else :
2463
2463
files = self .extractFilesFromCommit (description )
2464
- self .commit (description , files , self .branch , self . depotPaths ,
2464
+ self .commit (description , files , self .branch ,
2465
2465
self .initialParent )
2466
2466
self .initialParent = ""
2467
2467
except IOError :
@@ -2525,7 +2525,7 @@ def importHeadRevision(self, revision):
2525
2525
2526
2526
self .updateOptionDict (details )
2527
2527
try :
2528
- self .commit (details , self .extractFilesFromCommit (details ), self .branch , self . depotPaths )
2528
+ self .commit (details , self .extractFilesFromCommit (details ), self .branch )
2529
2529
except IOError :
2530
2530
print "IO error with git fast-import. Is your git version recent enough?"
2531
2531
print self .gitError .read ()
@@ -2683,6 +2683,9 @@ def run(self, args):
2683
2683
2684
2684
self .depotPaths = newPaths
2685
2685
2686
+ # --detect-branches may change this for each branch
2687
+ self .branchPrefixes = self .depotPaths
2688
+
2686
2689
self .loadUserMapFromCache ()
2687
2690
self .labels = {}
2688
2691
if self .detectLabels :
0 commit comments