Merge branch 'va/p4-client-path'
git p4 attempts to better handle branches in Perforce. * va/p4-client-path: git-p4: improve client path detection when branches are used t9801: check git-p4's branch detection with client spec enabled
This commit is contained in:
commit
0495983679
13
git-p4.py
13
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:
|
||||
@ -1653,7 +1655,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:
|
||||
|
@ -504,6 +504,112 @@ test_expect_success 'use-client-spec detect-branches skips files in branches' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'restart p4d' '
|
||||
kill_p4d &&
|
||||
start_p4d
|
||||
'
|
||||
|
||||
#
|
||||
# 1: //depot/branch1/base/file1
|
||||
# //depot/branch1/base/file2
|
||||
# //depot/branch1/base/dir/sub_file1
|
||||
# 2: integrate //depot/branch1/base/... -> //depot/branch2/base/...
|
||||
# 3: //depot/branch1/base/file3
|
||||
# 4: //depot/branch1/base/file2 (edit)
|
||||
# 5: integrate //depot/branch1/base/... -> //depot/branch3/base/...
|
||||
#
|
||||
# Note: the client view removes the "base" folder from the workspace
|
||||
# and moves sub_file1 one level up.
|
||||
test_expect_success 'add simple p4 branches with common base folder on each branch' '
|
||||
(
|
||||
cd "$cli" &&
|
||||
client_view "//depot/branch1/base/... //client/branch1/..." \
|
||||
"//depot/branch1/base/dir/sub_file1 //client/branch1/sub_file1" \
|
||||
"//depot/branch2/base/... //client/branch2/..." \
|
||||
"//depot/branch3/base/... //client/branch3/..." &&
|
||||
mkdir -p branch1 &&
|
||||
cd branch1 &&
|
||||
echo file1 >file1 &&
|
||||
echo file2 >file2 &&
|
||||
mkdir dir &&
|
||||
echo sub_file1 >sub_file1 &&
|
||||
p4 add file1 file2 sub_file1 &&
|
||||
p4 submit -d "Create branch1" &&
|
||||
p4 integrate //depot/branch1/base/... //depot/branch2/base/... &&
|
||||
p4 submit -d "Integrate branch2 from branch1" &&
|
||||
echo file3 >file3 &&
|
||||
p4 add file3 &&
|
||||
p4 submit -d "add file3 in branch1" &&
|
||||
p4 open file2 &&
|
||||
echo update >>file2 &&
|
||||
p4 submit -d "update file2 in branch1" &&
|
||||
p4 integrate //depot/branch1/base/... //depot/branch3/base/... &&
|
||||
p4 submit -d "Integrate branch3 from branch1"
|
||||
)
|
||||
'
|
||||
|
||||
# Configure branches through git-config and clone them.
|
||||
# All files are tested to make sure branches were cloned correctly.
|
||||
# Finally, make an update to branch1 on P4 side to check if it is imported
|
||||
# correctly by git p4.
|
||||
# git p4 is expected to use the client view to also not include the common
|
||||
# "base" folder in the imported directory structure.
|
||||
test_expect_success 'git p4 clone simple branches with base folder on server side' '
|
||||
test_create_repo "$git" &&
|
||||
(
|
||||
cd "$git" &&
|
||||
git config git-p4.branchList branch1:branch2 &&
|
||||
git config --add git-p4.branchList branch1:branch3 &&
|
||||
git p4 clone --dest=. --use-client-spec --detect-branches //depot@all &&
|
||||
git log --all --graph --decorate --stat &&
|
||||
git reset --hard p4/depot/branch1 &&
|
||||
test -f file1 &&
|
||||
test -f file2 &&
|
||||
test -f file3 &&
|
||||
test -f sub_file1 &&
|
||||
grep update file2 &&
|
||||
git reset --hard p4/depot/branch2 &&
|
||||
test -f file1 &&
|
||||
test -f file2 &&
|
||||
test ! -f file3 &&
|
||||
test -f sub_file1 &&
|
||||
! grep update file2 &&
|
||||
git reset --hard p4/depot/branch3 &&
|
||||
test -f file1 &&
|
||||
test -f file2 &&
|
||||
test -f file3 &&
|
||||
test -f sub_file1 &&
|
||||
grep update file2 &&
|
||||
cd "$cli" &&
|
||||
cd branch1 &&
|
||||
p4 edit file2 &&
|
||||
echo file2_ >>file2 &&
|
||||
p4 submit -d "update file2 in branch1" &&
|
||||
cd "$git" &&
|
||||
git reset --hard p4/depot/branch1 &&
|
||||
git p4 rebase &&
|
||||
grep file2_ file2
|
||||
)
|
||||
'
|
||||
|
||||
# Now update a file in one of the branches in git and submit to P4
|
||||
test_expect_success 'Update a file in git side and submit to P4 using client view' '
|
||||
test_when_finished cleanup_git &&
|
||||
(
|
||||
cd "$git" &&
|
||||
git reset --hard p4/depot/branch1 &&
|
||||
echo "client spec" >> file1 &&
|
||||
git add -u . &&
|
||||
git commit -m "update file1 in branch1" &&
|
||||
git config git-p4.skipSubmitEdit true &&
|
||||
git p4 submit --verbose &&
|
||||
cd "$cli" &&
|
||||
p4 sync ... &&
|
||||
cd branch1 &&
|
||||
grep "client spec" file1
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
Loading…
Reference in New Issue
Block a user