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

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

From
Vitor Antunes <vitor.hda@gmail.com>
Date
Mar 28, 2015, 12:28 UTC
Message-ID
<1427545730-3563-3-git-send-email-vitor.hda@gmail.com>
In-Reply-To
<1427545730-3563-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.
Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
---
 git-p4.py                |   11 +++++++----
 t/t9801-git-p4-branch.sh |    2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 549022e..6954549 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -502,12 +502,12 @@ 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:
+            if entry["depotFile"].find(depotPath) >= 0:
                 output = entry
                 break
         elif "data" in entry:
@@ -1627,7 +1627,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 2f0361a..4fe4e18 100755
--- a/t/t9801-git-p4-branch.sh
+++ b/t/t9801-git-p4-branch.sh
@@ -585,7 +585,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 AntunesNext: Vitor Antunes
Message 3 of 18 in “git-p4: Improve client path detection”
  1. 0/2 git-p4: Improve client path detectionVitor Antunes, Mar 28, 2015
  2. 1/2 git-p4: Check branch detection and client view togetherVitor Antunes, Mar 28, 2015
  3. 2/2 git-p4: Improve client path detection when branches are usedVitor Antunes, Mar 28, 2015
  4. t9814: Guarantee only one source exists in git-p4 copy testsVitor Antunes, Mar 29, 2015
  5. Junio C HamanoMar 30, 2015
  6. Luke DiamandMar 31, 2015
  7. t9814: Guarantee only one source exists in git-p4 copy testsVitor Antunes, Mar 31, 2015
  8. Luke DiamandApr 4, 2015
  9. Junio C HamanoApr 4, 2015
  10. t9814: Guarantee only one source exists in git-p4 copy testsVitor Antunes, Apr 5, 2015
  11. Luke DiamandApr 5, 2015
  12. Vitor AntunesApr 5, 2015
  13. Junio C HamanoApr 13, 2015
  14. Vitor AntunesApr 18, 2015
  15. git-p4: Improve client path detection when branches are usedVitor Antunes, Apr 18, 2015
  16. Junio C HamanoApr 19, 2015
  17. Vitor AntunesApr 19, 2015
  18. Junio C HamanoApr 20, 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.