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

[PATCH V2 2/2] git-p4: improve client path detection when branches are used

From
Vitor Antunes <vitor.hda@gmail.com>
Date
Apr 19, 2015, 10:56 UTC
Message-ID
<1429441009-17775-3-git-send-email-vitor.hda@gmail.com>
In-Reply-To
<1429441009-17775-1-git-send-email-vitor.hda@gmail.com>

A client view can be used to remap folder locations in the workspace. To support this when branch detection is enabled, it is necessary to get the client path through "p4 where".

This patch does two things to achieve this:
 1. Force usage of "p4 where" when P4 branches exist in the
    git repository.
 2. Search for mappings that contain the depot path, instead
    of requiring an exact match. To guarantee robustness,
    paths only match if ending in "/...".
Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-p4.py                |   13 +++++++++----
 t/t9801-git-p4-branch.sh |    2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 549022e..34e4fdd 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -502,12 +502,14 @@ def p4Cmd(cmd):
 def p4Where(depotPath):
     if not depotPath.endswith("/"):
         depotPath += "/"
-    depotPath = depotPath + "..."
-    outputList = p4CmdList(["where", depotPath])
+    depotPathLong = depotPath + "..."
+    outputList = p4CmdList(["where", depotPathLong])
     output = None
     for entry in outputList:
         if "depotFile" in entry:
-            if entry["depotFile"] == depotPath:
+            # Search for the base client side depot path, as long as it starts with the branch's P4 path.
+            # The base path always ends with "/...".
+            if entry["depotFile"].find(depotPath) == 0 and entry["depotFile"][-4:] == "/...":
                 output = entry
                 break
         elif "data" in entry:
@@ -1627,7 +1629,10 @@ class P4Submit(Command, P4UserMap):
         if self.useClientSpec:
             self.clientSpecDirs = getClientSpec()
 
-        if self.useClientSpec:
+        # Check for the existance of P4 branches
+        branchesDetected = (len(p4BranchesInGit().keys()) > 1)
+
+        if self.useClientSpec and not branchesDetected:
             # all files are relative to the client spec
             self.clientPath = getClientRoot()
         else:
diff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh
index 36a7f51..0aafd03 100755
--- a/t/t9801-git-p4-branch.sh
+++ b/t/t9801-git-p4-branch.sh
@@ -593,7 +593,7 @@ test_expect_success 'git p4 clone simple branches with base folder on server sid
 '
 
 # Now update a file in one of the branches in git and submit to P4
-test_expect_failure 'Update a file in git side and submit to P4 using client view' '
+test_expect_success 'Update a file in git side and submit to P4 using client view' '
 	test_when_finished cleanup_git &&
 	(
 		cd "$git" &&
-- 
1.7.10.4
Previous: Vitor Antunes
Message 7 of 7 in “git-p4: improve client path detection with branches used”
  1. 0/2 git-p4: improve client path detection with branches usedVitor Antunes, Apr 19, 2015
  2. 1/2 t9801: check git-p4's branch detection and client view togetherVitor Antunes, Apr 19, 2015
  3. Junio C HamanoApr 20, 2015
  4. Vitor AntunesApr 20, 2015
  5. Junio C HamanoApr 20, 2015
  6. Vitor AntunesApr 21, 2015
  7. 2/2 git-p4: improve client path detection when branches are usedVitor Antunes, Apr 19, 2015

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.