{"thread":{"id":"8844","subject":"Wrapper scripts to help git-cvsimport cope with cvs 1.12 breakage","startedAt":"2007-07-03T21:43:36Z","lastAt":"2007-07-03T21:43:36Z","messageCount":1,"participants":["Yann Dirson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"46409","messageId":"20070703214336.GC6361@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"8844","inReplyTo":null,"subject":"Wrapper scripts to help git-cvsimport cope with cvs 1.12 breakage","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-07-03T21:43:36Z","receivedAt":"2007-07-03T21:43:36Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"Some of you may have noticed that cvs 1.12.x has a bad habit, when a\nfile gets added on a branch, of creating a dummy 1.x.2.1 revision of\nthe empty file on the branch.  What's annoying, is that the dummy\nrevision gets an erroneous timestamp, which makes the cvsps output\nwrong, following the well-known GIGO principle.\n\nUntil someone (maybe me, but I can give no guaranty whatsoever) finds\nthe time to deal with this bug in cvsps, as well as avoiding at the\ncvsps level the extra \"file initially added on branch\" dummy\nrevisions, here is a little perl filter that sanitizes the csvps\noutput, and a customizable git-cvsimport wrapper using it.\n\nBest regards,\n-- \nYann\n\n\n#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n$/='---------------------';\n\nour @branches = qw/HEAD/;\nour %parents = ();\t\t# parents not yet recorded\n\n# parsing state\nour $patchset_is_valid;\nour $patchset;\n\nwhile(<>) {\n  $patchset = $_;\n\n  # skip first separator line\n  if ($patchset eq $/) {\n    print $patchset;\n    next;\n  }\n\n  $patchset_is_valid = 1;\n  my ($branch, $ancestor);\n  if (m/^Branch: (.*)/m) {\n    $branch = $1;\n    if (!grep { $_ eq $branch } @branches) {\n      push @branches, $branch;\n    }\n  } else {\n    die \"no branch in $patchset\";\n  }\n\n  if (m/^Ancestor branch: (.*)/m) {\n    $ancestor = $1;\n    if (!grep { $_ eq $ancestor } @branches or\n\tm/^file .* was added on branch /m) {\n      print STDERR \"preparing $branch fixup\\n\";\n      $patchset_is_valid = 0;\n      $parents{$branch} = $ancestor;\n    }\n  }\n\n  if (m/^file .* was added on branch /m) {\n    $patchset_is_valid = 0;\n  }\n\n  if (defined $parents{$branch} and $patchset_is_valid) {\n    print STDERR \"finalizing $branch fixup\\n\";\n    my $line = 'Ancestor branch: ' . $parents{$branch} . \"\\n\";\n    $patchset =~ s/^(?=Tag:)/$line/m;\n    delete $parents{$branch};\n  }\n"}]}