Wrapper scripts to help git-cvsimport cope with cvs 1.12 breakage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some of you may have noticed that cvs 1.12.x has a bad habit, when a
file gets added on a branch, of creating a dummy 1.x.2.1 revision of
the empty file on the branch.  What's annoying, is that the dummy
revision gets an erroneous timestamp, which makes the cvsps output
wrong, following the well-known GIGO principle.

Until someone (maybe me, but I can give no guaranty whatsoever) finds
the time to deal with this bug in cvsps, as well as avoiding at the
cvsps level the extra "file initially added on branch" dummy
revisions, here is a little perl filter that sanitizes the csvps
output, and a customizable git-cvsimport wrapper using it.

Best regards,
-- 
Yann
#!/usr/bin/perl
use strict;
use warnings;

$/='---------------------';

our @branches = qw/HEAD/;
our %parents = ();		# parents not yet recorded

# parsing state
our $patchset_is_valid;
our $patchset;

while(<>) {
  $patchset = $_;

  # skip first separator line
  if ($patchset eq $/) {
    print $patchset;
    next;
  }

  $patchset_is_valid = 1;
  my ($branch, $ancestor);
  if (m/^Branch: (.*)/m) {
    $branch = $1;
    if (!grep { $_ eq $branch } @branches) {
      push @branches, $branch;
    }
  } else {
    die "no branch in $patchset";
  }

  if (m/^Ancestor branch: (.*)/m) {
    $ancestor = $1;
    if (!grep { $_ eq $ancestor } @branches or
	m/^file .* was added on branch /m) {
      print STDERR "preparing $branch fixup\n";
      $patchset_is_valid = 0;
      $parents{$branch} = $ancestor;
    }
  }

  if (m/^file .* was added on branch /m) {
    $patchset_is_valid = 0;
  }

  if (defined $parents{$branch} and $patchset_is_valid) {
    print STDERR "finalizing $branch fixup\n";
    my $line = 'Ancestor branch: ' . $parents{$branch} . "\n";
    $patchset =~ s/^(?=Tag:)/$line/m;
    delete $parents{$branch};
  }

Attachment: fetch-from-cvs.sh
Description: Bourne shell script


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux