Project Home

xxdiff-patch

Author: Martin Blais <blais@furius.ca>
Version: 766

Abstract

This simple script splits the input patch for the individual files it represents, applies the individual patches to temporary files and for each, spawns an xxdiff for it. This effectively allows you merge the patch interactively. You can accept or reject a patch for each file. You can also merge the patch interactively with xxdiff, and select for the merged results to be applied on the output file.

Table of Contents

Description

This simple script splits the input patch for the individual files it represents, applies the individual patches to temporary files and for each, spawns an xxdiff for it. This effectively allows you merge the patch interactively. You can accept or reject a patch for each file. You can also merge the patch interactively with xxdiff, and select for the merged results to be applied on the output file.

If no <patchfile> is specified, xxdiff-patch attempts to read the patch from stdin.

Important: the new (patched) file will always be shown on the right. The patched file will display (patched) in its filename title. When a decision is asked to the user, ACCEPT always means keep/save the file that appears on the right. The script takes the following actions upon the answer:

If a patch for a file is accepted or merged, before being overwritten, a copy of the original files are saved with the extension .orig, like patch itself.

Note: notice that the --reverse and --invert options below are implementing orthogonal behaviour. It can be confusing to understand the differences between these two. If the a reverse patch is indeed reverting changes (and not constructed in the incorrect order), applying the patch will revert the changes as well (the display order is not changed). This behaviour is exactly like that of patch. Using invert, however, changes the logic of what this script does upon accepting or rejecting a patch. In any case, you will always find the 'new file if accepted' on the right side and the patched file is indicated with a string in the filename title.

Examples

To apply a patch, simply cd into the root of the directory where the patch should be applied, and invoke like this:

cat patchfile | xxdiff-patch

To preview the changes that have been made in a cvs checkout area, use the following command:

cvs diff | xxdiff-patch --reverse --invert --preview

(For better cvs-specific behaviour about committing changes, see script xxdiff-cvs-diff.)

Important

This script is unfinished, we still need to implement file addition/removal support.

Usage

xxdiff-patch [<options>] [<patchfile>]

Options

--version             show program's version number and exit
-h, --help            show this help message and exit
-x OPTS, --xxdiff-options=OPTS
                      specifies additional options to pass on to xxdiff.
-p OPTS, --patch-options=OPTS
                      specifies additional options to pass on to patch.
-s STRIP, --strip=STRIP
                      strip option to patch, provided for convenience.
-R, --reverse         apply the patch as a reverse patch (see
                      patch(1) option --reverse).  The patched file will be
                      shown as the new file regardless.
-I, --invert          change the order of the displayed files, so that
                      the patched file shows as the old file.  Accepting a
                      change will thus do nothing and rejecting a change
                      will copy the patched file over.
-n, --dry-run, --preview
                      don't apply the patch, just show the
                      differences (you don't have to make any decisions).
-B, --no-backup       disable backup filesa

Download

Download program here.

Requirements

Copyright

Copyright (C) 2003-2004 Martin Blais <blais@furius.ca>. This code is distributed under the terms of the GNU General Public License.