{"thread":{"id":"4460","subject":"[PATCH] cvsimport: ignore CVSPS_NO_BRANCH and impossible branches","startedAt":"2006-06-11T08:12:09Z","lastAt":"2006-06-19T16:20:35Z","messageCount":4,"participants":["Martin Langhoff","Junio C Hamano","Yann Dirson","Salikh Zakirov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"21582","messageId":"11500135293734-git-send-email-martin@catalyst.net.nz","threadId":"4460","inReplyTo":null,"subject":"[PATCH] cvsimport: ignore CVSPS_NO_BRANCH and impossible branches","fromName":"Martin Langhoff","fromEmail":"martin@catalyst.net.nz","sentAt":"2006-06-11T08:12:09Z","receivedAt":"2006-06-11T08:12:09Z","isPatch":true,"sender":{"key":"martin@laptop.org","avatar":null},"body":"cvsps output often contains references to CVSPS_NO_BRANCH, commits that it\ncould not trace to a branch. Ignore that branch.\n\nAdditionally, cvsps will sometimes draw circular relationships between\nbranches -- where two branches are recorded as opening from the other.\nIn those cases, and where the ancestor branch hasn't been seen, ignore\nit.\nSigned-off-by: Martin Langhoff <martin@catalyst.net.nz>\n---\n git-cvsimport.perl |   17 ++++++++++++++++-\n 1 files changed, 16 insertions(+), 1 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 76f6246..07b3203 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -595,7 +595,11 @@ sub write_tree () {\n }\n \n my($patchset,$date,$author_name,$author_email,$branch,$ancestor,$tag,$logmsg);\n-my(@old,@new,@skipped);\n+my(@old,@new,@skipped,%ignorebranch);\n+\n+# commits that cvsps cannot place anywhere...\n+$ignorebranch{'#CVSPS_NO_BRANCH'} = 1; \n+\n sub commit {\n \tupdate_index(@old, @new);\n \t@old = @new = ();\n@@ -751,7 +755,16 @@ while(<CVS>) {\n \t\t\t$state = 11;\n \t\t\tnext;\n \t\t}\n+\t\tif (exists $ignorebranch{$branch}) {\n+\t\t\tprint STDERR \"Skipping $branch\\n\";\n+\t\t\t$state = 11;\n+\t\t\tnext;\n+\t\t}\n \t\tif($ancestor) {\n+\t\t\tif($ancestor eq $branch) {\n+\t\t\t\tprint STDERR \"Branch $branch erroneously stems from itself -- changed ancestor to $opt_o\\n\";\n+\t\t\t\t$ancestor = $opt_o;\n+\t\t\t}\n \t\t\tif(-f \"$git_dir/refs/heads/$branch\") {\n \t\t\t\tprint STDERR \"Branch $branch already exists!\\n\";\n \t\t\t\t$state=11;\n@@ -759,6 +772,7 @@ while(<CVS>) {\n \t\t\t}\n \t\t\tunless(open(H,\"$git_dir/refs/heads/$ancestor\")) {\n \t\t\t\tprint STDERR \"Branch $ancestor does not exist!\\n\";\n+\t\t\t\t$ignorebranch{$branch} = 1;\n \t\t\t\t$state=11;\n \t\t\t\tnext;\n \t\t\t}\n@@ -766,6 +780,7 @@ while(<CVS>) {\n \t\t\tclose(H);\n \t\t\tunless(open(H,\"> $git_dir/refs/heads/$branch\")) {\n \t\t\t\tprint STDERR \"Could not create branch $branch: $!\\n\";\n+\t\t\t\t$ignorebranch{$branch} = 1;\n \t\t\t\t$state=11;\n \t\t\t\tnext;\n \t\t\t}\n-- \n1.4.0.gcda2\n"},{"id":"21967","messageId":"7vzmgb8plx.fsf@assigned-by-dhcp.cox.net","threadId":"4460","inReplyTo":"11500135293734-git-send-email-martin@catalyst.net.nz","subject":"Re: [PATCH] cvsimport: ignore CVSPS_NO_BRANCH and impossible branches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-17T21:00:10Z","receivedAt":"2006-06-17T21:00:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin@catalyst.net.nz> writes:\n\n> cvsps output often contains references to CVSPS_NO_BRANCH, commits that it\n> could not trace to a branch. Ignore that branch.\n>\n> Additionally, cvsps will sometimes draw circular relationships between\n> branches -- where two branches are recorded as opening from the other.\n> In those cases, and where the ancestor branch hasn't been seen, ignore\n> it.\n\nThis sounds more like an workaround than a real fix to me,\nalthough I'd apply it for now.  I see Yann is collecting cvsps\npatches but maybe there will be a real fix soonish?\n"},{"id":"21969","messageId":"20060617212741.GT7766@nowhere.earth","threadId":"4460","inReplyTo":"7vzmgb8plx.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] cvsimport: ignore CVSPS_NO_BRANCH and impossible branches","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-06-17T21:27:41Z","receivedAt":"2006-06-17T21:27:41Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Sat, Jun 17, 2006 at 02:00:10PM -0700, Junio C Hamano wrote:\n> Martin Langhoff <martin@catalyst.net.nz> writes:\n> \n> > cvsps output often contains references to CVSPS_NO_BRANCH, commits that it\n> > could not trace to a branch. Ignore that branch.\n> >\n> > Additionally, cvsps will sometimes draw circular relationships between\n> > branches -- where two branches are recorded as opening from the other.\n> > In those cases, and where the ancestor branch hasn't been seen, ignore\n> > it.\n> \n> This sounds more like an workaround than a real fix to me,\n> although I'd apply it for now.  I see Yann is collecting cvsps\n> patches but maybe there will be a real fix soonish?\n\nI have not dig yet into the cases that trigger CVSPS_NO_BRANCH so\ncan't make any promise, unless someone comes in with a patch already\nwritten :)\n\nSince the patch seems to ensure the user gets warned when a branch\ngets ignored this way, allowing it in could probably allow at least\nsome people to have cvsimport does a partial job, rather than failing\nmidway.  Maybe a final warning when all patchsets could not be\nimported could be issued, so the existing ones do not get simply lost\nin the verbose output.\n\nBest regards,\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"22067","messageId":"4496CED3.7050204@Intel.com","threadId":"4460","inReplyTo":"7vzmgb8plx.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] cvsimport: ignore CVSPS_NO_BRANCH and impossible branches","fromName":"Salikh Zakirov","fromEmail":"salikh.zakirov@intel.com","sentAt":"2006-06-19T16:20:35Z","receivedAt":"2006-06-19T16:20:35Z","isPatch":true,"sender":{"key":"salikh.zakirov@gmail.com","avatar":null},"body":"Junio C Hamano wrote:\n> Martin Langhoff <martin@catalyst.net.nz> writes:\n> \n>> cvsps output often contains references to CVSPS_NO_BRANCH, commits that it\n>> could not trace to a branch. Ignore that branch.\n>>\n>> Additionally, cvsps will sometimes draw circular relationships between\n>> branches -- where two branches are recorded as opening from the other.\n>> In those cases, and where the ancestor branch hasn't been seen, ignore\n>> it.\n> \n> This sounds more like an workaround than a real fix to me,\n> although I'd apply it for now.  I see Yann is collecting cvsps\n> patches but maybe there will be a real fix soonish?\n\n#CVSPS_NO_BRANCH is the identifier that CVSPS gives to the unnamed branches.\nUnnamed branches appear when the branch tag is removed or moved forcefully.\nThe following short script reproduces the CVS repository with unnamed branches.\n\nIn my opinion, ignoring #CVSPS_NO_BRANCH in git-cvsimport is the most sensible\nthing to do, because the branch was abandoned in the CVS in the first place. \nI had to preprocess cvsps output to cut out CVSPS_NO_BRANCH commits anyway.\n\nI vote for including the Martin's patch.\n\nCreating CVS repository with unnamed branch\n--8<--\nexport CVSROOT=$PWD/cvsroot\ncvs init\ncvs checkout .\nmkdir a\ncvs add a\ncd a\nvim a.txt\ncvs add a.txt\ncvs commit -m \"added a.txt\" a.txt\ncvs tag -b br1\ncvs update -r br1\necho \"br1 update\" >> a.txt\ncvs commit -m \"br1 update\" a.txt\ncvs update -A\necho \"HEAD update\" >> a.txt\ncvs commit -m \"HEAD update\" a.txt\ncvs tag -d br1\ncvs tag -b br1\ncvs tag -d -B br1\ncvs tag -b br1\ncvs update -r br1\necho \"branch update, once more\" >> a.txt\ncvs commit -m \"2nd branch update\" a.txt\n------\n\nand corresponding CVSPS output is\n--8<--\n$ cvsps -A\nWARNING: revision 1.1.2.1 of file a.txt on unnamed branch\n---------------------\nPatchSet 1 \nDate: 2006/06/19 20:10:09\nAuthor: sszakiro\nBranch: HEAD\nTag: (none) \nLog:\nadded a.txt\n\nMembers: \n        a.txt:INITIAL->1.1 \n\n---------------------\nPatchSet 2 \nDate: 2006/06/19 20:10:45\nAuthor: sszakiro\nBranch: #CVSPS_NO_BRANCH\nAncestor branch: HEAD\nTag: (none) \nLog:\nbr1 update\n\nMembers: \n        a.txt:1.1->1.1.2.1 \n\n---------------------\nPatchSet 3 \nDate: 2006/06/19 20:11:18\nAuthor: sszakiro\nBranch: HEAD\nTag: (none) \nLog:\nHEAD update\n\nMembers: \n        a.txt:1.1->1.2 \n\n---------------------\nPatchSet 4 \nDate: 2006/06/19 20:12:07\nAuthor: sszakiro\nBranch: br1\nAncestor branch: HEAD\nTag: (none) \nLog:\n2nd branch update\n\nMembers: \n        a.txt:1.2->1.2.2.1 \n------\n"}]}