{"thread":{"id":"28160","subject":"[PATCH/RFC 0/2] Search for parent commit in new branch import","startedAt":"2011-08-19T00:09:48Z","lastAt":"2011-08-27T23:32:01Z","messageCount":11,"participants":["Vitor Antunes","Pete Wyckoff"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"173820","messageId":"1313712590-26876-1-git-send-email-vitor.hda@gmail.com","threadId":"28160","inReplyTo":null,"subject":"[PATCH/RFC 0/2] Search for parent commit in new branch import","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-19T00:09:48Z","receivedAt":"2011-08-19T00:09:48Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"This is mostly a RFC/RFH (Request For Help;) regarding the code I used on this\npatch. I think that this is not a clean solution, but it shows the algorithm I\nwant to implement. The worst points are:\n\n1. Relies on a sleep() to avoid a race condition. I'm using 0.1s, but it still\n   fails sometimes, so it needs to be bigger.\n2. Requires the --force option of fast-import.\n\nTest case is included.\n\nThanks in advance to everyone who contributes.\n\nVitor Antunes (2):\n  git-p4: Search for parent commit on branch creation\n  git-p4: Add complex test case for branch import\n\n contrib/fast-import/git-p4 |   22 +++++++++++-\n t/t9800-git-p4.sh          |   77 ++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 97 insertions(+), 2 deletions(-)\n\n-- \n1.7.5.4\n"},{"id":"173822","messageId":"1313712590-26876-2-git-send-email-vitor.hda@gmail.com","threadId":"28160","inReplyTo":"1313712590-26876-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH/RFC 1/2] git-p4: Search for parent commit on branch creation","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-19T00:09:49Z","receivedAt":"2011-08-19T00:09:49Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"The new commit is applied sequentially to each blob of the parent branch. The\nfirst blob which results in a zero diff with the new commit is considered the\nparent commit. If none is found, then the commit is applied to the top of the\nparent branch.\nThis algorithm requires a checkpoint and a time.sleep() to be able to use\ndiff-tree, making it slower than what would be desirable. It also requires using\n--force argument of fast-import, leaving lots of trash commits when finished.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4 |   22 ++++++++++++++++++++--\n 1 files changed, 20 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex f622a38..0bced6d 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -1671,7 +1671,25 @@ class P4Sync(Command, P4UserMap):\n                             parent = self.initialParents[branch]\n                             del self.initialParents[branch]\n \n-                        self.commit(description, filesForCommit, branch, [branchPrefix], parent)\n+                        parentFound = 0\n+                        if len(parent) > 0:\n+                            self.gitStream.write(\"checkpoint\\n\\n\")\n+                            time.sleep(0.1)\n+                            for blob in read_pipe_lines(\"git rev-list --reverse --no-merges %s\" % parent):\n+                                blob = blob.strip()\n+                                self.gitStream.write(\"reset %s\\nfrom %s\\n\" % (branch, blob))\n+                                self.commit(description, filesForCommit, branch, [branchPrefix], blob)\n+                                self.gitStream.write(\"checkpoint\\n\\n\")\n+                                time.sleep(0.1)\n+                                if len( read_pipe(\"git diff-tree %s %s\" % (blob, branch)) ) == 0:\n+                                    parentFound = 1\n+                                    if self.verbose:\n+                                        print \"Found parent of %s in commit %s\" % (branch, blob)\n+                                    break\n+                        if not parentFound:\n+                            if self.verbose:\n+                                print \"Parent of %s not found. Committing into head of %s\" % (branch, parent)\n+                            self.commit(description, filesForCommit, branch, [branchPrefix], parent)\n                 else:\n                     files = self.extractFilesFromCommit(description)\n                     self.commit(description, files, self.branch, self.depotPaths,\n@@ -1948,7 +1966,7 @@ class P4Sync(Command, P4UserMap):\n \n         self.tz = \"%+03d%02d\" % (- time.timezone / 3600, ((- time.timezone % 3600) / 60))\n \n-        importProcess = subprocess.Popen([\"git\", \"fast-import\"],\n+        importProcess = subprocess.Popen([\"git\", \"fast-import\", \"--force\"],\n                                          stdin=subprocess.PIPE, stdout=subprocess.PIPE,\n                                          stderr=subprocess.PIPE);\n         self.gitOutput = importProcess.stdout\n-- \n1.7.5.4\n"},{"id":"173821","messageId":"1313712590-26876-3-git-send-email-vitor.hda@gmail.com","threadId":"28160","inReplyTo":"1313712590-26876-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-19T00:09:50Z","receivedAt":"2011-08-19T00:09:50Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Check if branches created from old changelists are correctly imported.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n t/t9800-git-p4.sh |   77 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 77 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex 15704d2..9f757d7 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -454,6 +454,83 @@ test_expect_success 'git-p4 clone simple branches' '\n \trm -rf \"$git\" && mkdir \"$git\"\n '\n \n+# Create a complex branch structure in P4 depot to check if they are correctly\n+# cloned. The branches are created from older changelists to check if git-p4 is\n+# able to correctly detect them.\n+# The final expected structure is:\n+# `branch1\n+# | `- file1\n+# | `- file2 (updated)\n+# | `- file3\n+# `branch2\n+# | `- file1\n+# | `- file2\n+# `branch3\n+# | `- file1\n+# | `- file2 (updated)\n+# | `- file3\n+# `branch4\n+# | `- file1\n+# | `- file2\n+# `branch5\n+#   `- file1\n+#   `- file2\n+#   `- file3\n+test_expect_success 'add p4 complex branches' '\n+\tcd \"$cli\" &&\n+\tchangelist=$(p4 changes -m1 //depot/... | cut -d \\  -f 2) &&\n+\tchangelist=$(($changelist - 5)) &&\n+\tp4 integrate //depot/branch1/...@$changelist //depot/branch4/... &&\n+\tp4 submit -d \"branch4\" &&\n+\tchangelist=$(($changelist + 2)) &&\n+\tp4 integrate //depot/branch1/...@$changelist //depot/branch5/... &&\n+\tp4 submit -d \"branch5\" &&\n+\tcd \"$TRASH_DIRECTORY\"\n+'\n+\n+# Configure branches through git-config and clone them. git-p4 will only be able\n+# to clone the original structure if it is able to detect the origin changelist\n+# of each branch.\n+test_expect_success 'git-p4 clone complex branches' '\n+\tgit init \"$git\" &&\n+\tcd \"$git\" &&\n+\tgit config git-p4.branchList branch1:branch2 &&\n+\tgit config --add git-p4.branchList branch1:branch3 &&\n+\tgit config --add git-p4.branchList branch1:branch4 &&\n+\tgit config --add git-p4.branchList branch1:branch5 &&\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\t\"$GITP4\" clone --dest=\"$git\" --detect-branches //depot@all &&\n+\tcd \"$git\" &&\n+\tgit log --all --graph --decorate --stat &&\n+\tgit reset --hard p4/depot/branch1 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\tgrep -q update file2 &&\n+\tgit reset --hard p4/depot/branch2 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest \\! -f file3 &&\n+\t! grep -q update file2 &&\n+\tgit reset --hard p4/depot/branch3 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\tgrep -q update file2 &&\n+\tgit reset --hard p4/depot/branch4 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest \\! -f file3 &&\n+\t! grep -q update file2 &&\n+\tgit reset --hard p4/depot/branch5 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\t! grep -q update file2 &&\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\trm -rf \"$git\" && mkdir \"$git\"\n+'\n+\n test_expect_success 'shutdown' '\n \tpid=`pgrep -f p4d` &&\n \ttest -n \"$pid\" &&\n-- \n1.7.5.4\n"},{"id":"173934","messageId":"20110820191203.GC7135@arf.padd.com","threadId":"28160","inReplyTo":"1313712590-26876-3-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-20T19:12:03Z","receivedAt":"2011-08-20T19:12:03Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Fri, 19 Aug 2011 01:09 +0100:\n> Check if branches created from old changelists are correctly imported.\n> \n> Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\n\nStyle edits.\n\n\t\t-- Pete\n\n\n\n---------------8<-------------------\n\n>From 5d1103a97b60570423782fd3873a2b413ddb1d5b Mon Sep 17 00:00:00 2001\nFrom: Pete Wyckoff <pw@padd.com>\nDate: Sat, 20 Aug 2011 14:31:49 -0400\nSubject: [PATCH 3/4] git-p4: complex branch test edits\n\nA few simplifications and style edits here too.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4.sh |   21 +++++++++------------\n 1 files changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex 5bcb8b4..cf3a70e 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -489,11 +489,11 @@ test_expect_success 'git-p4 clone simple branches' '\n #   `- file3\n test_expect_success 'add p4 complex branches' '\n \tcd \"$cli\" &&\n-\tchangelist=$(p4 changes -m1 //depot/... | cut -d \\  -f 2) &&\n-\tchangelist=$(($changelist - 5)) &&\n+\tchangelist=$(p4 changes -m1 //depot/... | cut -d\" \" -f2) &&\n+\tchangelist=$((changelist - 5)) &&\n \tp4 integrate //depot/branch1/...@$changelist //depot/branch4/... &&\n \tp4 submit -d \"branch4\" &&\n-\tchangelist=$(($changelist + 2)) &&\n+\tchangelist=$((changelist + 2)) &&\n \tp4 integrate //depot/branch1/...@$changelist //depot/branch5/... &&\n \tp4 submit -d \"branch5\" &&\n \tcd \"$TRASH_DIRECTORY\"\n@@ -503,15 +503,14 @@ test_expect_success 'add p4 complex branches' '\n # to clone the original structure if it is able to detect the origin changelist\n # of each branch.\n test_expect_success 'git-p4 clone complex branches' '\n-\tgit init \"$git\" &&\n+\ttest_when_finished cleanup_git &&\n+\ttest_create_repo \"$git\" &&\n \tcd \"$git\" &&\n \tgit config git-p4.branchList branch1:branch2 &&\n \tgit config --add git-p4.branchList branch1:branch3 &&\n \tgit config --add git-p4.branchList branch1:branch4 &&\n \tgit config --add git-p4.branchList branch1:branch5 &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n-\t\"$GITP4\" clone --dest=\"$git\" --detect-branches //depot@all &&\n-\tcd \"$git\" &&\n+\t\"$GITP4\" clone --dest=. --detect-branches //depot@all &&\n \tgit log --all --graph --decorate --stat &&\n \tgit reset --hard p4/depot/branch1 &&\n \ttest -f file1 &&\n@@ -521,7 +520,7 @@ test_expect_success 'git-p4 clone complex branches' '\n \tgit reset --hard p4/depot/branch2 &&\n \ttest -f file1 &&\n \ttest -f file2 &&\n-\ttest \\! -f file3 &&\n+\ttest ! -f file3 &&\n \t! grep -q update file2 &&\n \tgit reset --hard p4/depot/branch3 &&\n \ttest -f file1 &&\n@@ -531,15 +530,13 @@ test_expect_success 'git-p4 clone complex branches' '\n \tgit reset --hard p4/depot/branch4 &&\n \ttest -f file1 &&\n \ttest -f file2 &&\n-\ttest \\! -f file3 &&\n+\ttest ! -f file3 &&\n \t! grep -q update file2 &&\n \tgit reset --hard p4/depot/branch5 &&\n \ttest -f file1 &&\n \ttest -f file2 &&\n \ttest -f file3 &&\n-\t! grep -q update file2 &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n-\trm -rf \"$git\" && mkdir \"$git\"\n+\t! grep -q update file2\n '\n \n test_expect_success 'shutdown' '\n-- \n1.7.5.4\n"},{"id":"173982","messageId":"20110822011319.0a013117@fenix.utopia.dhis.org","threadId":"28160","inReplyTo":"20110820191203.GC7135@arf.padd.com","subject":"Re: [PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T00:13:19Z","receivedAt":"2011-08-22T00:13:19Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Sat, 20 Aug 2011 15:12:03 -0400\nPete Wyckoff <pw@padd.com> wrote:\n\n> Style edits.\n> \n> \t\t-- Pete\n\nI still need some help on the code part of this RFC patch. I really do\nnot like the way it is implemented. Do you see other possible ways of\nachieving the same algorithm?\n\nThanks,\n-- \nVitor Antunes\n"},{"id":"174066","messageId":"20110823022713.GA6005@arf.padd.com","threadId":"28160","inReplyTo":"20110822011319.0a013117@fenix.utopia.dhis.org","subject":"Re: [PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-23T02:27:13Z","receivedAt":"2011-08-23T02:27:13Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Mon, 22 Aug 2011 01:13 +0100:\n> I still need some help on the code part of this RFC patch. I really do\n> not like the way it is implemented. Do you see other possible ways of\n> achieving the same algorithm?\n\nI think I understand the problem now, and have a small test case\nto see what's going wrong.  Your solution is definitely\nsub-optimal.  :)  Is there anything that can be done with\n--import-marks and --export-marks?\n\nCould you guess at the branch point using p4?  I.e. for each file\nin the new branch, grab the change that caused its most recent\nrevision (the #xx part).  Pick the max of those changes.  In git,\nfind the commit whith \"change = ...\" that you just discovered.\nThat's the parent.\n\nEven this won't be perfect, and I'm not even sure if it's less\nicky than diff-tree.\n\n\t\t-- Pete\n"},{"id":"174126","messageId":"CAOpHH-V92CcWm1tCwvb=pJux5PKbYQoG=E8M_Pc2JGu00wnR8Q@mail.gmail.com","threadId":"28160","inReplyTo":"20110823022713.GA6005@arf.padd.com","subject":"Re: [PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-23T22:02:05Z","receivedAt":"2011-08-23T22:02:05Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Tue, Aug 23, 2011 at 3:27 AM, Pete Wyckoff <pw@padd.com> wrote:\n> I think I understand the problem now, and have a small test case\n> to see what's going wrong.  Your solution is definitely\n> sub-optimal.  :)  Is there anything that can be done with\n> --import-marks and --export-marks?\n\nDon't know if you agree, but I think it would be better to keep git-p4\nfrom storing extra files in the filesystem. And, as far as I understood,\nthese two options require extra files.\nBut I don't think marks would help us that much. We already have\nsomething similar: the changelist number in the commit log. The big\nproblem is that P4 does not store a pointer to the previous changelist.\n\n> Could you guess at the branch point using p4?  I.e. for each file\n> in the new branch, grab the change that caused its most recent\n> revision (the #xx part).  Pick the max of those changes.  In git,\n> find the commit whith \"change = ...\" that you just discovered.\n> That's the parent.\n\nYes, I think this would work. Nevertheless, I would prefer not to do so\nmuch pooling on the P4 server because when we're in a remote location in\nregards to the P4 proxy server this kind of command becomes rather slow.\nAnd if the branch has many files this may become cumbersome.\n\n> Even this won't be perfect, and I'm not even sure if it's less\n> icky than diff-tree.\n\nFrom what I can see, the two possible solutions would be:\n\na) Running a \"filelog\" on all files. This may become slower when the\n   branch has lots of files. There's also the problem in needing to\n   contact the P4 proxy server every time.\n\nb) Using diff-tree. This will be slower if the original changelist is\n   very far from the latest one, but has the advantage of being run\n   locally. It has the disadvantage of not having an apparent\n   compatibility with fast-import.\n\nIn my personal point of view, diff-tree solution still looks better, if\nit weren't for the fast-import issue. Now if we could just figure out\nhow to overcome this issue...\n\n-- \nVitor Antunes\n"},{"id":"174130","messageId":"20110823231034.GA11918@arf.padd.com","threadId":"28160","inReplyTo":"CAOpHH-V92CcWm1tCwvb=pJux5PKbYQoG=E8M_Pc2JGu00wnR8Q@mail.gmail.com","subject":"Re: [PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-23T23:10:34Z","receivedAt":"2011-08-23T23:10:34Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Tue, 23 Aug 2011 23:02 +0100:\n> On Tue, Aug 23, 2011 at 3:27 AM, Pete Wyckoff <pw@padd.com> wrote:\n> > I think I understand the problem now, and have a small test case\n> > to see what's going wrong.  Your solution is definitely\n> > sub-optimal.  :)  Is there anything that can be done with\n> > --import-marks and --export-marks?\n> \n> Don't know if you agree, but I think it would be better to keep git-p4\n> from storing extra files in the filesystem. And, as far as I understood,\n> these two options require extra files.\n> But I don't think marks would help us that much. We already have\n> something similar: the changelist number in the commit log. The big\n> problem is that P4 does not store a pointer to the previous changelist.\n\nAgreed.\n\n> > Could you guess at the branch point using p4?  I.e. for each file\n> > in the new branch, grab the change that caused its most recent\n> > revision (the #xx part).  Pick the max of those changes.  In git,\n> > find the commit whith \"change = ...\" that you just discovered.\n> > That's the parent.\n> \n> Yes, I think this would work. Nevertheless, I would prefer not to do so\n> much pooling on the P4 server because when we're in a remote location in\n> regards to the P4 proxy server this kind of command becomes rather slow.\n> And if the branch has many files this may become cumbersome.\n> \n> > Even this won't be perfect, and I'm not even sure if it's less\n> > icky than diff-tree.\n> \n> From what I can see, the two possible solutions would be:\n> \n> a) Running a \"filelog\" on all files. This may become slower when the\n>    branch has lots of files. There's also the problem in needing to\n>    contact the P4 proxy server every time.\n> \n> b) Using diff-tree. This will be slower if the original changelist is\n>    very far from the latest one, but has the advantage of being run\n>    locally. It has the disadvantage of not having an apparent\n>    compatibility with fast-import.\n> \n> In my personal point of view, diff-tree solution still looks better, if\n> it weren't for the fast-import issue. Now if we could just figure out\n> how to overcome this issue...\n\nNice analysis.  P4 can indeed be the bottleneck, even on near\nservers if there are lots of files.  Diff-tree seems like the\nbetter choice to find the branch point.  I don't understand fully\nwhy the way we are using fast-import causes these problems.  Will\nlook at that next.\n\n\t\t-- Pete\n"},{"id":"174145","messageId":"CAOpHH-V9nm2NRD47gdUj6sLJSTypjABjE-JGCkADE=fxh2nSWg@mail.gmail.com","threadId":"28160","inReplyTo":"20110823231034.GA11918@arf.padd.com","subject":"Re: [PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-24T10:46:53Z","receivedAt":"2011-08-24T10:46:53Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Wed, Aug 24, 2011 at 12:10 AM, Pete Wyckoff <pw@padd.com> wrote:\n> Nice analysis.  P4 can indeed be the bottleneck, even on near\n> servers if there are lots of files.  Diff-tree seems like the\n> better choice to find the branch point.  I don't understand fully\n> why the way we are using fast-import causes these problems.  Will\n> look at that next.\n\nI came up with some ideas during sleep:\n\n1. When doing a \"checkpoint\" it would make sense to have some kind of\n   feedback loop to know when fast-import completes it. In fact, I've\n   just looked at fast-import man page and the \"progress\" command seems\n   to do exactly that! Myabe we should crease a specific function for\n   \"checkpoint\" that would call also \"progress\" instead of calling\n   os.sleep().\n\n2. In order to avoid needing to use \"--force\" it would be nice to have\n   some form of \"drop\" command in fast-import that would allows us to\n   actively drop an older commit after calling \"reset\" (this could even\n   be an option of \"reset\"). This way fast-import would not find\n   dangling commits in the end of the import.  Maybe there's already\n   some sort of command to achieve this in fast-import...? We could\n   probably ask to one of its maintainers.\n\n-- \nVitor Antunes\n"},{"id":"174193","messageId":"CAOpHH-Uv=zK9JoL+ooA9eEHg2XyX=k92hL1QZ_WNZwgvpnNj0g@mail.gmail.com","threadId":"28160","inReplyTo":"CAOpHH-V9nm2NRD47gdUj6sLJSTypjABjE-JGCkADE=fxh2nSWg@mail.gmail.com","subject":"Re: [PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-24T21:23:17Z","receivedAt":"2011-08-24T21:23:17Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Wed, Aug 24, 2011 at 11:46 AM, Vitor Antunes <vitor.hda@gmail.com> wrote:\n> 1. When doing a \"checkpoint\" it would make sense to have some kind of\n>   feedback loop to know when fast-import completes it. In fact, I've\n>   just looked at fast-import man page and the \"progress\" command seems\n>   to do exactly that! Myabe we should crease a specific function for\n>   \"checkpoint\" that would call also \"progress\" instead of calling\n>   os.sleep().\n\n    # Force a checkpoint in fast-import and wait for it to finish\n    def checkpoint(self):\n        self.gitStream.write(\"checkpoint\\n\\n\")\n        self.gitStream.write(\"progress checkpoint\\n\\n\")\n        out = self.gitOutput.readline()\n        if self.verbose:\n            print \"checkpoint finished: \" + out\n\nThis seems to work! :)\n\n> 2. In order to avoid needing to use \"--force\" it would be nice to have\n>   some form of \"drop\" command in fast-import that would allows us to\n>   actively drop an older commit after calling \"reset\" (this could even\n>   be an option of \"reset\"). This way fast-import would not find\n>   dangling commits in the end of the import.  Maybe there's already\n>   some sort of command to achieve this in fast-import...? We could\n>   probably ask to one of its maintainers.\n\nJust missing point 2 now.\n\n-- \nVitor Antunes\n"},{"id":"174398","messageId":"20110827233201.GA6999@arf.padd.com","threadId":"28160","inReplyTo":"CAOpHH-Uv=zK9JoL+ooA9eEHg2XyX=k92hL1QZ_WNZwgvpnNj0g@mail.gmail.com","subject":"Re: [PATCH/RFC 2/2] git-p4: Add complex test case for branch import","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-27T23:32:01Z","receivedAt":"2011-08-27T23:32:01Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Wed, 24 Aug 2011 22:23 +0100:\n> On Wed, Aug 24, 2011 at 11:46 AM, Vitor Antunes <vitor.hda@gmail.com> wrote:\n> > 1. When doing a \"checkpoint\" it would make sense to have some kind of\n> >   feedback loop to know when fast-import completes it. In fact, I've\n> >   just looked at fast-import man page and the \"progress\" command seems\n> >   to do exactly that! Myabe we should crease a specific function for\n> >   \"checkpoint\" that would call also \"progress\" instead of calling\n> >   os.sleep().\n> \n>     # Force a checkpoint in fast-import and wait for it to finish\n>     def checkpoint(self):\n>         self.gitStream.write(\"checkpoint\\n\\n\")\n>         self.gitStream.write(\"progress checkpoint\\n\\n\")\n>         out = self.gitOutput.readline()\n>         if self.verbose:\n>             print \"checkpoint finished: \" + out\n> \n> This seems to work! :)\n\nThat's brilliant.  And not even hacky.  :)\n\n> > 2. In order to avoid needing to use \"--force\" it would be nice to have\n> >   some form of \"drop\" command in fast-import that would allows us to\n> >   actively drop an older commit after calling \"reset\" (this could even\n> >   be an option of \"reset\"). This way fast-import would not find\n> >   dangling commits in the end of the import.  Maybe there's already\n> >   some sort of command to achieve this in fast-import...? We could\n> >   probably ask to one of its maintainers.\n> \n> Just missing point 2 now.\n\nHow about this.  Create the commit onto a fake branch name,\nsomething involving the changeid would be okay.  Remember this\nso we can delete it later.  For a parent, you can use anything,\nso the top of the parent branch would be okay.  Checkpoint.\n\nUse rev-parse like you do.  But go from the most recent commit on\nback, hoping that the branch was created recently.  I suspect\nthis is the case for those using \"git-p4 sync\" with\ndetect-branches to discover new ones periodically.\n\nFor each ref, diff-tree like you do.  When it is found, generate\nthe commit again, with its real branch name and parent now.\n\nWhen it exits, remember to delete the temp branches.  Would be\nnice to do this even on error exit, but that's harder.  Maybe\nthe fake branch name should be something like\n\"refs/git-p4-temp/change-30214\" instead of refs/heads/... to\nindicate they are special.  GC will commit the commits\neventually.\n\n\nThe other thought I had was to use \"blob\" with a mark name on\neach file.  Use --export-marks=...  Checkpoint.  Read the blob\nids corresponding to files on the branch.  Then iterate back the\nrevs and do \"git ls-tree -r ref^{tree}\".  Compare its blobs to\nthe new ones until a matching commit is found.  Finally assemble\nthe blobs into a commit; no need to write them again.  This seems\nharder.\n\n\nHere's a commit that refactors the tests and adds a bunch more\nbranch tests.  They all pass with your checkpoint/progress fix,\nand still using --force.\n\n\t\t-- Pete\n\n\n---------------------8<---------------\nFrom f1e11b78cbb74fd4347df5fff64a373c3e449f68 Mon Sep 17 00:00:00 2001\nFrom: Pete Wyckoff <pw@padd.com>\nDate: Mon, 22 Aug 2011 22:20:33 -0400\nSubject: [PATCH] git-p4 tests: refactor and add branch tests\n\nSeparate the tests related to detecting p4 branches\ninto their own file, and add a few more.\n\nIntroduce a library for functions that are common to\nboth git-p4 test files.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/lib-git-p4.sh          |   55 ++++++++\n t/t9800-git-p4.sh        |  182 +-------------------------\n t/t9801-git-p4-branch.sh |  326 ++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 388 insertions(+), 175 deletions(-)\n create mode 100644 t/lib-git-p4.sh\n create mode 100755 t/t9801-git-p4-branch.sh\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nnew file mode 100644\nindex 0000000..dbc1499\n--- /dev/null\n+++ b/t/lib-git-p4.sh\n@@ -0,0 +1,55 @@\n+#\n+# Library code for git-p4 tests\n+#\n+\n+. ./test-lib.sh\n+\n+( p4 -h && p4d -h ) >/dev/null 2>&1 || {\n+\tskip_all='skipping git-p4 tests; no p4 or p4d'\n+\ttest_done\n+}\n+\n+GITP4=$GIT_BUILD_DIR/contrib/fast-import/git-p4\n+P4DPORT=10669\n+\n+export P4PORT=localhost:$P4DPORT\n+export P4CLIENT=client\n+\n+db=\"$TRASH_DIRECTORY/db\"\n+cli=\"$TRASH_DIRECTORY/cli\"\n+git=\"$TRASH_DIRECTORY/git\"\n+\n+start_p4d()\n+{\n+\tmkdir -p \"$db\" &&\n+\tp4d -q -d -r \"$db\" -p $P4DPORT &&\n+\tmkdir -p \"$cli\" &&\n+\tmkdir -p \"$git\" &&\n+\tcd \"$cli\" &&\n+\tp4 client -i <<-EOF\n+\tClient: client\n+\tDescription: client\n+\tRoot: $cli\n+\tView: //depot/... //client/...\n+\tEOF\n+}\n+\n+kill_p4d()\n+{\n+\tpid=`pgrep -f p4d` &&\n+\ttest -n \"$pid\" &&\n+\tfor i in {1..5} ; do\n+\t    test_debug \"ps wl `echo $pid`\" &&\n+\t    kill $pid 2>/dev/null &&\n+\t    pgrep -f p4d >/dev/null || break &&\n+\t    sleep 0.2\n+\tdone &&\n+\trm -rf \"$db\" &&\n+\trm -rf \"$cli\"\n+}\n+\n+cleanup_git() {\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\trm -rf \"$git\" &&\n+\tmkdir \"$git\"\n+}\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex cf3a70e..684aa53 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -2,40 +2,16 @@\n \n test_description='git-p4 tests'\n \n-. ./test-lib.sh\n+. ./lib-git-p4.sh\n \n-( p4 -h && p4d -h ) >/dev/null 2>&1 || {\n-\tskip_all='skipping git-p4 tests; no p4 or p4d'\n-\ttest_done\n-}\n-\n-GITP4=$GIT_BUILD_DIR/contrib/fast-import/git-p4\n-P4DPORT=10669\n-\n-export P4PORT=localhost:$P4DPORT\n-\n-db=\"$TRASH_DIRECTORY/db\"\n-cli=\"$TRASH_DIRECTORY/cli\"\n-git=\"$TRASH_DIRECTORY/git\"\n-\n-test_debug 'echo p4d -q -d -r \"$db\" -p $P4DPORT'\n-test_expect_success setup '\n-\tmkdir -p \"$db\" &&\n-\tp4d -q -d -r \"$db\" -p $P4DPORT &&\n-\tmkdir -p \"$cli\" &&\n-\tmkdir -p \"$git\" &&\n-\texport P4PORT=localhost:$P4DPORT\n+test_expect_success 'start p4d' '\n+\tkill_p4d || : &&\n+\tstart_p4d &&\n+\tcd \"$TRASH_DIRECTORY\"\n '\n \n test_expect_success 'add p4 files' '\n \tcd \"$cli\" &&\n-\tp4 client -i <<-EOF &&\n-\tClient: client\n-\tDescription: client\n-\tRoot: $cli\n-\tView: //depot/... //client/...\n-\tEOF\n-\texport P4CLIENT=client &&\n \techo file1 >file1 &&\n \tp4 add file1 &&\n \tp4 submit -d \"file1\" &&\n@@ -45,12 +21,6 @@ test_expect_success 'add p4 files' '\n \tcd \"$TRASH_DIRECTORY\"\n '\n \n-cleanup_git() {\n-\tcd \"$TRASH_DIRECTORY\" &&\n-\trm -rf \"$git\" &&\n-\tmkdir \"$git\"\n-}\n-\n test_expect_success 'basic git-p4 clone' '\n \t\"$GITP4\" clone --dest=\"$git\" //depot &&\n \ttest_when_finished cleanup_git &&\n@@ -404,146 +374,8 @@ test_expect_success 'detect copies' '\n \tp4 filelog //depot/file13 | grep -q \"branch from //depot/file\"\n '\n \n-# Create a simple branch structure in P4 depot to check if it is correctly\n-# cloned.\n-test_expect_success 'add simple p4 branches' '\n-\tcd \"$cli\" &&\n-\tmkdir branch1 &&\n-\tcd branch1 &&\n-\techo file1 >file1 &&\n-\techo file2 >file2 &&\n-\tp4 add file1 file2 &&\n-\tp4 submit -d \"branch1\" &&\n-\tp4 integrate //depot/branch1/... //depot/branch2/... &&\n-\tp4 submit -d \"branch2\" &&\n-\techo file3 >file3 &&\n-\tp4 add file3 &&\n-\tp4 submit -d \"add file3 in branch1\" &&\n-\tp4 open file2 &&\n-\techo update >>file2 &&\n-\tp4 submit -d \"update file2 in branch1\" &&\n-\tp4 integrate //depot/branch1/... //depot/branch3/... &&\n-\tp4 submit -d \"branch3\" &&\n-\tcd \"$TRASH_DIRECTORY\"\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-test_expect_success 'git-p4 clone simple branches' '\n-\ttest_when_finished cleanup_git &&\n-\ttest_create_repo \"$git\" &&\n-\tcd \"$git\" &&\n-\tgit config git-p4.branchList branch1:branch2 &&\n-\tgit config --add git-p4.branchList branch1:branch3 &&\n-\t\"$GITP4\" clone --dest=. --detect-branches //depot@all &&\n-\tgit log --all --graph --decorate --stat &&\n-\tgit reset --hard p4/depot/branch1 &&\n-\ttest -f file1 &&\n-\ttest -f file2 &&\n-\ttest -f file3 &&\n-\tgrep -q update file2 &&\n-\tgit reset --hard p4/depot/branch2 &&\n-\ttest -f file1 &&\n-\ttest -f file2 &&\n-\ttest ! -f file3 &&\n-\t! grep -q update file2 &&\n-\tgit reset --hard p4/depot/branch3 &&\n-\ttest -f file1 &&\n-\ttest -f file2 &&\n-\ttest -f file3 &&\n-\tgrep -q update file2 &&\n-\tcd \"$cli\" &&\n-\tcd branch1 &&\n-\tp4 edit file2 &&\n-\techo file2_ >>file2 &&\n-\tp4 submit -d \"update file2 in branch3\" &&\n-\tcd \"$git\" &&\n-\tgit reset --hard p4/depot/branch1 &&\n-\t\"$GITP4\" rebase &&\n-\tgrep -q file2_ file2\n-'\n-\n-# Create a complex branch structure in P4 depot to check if they are correctly\n-# cloned. The branches are created from older changelists to check if git-p4 is\n-# able to correctly detect them.\n-# The final expected structure is:\n-# `branch1\n-# | `- file1\n-# | `- file2 (updated)\n-# | `- file3\n-# `branch2\n-# | `- file1\n-# | `- file2\n-# `branch3\n-# | `- file1\n-# | `- file2 (updated)\n-# | `- file3\n-# `branch4\n-# | `- file1\n-# | `- file2\n-# `branch5\n-#   `- file1\n-#   `- file2\n-#   `- file3\n-test_expect_success 'add p4 complex branches' '\n-\tcd \"$cli\" &&\n-\tchangelist=$(p4 changes -m1 //depot/... | cut -d\" \" -f2) &&\n-\tchangelist=$((changelist - 5)) &&\n-\tp4 integrate //depot/branch1/...@$changelist //depot/branch4/... &&\n-\tp4 submit -d \"branch4\" &&\n-\tchangelist=$((changelist + 2)) &&\n-\tp4 integrate //depot/branch1/...@$changelist //depot/branch5/... &&\n-\tp4 submit -d \"branch5\" &&\n-\tcd \"$TRASH_DIRECTORY\"\n-'\n-\n-# Configure branches through git-config and clone them. git-p4 will only be able\n-# to clone the original structure if it is able to detect the origin changelist\n-# of each branch.\n-test_expect_success 'git-p4 clone complex branches' '\n-\ttest_when_finished cleanup_git &&\n-\ttest_create_repo \"$git\" &&\n-\tcd \"$git\" &&\n-\tgit config git-p4.branchList branch1:branch2 &&\n-\tgit config --add git-p4.branchList branch1:branch3 &&\n-\tgit config --add git-p4.branchList branch1:branch4 &&\n-\tgit config --add git-p4.branchList branch1:branch5 &&\n-\t\"$GITP4\" clone --dest=. --detect-branches //depot@all &&\n-\tgit log --all --graph --decorate --stat &&\n-\tgit reset --hard p4/depot/branch1 &&\n-\ttest -f file1 &&\n-\ttest -f file2 &&\n-\ttest -f file3 &&\n-\tgrep -q update file2 &&\n-\tgit reset --hard p4/depot/branch2 &&\n-\ttest -f file1 &&\n-\ttest -f file2 &&\n-\ttest ! -f file3 &&\n-\t! grep -q update file2 &&\n-\tgit reset --hard p4/depot/branch3 &&\n-\ttest -f file1 &&\n-\ttest -f file2 &&\n-\ttest -f file3 &&\n-\tgrep -q update file2 &&\n-\tgit reset --hard p4/depot/branch4 &&\n-\ttest -f file1 &&\n-\ttest -f file2 &&\n-\ttest ! -f file3 &&\n-\t! grep -q update file2 &&\n-\tgit reset --hard p4/depot/branch5 &&\n-\ttest -f file1 &&\n-\ttest -f file2 &&\n-\ttest -f file3 &&\n-\t! grep -q update file2\n-'\n-\n-test_expect_success 'shutdown' '\n-\tpid=`pgrep -f p4d` &&\n-\ttest -n \"$pid\" &&\n-\ttest_debug \"ps wl `echo $pid`\" &&\n-\tkill $pid\n+test_expect_success 'kill p4d' '\n+\tkill_p4d\n '\n \n test_done\ndiff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh\nnew file mode 100755\nindex 0000000..c71d1a5\n--- /dev/null\n+++ b/t/t9801-git-p4-branch.sh\n@@ -0,0 +1,326 @@\n+#!/bin/sh\n+\n+test_description='git-p4 p4 branching tests'\n+\n+. ./lib-git-p4.sh\n+\n+test_expect_success 'start p4d' '\n+\tkill_p4d || : &&\n+\tstart_p4d &&\n+\tcd \"$TRASH_DIRECTORY\"\n+'\n+\n+#\n+# 1: //depot/main/f1\n+# 2: //depot/main/f2\n+# 3: integrate //depot/main/... -> //depot/branch1/...\n+# 4: //depot/main/f4\n+# 5: //depot/branch1/f5\n+# .: named branch branch2\n+# 6: integrate -b branch2\n+# 7: //depot/branch2/f7\n+# 8: //depot/main/f8\n+#\n+test_expect_success 'basic p4 branches' '\n+\tcd \"$cli\" &&\n+\tmkdir -p main &&\n+\n+\techo f1 >main/f1 &&\n+\tp4 add main/f1 &&\n+\tp4 submit -d \"main/f1\" &&\n+\n+\techo f2 >main/f2 &&\n+\tp4 add main/f2 &&\n+\tp4 submit -d \"main/f2\" &&\n+\n+\tp4 integrate //depot/main/... //depot/branch1/... &&\n+\tp4 submit -d \"integrate main to branch1\" &&\n+\n+\techo f4 >main/f4 &&\n+\tp4 add main/f4 &&\n+\tp4 submit -d \"main/f4\" &&\n+\n+\techo f5 >branch1/f5 &&\n+\tp4 add branch1/f5 &&\n+\tp4 submit -d \"branch1/f5\" &&\n+\n+\tp4 branch -i <<-EOF &&\n+\tBranch: branch2\n+\tView: //depot/main/... //depot/branch2/...\n+\tEOF\n+\n+\tp4 integrate -b branch2 &&\n+\tp4 submit -d \"integrate main to branch2\" &&\n+\n+\techo f7 >branch2/f7 &&\n+\tp4 add branch2/f7 &&\n+\tp4 submit -d \"branch2/f7\" &&\n+\n+\techo f8 >main/f8 &&\n+\tp4 add main/f8 &&\n+\tp4 submit -d \"main/f8\" &&\n+\n+\tcd \"$TRASH_DIRECTORY\"\n+'\n+\n+test_expect_success 'import main, no branch detection' '\n+\ttest_when_finished cleanup_git &&\n+\t\"$GITP4\" clone --dest=\"$git\" //depot/main@all &&\n+\tcd \"$git\" &&\n+\tgit log --oneline --graph --decorate --all &&\n+\tgit rev-list master >wc &&\n+\ttest_line_count = 4 wc\n+'\n+\n+test_expect_success 'import branch1, no branch detection' '\n+\ttest_when_finished cleanup_git &&\n+\t\"$GITP4\" clone --dest=\"$git\" //depot/branch1@all &&\n+\tcd \"$git\" &&\n+\tgit log --oneline --graph --decorate --all &&\n+\tgit rev-list master >wc &&\n+\ttest_line_count = 2 wc\n+'\n+\n+test_expect_success 'import branch2, no branch detection' '\n+\ttest_when_finished cleanup_git &&\n+\t\"$GITP4\" clone --dest=\"$git\" //depot/branch2@all &&\n+\tcd \"$git\" &&\n+\tgit log --oneline --graph --decorate --all &&\n+\tgit rev-list master >wc &&\n+\ttest_line_count = 2 wc\n+'\n+\n+test_expect_success 'import depot, no branch detection' '\n+\ttest_when_finished cleanup_git &&\n+\t\"$GITP4\" clone --dest=\"$git\" //depot@all &&\n+\tcd \"$git\" &&\n+\tgit log --oneline --graph --decorate --all &&\n+\tgit rev-list master >wc &&\n+\ttest_line_count = 8 wc\n+'\n+\n+test_expect_success 'import depot, branch detection' '\n+\ttest_when_finished cleanup_git &&\n+\t\"$GITP4\" clone --dest=\"$git\" --detect-branches //depot@all &&\n+\tcd \"$git\" &&\n+\n+\tgit log --oneline --graph --decorate --all &&\n+\n+\t# 4 main commits\n+\tgit rev-list master >wc &&\n+\ttest_line_count = 4 wc &&\n+\n+\t# 3 main, 1 integrate, 1 on branch2\n+\tgit rev-list p4/depot/branch2 >wc &&\n+\ttest_line_count = 5 wc &&\n+\n+\t# no branch1, since no p4 branch created for it\n+\ttest_must_fail git show-ref p4/depot/branch1\n+'\n+\n+test_expect_success 'import depot, branch detection, branchList branch definition' '\n+\ttest_when_finished cleanup_git &&\n+\ttest_create_repo \"$git\" &&\n+\tcd \"$git\" &&\n+\tgit config git-p4.branchList main:branch1 &&\n+\t\"$GITP4\" clone --dest=. --detect-branches //depot@all &&\n+\n+\tgit log --oneline --graph --decorate --all &&\n+\n+\t# 4 main commits\n+\tgit rev-list master >wc &&\n+\ttest_line_count = 4 wc &&\n+\n+\t# 3 main, 1 integrate, 1 on branch2\n+\tgit rev-list p4/depot/branch2 >wc &&\n+\ttest_line_count = 5 wc &&\n+\n+\t# 2 main, 1 integrate, 1 on branch1\n+\tgit rev-list p4/depot/branch1 >wc &&\n+\ttest_line_count = 4 wc\n+'\n+\n+test_expect_success 'branch from non-head should find parent' '\n+\tcd \"$cli\" &&\n+\tp4 integrate //depot/main/...@1 //depot/branch3/... &&\n+\tp4 submit -d \"integrate main@1 to branch3\" &&\n+\n+\ttest_when_finished cleanup_git &&\n+\ttest_create_repo \"$git\" &&\n+\tcd \"$git\" &&\n+\n+\tgit config git-p4.branchList main:branch1 &&\n+\tgit config git-p4.branchList main:branch3 &&\n+\t\"$GITP4\" clone --dest=. --detect-branches //depot@all &&\n+\n+\tgit log --oneline --graph --decorate --all &&\n+\n+\tbranch3_parent=$(git rev-parse p4/depot/branch3^) &&\n+\tchange1=$(git rev-parse :/\"change = 1\") &&\n+\techo test $branch3_parent = $change1 &&\n+\ttest $branch3_parent = $change1\n+'\n+\n+test_expect_success 'restart p4d' '\n+\tkill_p4d &&\n+\tstart_p4d &&\n+\tcd \"$TRASH_DIRECTORY\"\n+'\n+\n+#\n+# 1: //depot/branch1/file1\n+#    //depot/branch1/file2\n+# 2: integrate //depot/branch1/... -> //depot/branch2/...\n+# 3: //depot/branch1/file3\n+# 4: //depot/branch1/file2 (edit)\n+# 5: integrate //depot/branch1/... -> //depot/branch3/...\n+#\n+## Create a simple branch structure in P4 depot.\n+test_expect_success 'add simple p4 branches' '\n+\tcd \"$cli\" &&\n+\tmkdir branch1 &&\n+\tcd branch1 &&\n+\techo file1 >file1 &&\n+\techo file2 >file2 &&\n+\tp4 add file1 file2 &&\n+\tp4 submit -d \"branch1\" &&\n+\tp4 integrate //depot/branch1/... //depot/branch2/... &&\n+\tp4 submit -d \"branch2\" &&\n+\techo file3 >file3 &&\n+\tp4 add file3 &&\n+\tp4 submit -d \"add file3 in branch1\" &&\n+\tp4 open file2 &&\n+\techo update >>file2 &&\n+\tp4 submit -d \"update file2 in branch1\" &&\n+\tp4 integrate //depot/branch1/... //depot/branch3/... &&\n+\tp4 submit -d \"branch3\" &&\n+\tcd \"$TRASH_DIRECTORY\"\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+test_expect_success 'git-p4 clone simple branches' '\n+\ttest_when_finished cleanup_git &&\n+\ttest_create_repo \"$git\" &&\n+\tcd \"$git\" &&\n+\tgit config git-p4.branchList branch1:branch2 &&\n+\tgit config --add git-p4.branchList branch1:branch3 &&\n+\t\"$GITP4\" clone --dest=. --detect-branches //depot@all &&\n+\tgit log --all --graph --decorate --stat &&\n+\tgit reset --hard p4/depot/branch1 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\tgrep -q update file2 &&\n+\tgit reset --hard p4/depot/branch2 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest ! -f file3 &&\n+\ttest_must_fail grep -q update file2 &&\n+\tgit reset --hard p4/depot/branch3 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\tgrep -q update file2 &&\n+\tcd \"$cli\" &&\n+\tcd branch1 &&\n+\tp4 edit file2 &&\n+\techo file2_ >>file2 &&\n+\tp4 submit -d \"update file2 in branch3\" &&\n+\tcd \"$git\" &&\n+\tgit reset --hard p4/depot/branch1 &&\n+\t\"$GITP4\" rebase &&\n+\tgrep -q file2_ file2\n+'\n+\n+# Create a complex branch structure in P4 depot to check if they are correctly\n+# cloned. The branches are created from older changelists to check if git-p4 is\n+# able to correctly detect them.\n+#\n+# The final expected structure is:\n+# `branch1\n+# | `- file1\n+# | `- file2 (updated)\n+# | `- file3\n+# `branch2\n+# | `- file1\n+# | `- file2\n+# `branch3\n+# | `- file1\n+# | `- file2 (updated)\n+# | `- file3\n+# `branch4\n+# | `- file1\n+# | `- file2\n+# `branch5\n+#   `- file1\n+#   `- file2\n+#   `- file3\n+#\n+# Changes 1..6 from previous tests, plus two new ones:\n+# 1: //depot/branch1/file1\n+#    //depot/branch1/file2\n+# 2: integrate //depot/branch1/... -> //depot/branch2/...\n+# 3: //depot/branch1/file3\n+# 4: //depot/branch1/file2 (edit)\n+# 5: integrate //depot/branch1/... -> //depot/branch3/...\n+# 6: //depot/branch3/file2 (edit, from previous test)\n+# 7: integrate //depot/branch1/...@1 -> //depot/branch4/...\n+# 8: integrate //depot/branch1/...@3 -> //depot/branch5/...\n+#\n+test_expect_success 'add p4 complex branches' '\n+\tcd \"$cli\" &&\n+\tp4 integrate //depot/branch1/...@1 //depot/branch4/... &&\n+\tp4 submit -d \"branch4 from branch1@1\" &&\n+\tp4 integrate //depot/branch1/...@3 //depot/branch5/... &&\n+\tp4 submit -d \"branch5 from branch1@3\" &&\n+\tcd \"$TRASH_DIRECTORY\"\n+'\n+\n+# Configure branches through git-config and clone them.  git-p4 will only be\n+# able to clone the original structure if it is able to detect the origin\n+# changelist of each branch.\n+test_expect_success 'git-p4 clone complex branches' '\n+\ttest_when_finished cleanup_git &&\n+\ttest_create_repo \"$git\" &&\n+\tcd \"$git\" &&\n+\tgit config git-p4.branchList branch1:branch2 &&\n+\tgit config --add git-p4.branchList branch1:branch3 &&\n+\tgit config --add git-p4.branchList branch1:branch4 &&\n+\tgit config --add git-p4.branchList branch1:branch5 &&\n+\t\"$GITP4\" clone --dest=. --detect-branches //depot@all &&\n+\tgit log --all --graph --decorate --stat &&\n+\tgit reset --hard p4/depot/branch1 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\tgrep -q update file2 &&\n+\tgit reset --hard p4/depot/branch2 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest ! -f file3 &&\n+\ttest_must_fail grep -q update file2 &&\n+\tgit reset --hard p4/depot/branch3 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\tgrep -q update file2 &&\n+\tgit reset --hard p4/depot/branch4 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest ! -f file3 &&\n+\ttest_must_fail grep -q update file2 &&\n+\tgit reset --hard p4/depot/branch5 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\ttest_must_fail grep -q update file2\n+'\n+\n+test_expect_success 'kill p4d' '\n+\tkill_p4d\n+'\n+\n+test_done\n-- \n1.7.5.4\n"}]}