git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 10/14] git p4: rearrange self.initialParent use

From
PWPete Wyckoff <pw@padd.com>
Date
Jan 15, 2013, 00:47 UTC
Message-ID
<1358210828-2369-11-git-send-email-pw@padd.com>
In-Reply-To
<1358210828-2369-1-git-send-email-pw@padd.com>

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>
---
 git-p4.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 5dcb527..9b07ddd 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2689,6 +2689,7 @@ class P4Sync(Command, P4UserMap):
                     files = self.extractFilesFromCommit(description)
                     self.commit(description, files, self.branch,
                                 self.initialParent)
+                    # only needed once, to connect to the previous commit
                     self.initialParent = ""
             except IOError:
                 print self.gitError.read()
@@ -2754,7 +2755,6 @@ class P4Sync(Command, P4UserMap):
     def run(self, args):
         self.depotPaths = []
         self.changeRange = ""
-        self.initialParent = ""
         self.previousDepotPaths = []
         self.hasOrigin = False
 
@@ -2842,8 +2842,6 @@ class P4Sync(Command, P4UserMap):
             if p4Change > 0:
                 self.depotPaths = sorted(self.previousDepotPaths)
                 self.changeRange = "@%s,#head" % p4Change
-                if not self.detectBranches:
-                    self.initialParent = parseRevision(self.branch)
                 if not self.silent and not self.detectBranches:
                     print "Performing incremental import into %s git branch" % self.branch
 
@@ -2988,6 +2986,14 @@ class P4Sync(Command, P4UserMap):
 
                 self.updatedBranches = set()
 
+                if not self.detectBranches:
+                    if args:
+                        # start a new branch
+                        self.initialParent = ""
+                    else:
+                        # build on a previous revision
+                        self.initialParent = parseRevision(self.branch)
+
                 self.importChanges(changes)
 
                 if not self.silent:
-- 
1.8.1.350.gdbf6fd0
Previous: Pete WyckoffNext: Pete Wyckoff
Message 11 of 15 in “git p4 branch handling fixes”
  1. 00/14 git p4 branch handling fixesPete Wyckoff, Jan 15, 2013
  2. 01/14 git p4: test sync/clone --branch behaviorPete Wyckoff, Jan 15, 2013
  3. 02/14 git p4: rearrange and simplify hasOrigin handlingPete Wyckoff, Jan 15, 2013
  4. 03/14 git p4: add comments to p4BranchesInGitPete Wyckoff, Jan 15, 2013
  5. 04/14 git p4: inline listExistingP4GitBranchesPete Wyckoff, Jan 15, 2013
  6. 05/14 git p4: create p4/HEAD on initial clonePete Wyckoff, Jan 15, 2013
  7. 06/14 git p4: verify expected refs in clone --bare testPete Wyckoff, Jan 15, 2013
  8. 07/14 git p4: clone --branch should checkout masterPete Wyckoff, Jan 15, 2013
  9. 08/14 git p4 doc: fix branch detection examplePete Wyckoff, Jan 15, 2013
  10. 09/14 git p4: allow short ref names to --branchPete Wyckoff, Jan 15, 2013
  11. 10/14 git p4: rearrange self.initialParent usePete Wyckoff, Jan 15, 2013
  12. 11/14 git p4: fail gracefully on sync with no master branchPete Wyckoff, Jan 15, 2013
  13. 12/14 git p4: fix sync --branch when no master branchPete Wyckoff, Jan 15, 2013
  14. 13/14 git p4 test: keep P4CLIENT changes inside subshellsPete Wyckoff, Jan 15, 2013
  15. 14/14 git p4: fix submit when no master branchPete Wyckoff, Jan 15, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.