git p4: rearrange self.initialParent use
This was set in a couple of places, both of which were very far away from its use. Move it a bit closer to importChanges(), and add some comments. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pete Wyckoff committed
Jan 14, 2013 at 19:47 UTC
47497844442615b6e5cd5f9b9e1552e8ba84ce71
1 file changed
+9
-3
git-p4.py
+9
-3
@@ -2683,6 +2683,7 @@ class P4Sync(Command, P4UserMap):
2683
files = self.extractFilesFromCommit(description)
2684
self.commit(description, files, self.branch,
2685
self.initialParent)
2686
+ # only needed once, to connect to the previous commit
2687
self.initialParent = ""
2688
except IOError:
2689
print self.gitError.read()
@@ -2748,7 +2749,6 @@ class P4Sync(Command, P4UserMap):
2749
def run(self, args):
2750
self.depotPaths = []
2751
self.changeRange = ""
2751
- self.initialParent = ""
2752
self.previousDepotPaths = []
2753
self.hasOrigin = False
2754
@@ -2836,8 +2836,6 @@ class P4Sync(Command, P4UserMap):
2836
if p4Change > 0:
2837
self.depotPaths = sorted(self.previousDepotPaths)
2838
self.changeRange = "@%s,#head" % p4Change
2839
- if not self.detectBranches:
2840
- self.initialParent = parseRevision(self.branch)
2839
if not self.silent and not self.detectBranches:
2840
print "Performing incremental import into %s git branch" % self.branch
2841
@@ -2982,6 +2980,14 @@ class P4Sync(Command, P4UserMap):
2980
2981
self.updatedBranches = set()
2982
2983
+ if not self.detectBranches:
2984
+ if args:
2985
+ # start a new branch
2986
+ self.initialParent = ""
2987
+ else:
2988
+ # build on a previous revision
2989
+ self.initialParent = parseRevision(self.branch)
2990
+
2991
self.importChanges(changes)
2992
2993
if not self.silent: