Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] Re: (PR#2680) [PATCH] Cities window: hide/raise instead of
Home

[Freeciv-Dev] Re: (PR#2680) [PATCH] Cities window: hide/raise instead of

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: stepan@xxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2680) [PATCH] Cities window: hide/raise instead of destroy/create
From: "Reinier Post" <rp@xxxxxxxxxx>
Date: Tue, 4 Mar 2003 00:18:16 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Mon, Mar 03, 2003 at 02:35:48PM -0800, Vasco Alexandre da Silva Costa wrote:
> 
> On Mon, 3 Mar 2003, Stepan Roh wrote:
> 
> > Your patch is not correct, it has incomplete last header (for
> > gui_stuff.h). But code itself works great.
> 
> Doh. That is what I get for hand-converting from RCS diff to patch format.
> :-P
> 
> I guess I'll get some script to do this for me in the future.

Try this.  I wrote it to "un-CVS" a cvs diff, but it does a lot more now.
Patches on pubserver are fed through this before they are applied.
A possible way to apply:

  case "`cvsdiff2udiff $patch | p0p1`" in
  -p*) cvsdiff2udiff $patch | patch -f || exit 1;;
    *) exit 3;;
  esac

-- 
Reinier

#!/usr/bin/env perl
#
# cvsdiff2udiff - transforms a cvs diff into diff -u format for patch -p0
#
# $Id: cvsdiff2udiff,v 1.6 2002/11/06 13:35:47 gamecvs Exp $

# just patch it when it breaks, ok?

# note that the top directory may or may not end up in the end result,
# depending on the input, so we may have to patch with -p0 or -p1

while (<>) {

  if (/^Index: / || /^===/ || /^RCS file: / || /^retrieving  revision /) {
    next;
  }

  if (!/^diff\s+/) {
    # huh?
    print;
    next;
  }

  my $diffopts = $';
  $diffopts =~ s/\s+\S+\s+\S+\s*$//;

  if ($diffopts !~ /-\S*u/) {
    # only unified diffs are supported for now
    die "unexpected input line (we only support diff -u): $_";
  }

  chomp($_ = <>);

  if (!/^---\s+(\S+)(\s+\S.*)/) {
    # huh?
    die "unexpected input line: $_";
  }
  my $origdate = $2;

  chomp($_ = <>);

  if (!/^\+\+\+\s+(\S+)(\s+\S.*)/) {
    # huh?
    die "unexpected input line: $_";
  }
  my $newdate = $2;
  my $file = $1;  $file =~ s/:[^:]+$//;

  print "diff $diffopts $file $file\n";
  print "--- $file$origdate\n";
  print "+++ $file$newdate\n";
}
#!/usr/bin/env perl

use strict;

while (<>) {

  next unless /^\+\+\+/;

  my ($sep, $file) = split;
  $file =~ s/:[^:]+$//;
  $file =~ s#\.orig##;

  if ( -f $file) {
    print "-p0\n";
    exit 0;
  }

  my $file2 = $file; $file2 =~ s#[^/]+/##;
  $file2 =~ s#\.orig##;

  if ( -f $file2) {
    print "-p1\n";
    exit 0;
  } 

  # perhaps the file is new?

  my $dir1 = $file;
  $dir1 =~ s#/+[^/]+$##;

  if ( -d $dir1) {
      print "-p0\n";
    exit 0;
  }

  my $dir2 = $file2;
  $dir2 =~ s#/+[^/]+$##;

  if ( -d $dir2) {
      print "-p1\n";
    exit 0;
  }

  my $cwd = `pwd`;  chomp $cwd;
  my $me = $0;  $me =~ s#.*/##;

  die "$me: neither $dir1 nor $dir2 found in $cwd, giving up\n";
}

[Prev in Thread] Current Thread [Next in Thread]