{"thread":{"id":"15065","subject":"[RFC] Using git-p4 on project with branches","startedAt":"2008-08-18T09:26:27Z","lastAt":"2008-08-24T10:36:32Z","messageCount":3,"participants":["Tor Arvid Lund","Daniel Barkalow","Simon Hausmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"87524","messageId":"1a6be5fa0808180226h79eebf46yad9174b1518d4eed@mail.gmail.com","threadId":"15065","inReplyTo":null,"subject":"[RFC] Using git-p4 on project with branches","fromName":"Tor Arvid Lund","fromEmail":"torarvid@gmail.com","sentAt":"2008-08-18T09:26:27Z","receivedAt":"2008-08-18T09:26:27Z","isPatch":false,"sender":{"key":"torarvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/439758?v=4"},"body":"Hi!\n\nI really appreciate the work that is done with allowing us poor souls\nstuck with perforce at work to use git via git-p4. But I'm wondering\nhow to make it work when there are several branches on the perforce\nserver.\n\nSay, for instance, that I have this setup:\n\n//depot/old/path/to/projectX\n//depot/new/path/to/projectX_Devel_Branch\n//depot/new/path/to/projectX_Release_1.2_Branch\n//depot/new/path/to/projectOther\n\nIt would be really nice, if I were able to make a projectX.git\nrepository with the 'old', 'devel' and '1.2' branches. It seems that\nthe --detect-branches argument to P4Sync wants me to enter\n//depot/new/path/to as the root path, and detect p4 branchspecs from\nthere. That works poorly for me, since it would also include\nprojectOther, which I don't want. It would also not include the 'old'\nbranch.\n\nI have looked briefly at the git-p4 code, but don't know it very well\nyet. Anyway, I suspect this functionality is not implemented... I\nmight try to do this myself, and if anybody has ideas on how to get\nstarted, it would be much appreciated.\n\nTo support submitting changelists back to perforce, it would probably\nneed some configuration (to determine which path to submit to in\nperforce)... Like:\n\n[git-p4 \"branches\"]\n        old = //depot/old/path/to/projectX\n        devel = //depot/new/path/to/projectX_Devel_Branch\n        1.2 = //depot/new/path/to/projectX_Release_1.2_Branch\n\nWell, I guess I'm just wondering if this is something anybody but me\nwould like to have? Or if there is another/better way to go about\ndoing it...\n\n-Tor Arvid-\n"},{"id":"87576","messageId":"alpine.LNX.1.00.0808181732180.19665@iabervon.org","threadId":"15065","inReplyTo":"1a6be5fa0808180226h79eebf46yad9174b1518d4eed@mail.gmail.com","subject":"Re: [RFC] Using git-p4 on project with branches","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-08-18T21:44:12Z","receivedAt":"2008-08-18T21:44:12Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Mon, 18 Aug 2008, Tor Arvid Lund wrote:\n\n> Hi!\n> \n> I really appreciate the work that is done with allowing us poor souls\n> stuck with perforce at work to use git via git-p4. But I'm wondering\n> how to make it work when there are several branches on the perforce\n> server.\n> \n> Say, for instance, that I have this setup:\n> \n> //depot/old/path/to/projectX\n> //depot/new/path/to/projectX_Devel_Branch\n> //depot/new/path/to/projectX_Release_1.2_Branch\n> //depot/new/path/to/projectOther\n> \n> It would be really nice, if I were able to make a projectX.git\n> repository with the 'old', 'devel' and '1.2' branches. It seems that\n> the --detect-branches argument to P4Sync wants me to enter\n> //depot/new/path/to as the root path, and detect p4 branchspecs from\n> there. That works poorly for me, since it would also include\n> projectOther, which I don't want. It would also not include the 'old'\n> branch.\n> \n> I have looked briefly at the git-p4 code, but don't know it very well\n> yet. Anyway, I suspect this functionality is not implemented... I\n> might try to do this myself, and if anybody has ideas on how to get\n> started, it would be much appreciated.\n\nYou might want to also look at git-p4raw, which does extremely clever \nbranch tracking, but acts on the perforce server database directly. If you \nfigured out how to supply its engine with information through the client, \nit would be really great (but likely slow on the order of \"leave it \nimporting over the weekend\").\n\n> To support submitting changelists back to perforce, it would probably\n> need some configuration (to determine which path to submit to in\n> perforce)... Like:\n> \n> [git-p4 \"branches\"]\n>         old = //depot/old/path/to/projectX\n>         devel = //depot/new/path/to/projectX_Devel_Branch\n>         1.2 = //depot/new/path/to/projectX_Release_1.2_Branch\n\nYou'd get \"master = //depot/new/path/to/projectX_Devel_Branch\", probably, \nby default, and then could add \"old\" and \"1.2\".\n\n> Well, I guess I'm just wondering if this is something anybody but me\n> would like to have? Or if there is another/better way to go about\n> doing it...\n\nI'd certainly like it. (But it's likely to be really tricky.)\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"88358","messageId":"200808241236.38387.simon@lst.de","threadId":"15065","inReplyTo":"1a6be5fa0808180226h79eebf46yad9174b1518d4eed@mail.gmail.com","subject":"Re: [RFC] Using git-p4 on project with branches","fromName":"Simon Hausmann","fromEmail":"simon@lst.de","sentAt":"2008-08-24T10:36:32Z","receivedAt":"2008-08-24T10:36:32Z","isPatch":false,"sender":{"key":"hausmann@kde.org","avatar":"https://gravatar.com/avatar/bc9aad4fb31dce17eb66e690e7b51fe980c62da3c225c785da35dd806b8da778?d=mp&s=160"},"body":"On Monday 18 August 2008 11:26:27 Tor Arvid Lund wrote:\n> Hi!\n>\n> I really appreciate the work that is done with allowing us poor souls\n> stuck with perforce at work to use git via git-p4. But I'm wondering\n> how to make it work when there are several branches on the perforce\n> server.\n>\n> Say, for instance, that I have this setup:\n>\n> //depot/old/path/to/projectX\n> //depot/new/path/to/projectX_Devel_Branch\n> //depot/new/path/to/projectX_Release_1.2_Branch\n> //depot/new/path/to/projectOther\n>\n> It would be really nice, if I were able to make a projectX.git\n> repository with the 'old', 'devel' and '1.2' branches. It seems that\n> the --detect-branches argument to P4Sync wants me to enter\n> //depot/new/path/to as the root path, and detect p4 branchspecs from\n> there. That works poorly for me, since it would also include\n> projectOther, which I don't want. It would also not include the 'old'\n> branch.\n>\n> I have looked briefly at the git-p4 code, but don't know it very well\n> yet. Anyway, I suspect this functionality is not implemented... I\n> might try to do this myself, and if anybody has ideas on how to get\n> started, it would be much appreciated.\n\nI can try to explain the way we import multiple branches into one git \nrepository where I work. Our setup is based on a few assumptions on the layout \nof the perforce depot.\n\nThe components in our depot paths begin with the project, followed by the name \nof the branch:\n\n//depot/project/main\n//depot/project/4.4\n//depot/project/4.4.1\n//depot/project/4.5\n//depot/project/research/foobar\n\n4.4 is branched off of main, 4.4.1 is branched off of 4.4, 4.5 and \nresearch/foobar are branched off of main again.\n\nBased on this structure we also have branch mappings stored on the perforce \nserver. They were originally introduced for convenience being able to run p4 \nintegrate with few arguments. Now they are also used for the git import:\n\n4.4branch:\n\n//depot/project/main/...    //depot/project/4.4/...\n\n(same for 4.5, 4.4.1, etc.)\n\nBased on this git-p4 imports changes:\n\n1) git-p4 is aware of //depot/project as general prefix for all branches.\n\n2) Based on the p4 branch mappings retrieved from the server it is easy to \ndetermine that the 'research/foobar' component in the \n//depot/project/research/foobar/somedir/somefile.c path of a file change \nrepresents the name of the branch.\n\n3) Based on the branch mapping git-p4 knows that for example 4.4 is based on \nmain. When the first change in the 4.4 branch is imported git-p4 assumes that \nlast change number in //depot/qt/main that is less than $currentChangeNumber\nrepresents the \"parent\" of the branch.\n\nThis approach has served us quite well, and I like that that doesn't require \nany separate configuration files or extra state information. However I \nunderstand that it requires discipline on the use of Perforce and the way \nprojects are branched.\n\nFrom your description I understand that you are using a very different \nstructure. I think what may work well for you would be an approach where you \nspecify a mapping from depot path to git branch manually in a configuration \nfile, and changes git-p4 to read such a file.\n\n> To support submitting changelists back to perforce, it would probably\n> need some configuration (to determine which path to submit to in\n> perforce)... Like:\n>\n> [git-p4 \"branches\"]\n>         old = //depot/old/path/to/projectX\n>         devel = //depot/new/path/to/projectX_Devel_Branch\n>         1.2 = //depot/new/path/to/projectX_Release_1.2_Branch\n>\n> Well, I guess I'm just wondering if this is something anybody but me\n> would like to have? Or if there is another/better way to go about\n> doing it...\n\nSubmitting changes back to Perforce with git-p4 submit is actually a very \nsimple thing, and thanks to Perforce's knowledge of everything on the client \nside there is no need to set up any configuration.\n\n1) Based on the [git-p4: depot-paths...] field in the commit log it is easy to \ndetermine the depot path.\n2) Using the p4 where command git-p4 can find out where in your p4 client view \nthe branch resides.\n3) Changes are applied in that checkout (along with p4 edit commands) and the \nchange can be submitted to perforce.\n4) Afterwards an import from Perforce is started and the changes just \nsubmitted appear in the import with the same patch-ids as the local commits, \nso git rebase will replace your local commits with the imported changes.\n\n\nI hope this helps a bit with the git-p4 understanding :)\n\n\nSimon\n"}]}