git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Yann Dirson <ydirson@altern.org>
Date
Jul 3, 2007, 21:43 UTC
Message-ID
<20070703214336.GC6361@nan92-1-81-57-214-146.fbx.proxad.net>

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};
  }
Message 1 of 1 in “Wrapper scripts to help git-cvsimport cope with cvs 1.12 breakage”
  1. Yann DirsonJul 3, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.