Menu

#18 Wish: using diff for inteligent patching

open
None
5
2004-11-03
2002-03-22
No

Hi!

Here's what would make xxdiff usefull to me. (You asked
on linux kernel, that's why you are getting this comment).

Task is updating to next version by linux, when you already
have some changes in your tree. You can probably assume
that each developer also stores official source without
changes somewhere.

So task is to apply patch-2.4.19 over linux directory
with local changes, when you have clean directory
[where you know patch applies without rejects for sure].

As much as possible should be done automatically -- if
it does not conflict within 3 lines, automerge it.

I do not think this is easily done with xxdiff, currently,
and it would be very usefull.

Pavel

Discussion

  • Martin Blais

    Martin Blais - 2002-04-16
    • assigned_to: nobody --> blais
     
  • Tomas Pospisek

    Tomas Pospisek - 2002-11-02

    Logged In: YES
    user_id=15179

    Have you ever recieved a patch against xxdiff Martin? Today
    I had to slump through a whole pile of patches and I wished
    xxdiff had that feature. That is:

    xxdiff file.c hackers_delight.diff

    xxdiff takes file.c, copies it to some /tmp, applies
    hackers_delight.diff and shows you the diff.

    Erm, wait - that could be done through some script... I'll have a
    try.

    Greets,
    *t

     
  • Tomas Pospisek

    Tomas Pospisek - 2002-11-03

    Logged In: YES
    user_id=15179

    So here we go. Martin, Pavel, let me know whether you like it.
    *t

    #!/usr/bin/perl
    #
    # (gpl) by tomas pospisek <tpo_deb@sourcepole.ch>

    use strict;
    use warnings;
    use English;

    sub main();
    main();

    sub usage() {
    print "xxpatch file|dir diff [diff] [...]\n";
    print "\tPatch file or directory with diff[s] and display the
    diff\n";
    print "\twith xxdiff. The original file or directory is left
    unaltered\n";
    print "\tThe diff has to be in a format that print lets patch
    guess the\n";
    print "\tfilename to patch, like f.ex. the \"diff -u\" format.\n";
    exit 1;
    }

    sub main() {
    my $fileOrDir = shift (@ARGV);
    my $tempdir = `mktemp -t -d xxdiff.XXXXXXXXXX`;
    $? == 0 or die;
    chop $tempdir;

    my $curdir = `pwd`;
    my $copy = `basename $fileOrDir`; chop $copy;

    print "file: $fileOrDir\n";

    usage() unless (defined($fileOrDir) and defined($ARGV[0])) ;

    # make a copy of the file|dir to patch
    system("cp -a $fileOrDir $tempdir") == 0 or die;

    chdir $tempdir or die "Couldn't change into $tempdir\n";

    # change into $tempdir and maybe into copy-dir
    if ( -d $fileOrDir ) {
    print "xxpatching directory $fileOrDir\n";
    chdir $copy or die "Couldn't change into
    $tempdir/$copy\n";
    } else {
    print "xxpatching file $fileOrDir\n";
    }

    # apply patches
    while( $_ = shift(@ARGV) ) {
    system("patch < $_"); $? == 0 or die;
    }

    # exec xxdiff an patched copy
    chdir $tempdir or die "Couldn't change into $tempdir\n";
    system("xxdiff $fileOrDir $copy");

    # don't like this, but is there a better way?
    system("rm -r $tempdir");
    }

     
  • Tomas Pospisek

    Tomas Pospisek - 2002-11-28

    Logged In: YES
    user_id=15179

    I'm slowly fixing my little script some more. Up to date versions of
    it can be found here:

    http://sourcepole.ch/sources/software/xxdiff/
    *t

     
  • Martin Blais

    Martin Blais - 2003-03-18
    • assigned_to: blais --> nobody
     
  • Martin Blais

    Martin Blais - 2004-11-03
    • assigned_to: nobody --> blais
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.