{"thread":{"id":"39113","subject":"[PATCH V2 0/2] git-p4: improve client path detection with branches used","startedAt":"2015-04-19T10:56:47Z","lastAt":"2015-04-21T07:10:05Z","messageCount":7,"participants":["Vitor Antunes","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"259642","messageId":"1429441009-17775-1-git-send-email-vitor.hda@gmail.com","threadId":"39113","inReplyTo":null,"subject":"[PATCH V2 0/2] git-p4: improve client path detection with branches used","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2015-04-19T10:56:47Z","receivedAt":"2015-04-19T10:56:47Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Robustness improvement in regards to previous patches, both in the test case and\ngit-p4 functionality.\n\n1. Test case now includes a mapped sub-file, to guarantee that git-p4 copes with\n   such client view.\n\n2. git-p4 now searches for paths starting with the branch's depot path and\n   ending with \"/...\" to guarantee that the correct client side path is\n   identified.\n\nVitor Antunes (2):\n  t9801: check git-p4's branch detection and client view together\n  git-p4: improve client path detection when branches are used\n\n git-p4.py                |   13 ++++--\n t/t9801-git-p4-branch.sh |  106 ++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 115 insertions(+), 4 deletions(-)\n\n-- \n1.7.10.4\n"},{"id":"259643","messageId":"1429441009-17775-2-git-send-email-vitor.hda@gmail.com","threadId":"39113","inReplyTo":"1429441009-17775-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH V2 1/2] t9801: check git-p4's branch detection and client view together","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2015-04-19T10:56:48Z","receivedAt":"2015-04-19T10:56:48Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Add failing scenario where branch detection is enabled together with\nuse client view. In this specific scenario git-p4 will break when the\nperforce client view removes part of the depot path.\n\nThe test case also includes an extra sub-file mapping to enforce\nrobustness check on git-p4 implementation.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t9801-git-p4-branch.sh |  106 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 106 insertions(+)\n\ndiff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh\nindex 2bf142d..36a7f51 100755\n--- a/t/t9801-git-p4-branch.sh\n+++ b/t/t9801-git-p4-branch.sh\n@@ -504,6 +504,112 @@ test_expect_success 'use-client-spec detect-branches skips files in branches' '\n \t)\n '\n \n+test_expect_success 'restart p4d' '\n+\tkill_p4d &&\n+\tstart_p4d\n+'\n+\n+#\n+# 1: //depot/branch1/base/file1\n+#    //depot/branch1/base/file2\n+#    //depot/branch1/base/dir/sub_file1\n+# 2: integrate //depot/branch1/base/... -> //depot/branch2/base/...\n+# 3: //depot/branch1/base/file3\n+# 4: //depot/branch1/base/file2 (edit)\n+# 5: integrate //depot/branch1/base/... -> //depot/branch3/base/...\n+#\n+# Note: the client view removes the \"base\" folder from the workspace\n+#       and moves sub_file1 one level up.\n+test_expect_success 'add simple p4 branches with common base folder on each branch' '\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\tclient_view \"//depot/branch1/base/... //client/branch1/...\" \\\n+\t\t\t    \"//depot/branch1/base/dir/sub_file1 //client/branch1/sub_file1\" \\\n+\t\t\t    \"//depot/branch2/base/... //client/branch2/...\" \\\n+\t\t\t    \"//depot/branch3/base/... //client/branch3/...\" &&\n+\t\tmkdir -p branch1 &&\n+\t\tcd branch1 &&\n+\t\techo file1 >file1 &&\n+\t\techo file2 >file2 &&\n+\t\tmkdir dir &&\n+\t\techo sub_file1 >sub_file1 &&\n+\t\tp4 add file1 file2 sub_file1 &&\n+\t\tp4 submit -d \"Create branch1\" &&\n+\t\tp4 integrate //depot/branch1/base/... //depot/branch2/base/... &&\n+\t\tp4 submit -d \"Integrate branch2 from branch1\" &&\n+\t\techo file3 >file3 &&\n+\t\tp4 add file3 &&\n+\t\tp4 submit -d \"add file3 in branch1\" &&\n+\t\tp4 open file2 &&\n+\t\techo update >>file2 &&\n+\t\tp4 submit -d \"update file2 in branch1\" &&\n+\t\tp4 integrate //depot/branch1/base/... //depot/branch3/base/... &&\n+\t\tp4 submit -d \"Integrate branch3 from branch1\"\n+\t)\n+'\n+\n+# Configure branches through git-config and clone them.\n+# All files are tested to make sure branches were cloned correctly.\n+# Finally, make an update to branch1 on P4 side to check if it is imported\n+# correctly by git p4.\n+# git p4 is expected to use the client view to also not include the common\n+# \"base\" folder in the imported directory structure.\n+test_expect_success 'git p4 clone simple branches with base folder on server side' '\n+\ttest_create_repo \"$git\" &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit config git-p4.branchList branch1:branch2 &&\n+\t\tgit config --add git-p4.branchList branch1:branch3 &&\n+\t\tgit p4 clone --dest=. --use-client-spec  --detect-branches //depot@all &&\n+\t\tgit log --all --graph --decorate --stat &&\n+\t\tgit reset --hard p4/depot/branch1 &&\n+\t\ttest -f file1 &&\n+\t\ttest -f file2 &&\n+\t\ttest -f file3 &&\n+\t\ttest -f sub_file1 &&\n+\t\tgrep update file2 &&\n+\t\tgit reset --hard p4/depot/branch2 &&\n+\t\ttest -f file1 &&\n+\t\ttest -f file2 &&\n+\t\ttest ! -f file3 &&\n+\t\ttest -f sub_file1 &&\n+\t\t! grep update file2 &&\n+\t\tgit reset --hard p4/depot/branch3 &&\n+\t\ttest -f file1 &&\n+\t\ttest -f file2 &&\n+\t\ttest -f file3 &&\n+\t\ttest -f sub_file1 &&\n+\t\tgrep update file2 &&\n+\t\tcd \"$cli\" &&\n+\t\tcd branch1 &&\n+\t\tp4 edit file2 &&\n+\t\techo file2_ >>file2 &&\n+\t\tp4 submit -d \"update file2 in branch1\" &&\n+\t\tcd \"$git\" &&\n+\t\tgit reset --hard p4/depot/branch1 &&\n+\t\tgit p4 rebase &&\n+\t\tgrep file2_ file2\n+\t)\n+'\n+\n+# Now update a file in one of the branches in git and submit to P4\n+test_expect_failure 'Update a file in git side and submit to P4 using client view' '\n+\ttest_when_finished cleanup_git &&\n+\t(\n+\t\tcd \"$git\" &&\n+\t\tgit reset --hard p4/depot/branch1 &&\n+\t\techo \"client spec\" >> file1 &&\n+\t\tgit add -u . &&\n+\t\tgit commit -m \"update file1 in branch1\" &&\n+\t\tgit config git-p4.skipSubmitEdit true &&\n+\t\tgit p4 submit --verbose &&\n+\t\tcd \"$cli\" &&\n+\t\tp4 sync ... &&\n+\t\tcd branch1 &&\n+\t\tgrep \"client spec\" file1\n+\t)\n+'\n+\n test_expect_success 'kill p4d' '\n \tkill_p4d\n '\n-- \n1.7.10.4\n"},{"id":"259644","messageId":"1429441009-17775-3-git-send-email-vitor.hda@gmail.com","threadId":"39113","inReplyTo":"1429441009-17775-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH V2 2/2] git-p4: improve client path detection when branches are used","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2015-04-19T10:56:49Z","receivedAt":"2015-04-19T10:56:49Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"A client view can be used to remap folder locations in the\nworkspace. To support this when branch detection is enabled,\nit is necessary to get the client path through \"p4 where\".\n\nThis patch does two things to achieve this:\n\n 1. Force usage of \"p4 where\" when P4 branches exist in the\n    git repository.\n\n 2. Search for mappings that contain the depot path, instead\n    of requiring an exact match. To guarantee robustness,\n    paths only match if ending in \"/...\".\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-p4.py                |   13 +++++++++----\n t/t9801-git-p4-branch.sh |    2 +-\n 2 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex 549022e..34e4fdd 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -502,12 +502,14 @@ def p4Cmd(cmd):\n def p4Where(depotPath):\n     if not depotPath.endswith(\"/\"):\n         depotPath += \"/\"\n-    depotPath = depotPath + \"...\"\n-    outputList = p4CmdList([\"where\", depotPath])\n+    depotPathLong = depotPath + \"...\"\n+    outputList = p4CmdList([\"where\", depotPathLong])\n     output = None\n     for entry in outputList:\n         if \"depotFile\" in entry:\n-            if entry[\"depotFile\"] == depotPath:\n+            # Search for the base client side depot path, as long as it starts with the branch's P4 path.\n+            # The base path always ends with \"/...\".\n+            if entry[\"depotFile\"].find(depotPath) == 0 and entry[\"depotFile\"][-4:] == \"/...\":\n                 output = entry\n                 break\n         elif \"data\" in entry:\n@@ -1627,7 +1629,10 @@ class P4Submit(Command, P4UserMap):\n         if self.useClientSpec:\n             self.clientSpecDirs = getClientSpec()\n \n-        if self.useClientSpec:\n+        # Check for the existance of P4 branches\n+        branchesDetected = (len(p4BranchesInGit().keys()) > 1)\n+\n+        if self.useClientSpec and not branchesDetected:\n             # all files are relative to the client spec\n             self.clientPath = getClientRoot()\n         else:\ndiff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh\nindex 36a7f51..0aafd03 100755\n--- a/t/t9801-git-p4-branch.sh\n+++ b/t/t9801-git-p4-branch.sh\n@@ -593,7 +593,7 @@ test_expect_success 'git p4 clone simple branches with base folder on server sid\n '\n \n # Now update a file in one of the branches in git and submit to P4\n-test_expect_failure 'Update a file in git side and submit to P4 using client view' '\n+test_expect_success 'Update a file in git side and submit to P4 using client view' '\n \ttest_when_finished cleanup_git &&\n \t(\n \t\tcd \"$git\" &&\n-- \n1.7.10.4\n"},{"id":"259659","messageId":"xmqqtwwbmk16.fsf@gitster.dls.corp.google.com","threadId":"39113","inReplyTo":"1429441009-17775-2-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH V2 1/2] t9801: check git-p4's branch detection and client view together","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-04-20T05:43:49Z","receivedAt":"2015-04-20T05:43:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Vitor Antunes <vitor.hda@gmail.com> writes:\n\n> Add failing scenario where branch detection is enabled together with\n> use client view. In this specific scenario git-p4 will break when the\n> perforce client view removes part of the depot path.\n\nI somehow cannot parse \"together with use client view\", especially\nthe word \"use\".  Is it \"user client view\" or something (I am not\nfamiliar with p4 lingo), or perhaps \"use of client view\"?\n"},{"id":"259713","messageId":"48EB5BF2-166D-45F5-9573-0C9E16CAC2B9@gmail.com","threadId":"39113","inReplyTo":"xmqqtwwbmk16.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH V2 1/2] t9801: check git-p4's branch detection and client view together","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2015-04-20T22:25:17Z","receivedAt":"2015-04-20T22:25:17Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On April 20, 2015 6:43:49 AM GMT+01:00, Junio C Hamano <gitster@pobox.com> wrote:\n>Vitor Antunes <vitor.hda@gmail.com> writes:\n>\n>> Add failing scenario where branch detection is enabled together with\n>> use client view. In this specific scenario git-p4 will break when the\n>> perforce client view removes part of the depot path.\n>\n>I somehow cannot parse \"together with use client view\", especially\n>the word \"use\".  Is it \"user client view\" or something (I am not\n>familiar with p4 lingo), or perhaps \"use of client view\"?\n\nI meant \"spec\" instead of \"view\". As in - -use-client-spec.\n\nIn perforce you need to configure your workspace using a client specification.\nOne of the configured values is the client view, which maps files/folders in the\nserver to locations in your local workspace. What I'm trying to fix with these\npatches is the ability of git-p4 to process the client view definition through\nthe use of \"p4 where\" to determine the correct location of the local files, such\nthat it is able to apply the necessary patches for submission to the perforce\nserver.\n\nWhile thinking about client views I completely forgot that the git-p4 argument\nthat enables thos feature uses \"spec\" and not \"view\".\n"},{"id":"259715","messageId":"xmqq4moaju6c.fsf@gitster.dls.corp.google.com","threadId":"39113","inReplyTo":"48EB5BF2-166D-45F5-9573-0C9E16CAC2B9@gmail.com","subject":"Re: [PATCH V2 1/2] t9801: check git-p4's branch detection and client view together","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-04-20T22:45:15Z","receivedAt":"2015-04-20T22:45:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Vitor Antunes <vitor.hda@gmail.com> writes:\n\n> On April 20, 2015 6:43:49 AM GMT+01:00, Junio C Hamano <gitster@pobox.com> wrote:\n>>Vitor Antunes <vitor.hda@gmail.com> writes:\n>>\n>>> Add failing scenario where branch detection is enabled together with\n>>> use client view. In this specific scenario git-p4 will break when the\n>>> perforce client view removes part of the depot path.\n>>\n>>I somehow cannot parse \"together with use client view\", especially\n>>the word \"use\".  Is it \"user client view\" or something (I am not\n>>familiar with p4 lingo), or perhaps \"use of client view\"?\n>\n> I meant \"spec\" instead of \"view\". As in - -use-client-spec.\n>\n> In perforce you need to configure your workspace using a client specification.\n> One of the configured values is the client view, which maps files/folders in the\n> server to locations in your local workspace. What I'm trying to fix with these\n> patches is the ability of git-p4 to process the client view definition through\n> the use of \"p4 where\" to determine the correct location of the local files, such\n> that it is able to apply the necessary patches for submission to the perforce\n> server.\n>\n> While thinking about client views I completely forgot that the git-p4 argument\n> that enables thos feature uses \"spec\" and not \"view\".\n\nSo,... what's the conclusion?  Should the log message be written\nlike this perhaps?\n\n    t9801: check git-p4's branch detection and client spec together\n    \n    Add failing scenario where branch detection is enabled together\n    with use of client spec.  In this specific scenario git-p4 will\n    break when the perforce client spec removes part of the depot\n    path.\n    \n    The test case also includes an extra sub-file mapping to enforce\n    robustness check on git-p4 implementation.\n    \n    Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n"},{"id":"259726","messageId":"B0C2FE2B-74B5-40CE-A818-B28E83AB4D2A@gmail.com","threadId":"39113","inReplyTo":"xmqq4moaju6c.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH V2 1/2] t9801: check git-p4's branch detection and client view together","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2015-04-21T07:10:05Z","receivedAt":"2015-04-21T07:10:05Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On April 20, 2015 11:45:15 PM GMT+01:00, Junio C Hamano <gitster@pobox.com> wrote:\n>Vitor Antunes <vitor.hda@gmail.com> writes:\n>\n>> On April 20, 2015 6:43:49 AM GMT+01:00, Junio C Hamano\n><gitster@pobox.com> wrote:\n>>>Vitor Antunes <vitor.hda@gmail.com> writes:\n>>>\n>>>> Add failing scenario where branch detection is enabled together\n>with\n>>>> use client view. In this specific scenario git-p4 will break when\n>the\n>>>> perforce client view removes part of the depot path.\n>>>\n>>>I somehow cannot parse \"together with use client view\", especially\n>>>the word \"use\".  Is it \"user client view\" or something (I am not\n>>>familiar with p4 lingo), or perhaps \"use of client view\"?\n>>\n>> I meant \"spec\" instead of \"view\". As in - -use-client-spec.\n>>\n>> In perforce you need to configure your workspace using a client\n>specification.\n>> One of the configured values is the client view, which maps\n>files/folders in the\n>> server to locations in your local workspace. What I'm trying to fix\n>with these\n>> patches is the ability of git-p4 to process the client view\n>definition through\n>> the use of \"p4 where\" to determine the correct location of the local\n>files, such\n>> that it is able to apply the necessary patches for submission to the\n>perforce\n>> server.\n>>\n>> While thinking about client views I completely forgot that the git-p4\n>argument\n>> that enables thos feature uses \"spec\" and not \"view\".\n>\n>So,... what's the conclusion?  Should the log message be written\n>like this perhaps?\n>\n>    t9801: check git-p4's branch detection and client spec together\n>    \n>    Add failing scenario where branch detection is enabled together\n>    with use of client spec.  In this specific scenario git-p4 will\n>    break when the perforce client spec removes part of the depot\n>    path.\n>    \n>    The test case also includes an extra sub-file mapping to enforce\n>    robustness check on git-p4 implementation.\n>    \n>    Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\n>    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nUnfortunately at the moment I have limited computer access at\nhome. I will, obviously, update the descriptions as soon as\npossible.\n"}]}