Giter Site home page Giter Site logo

com.zutubi.diff's Introduction

Zutubi Diff

Introduction

Zutubi Diff is a Java library for parsing and applying patch files in unified diff and other formats. You can think of it as the library equivalent of the patch(1) utility, with the beginnings of support for more than just unified diffs.

Home Page

Zutubi diff has home on the web at:

http://zutubi.com/source/projects/com.zutubi.diff/

License

Zutubi diff is licensed under the Apache License, version 2.0. See the LICENSE file for details.

Quick Start

The best way to illustrate usage is with a simple example:

PatchFileParser parser = new PatchFileParser(new UnifiedPatchParser());
PatchFile patchFile = parser.parse(new FileReader("/path/to/my.patch"));
patchFile.apply(toDirectory, 3);

This code parses a patch from the file my.patch and applies it to the directory toDirectory, stripping 3 slashes from the paths. It is analogous to running:

$ cd toDirectory
$ patch -p3 < /path/to/my.patch

Full code for this example can be found in the examples/patch directory. See below for build instructions.

Supported Formats

Currently full support is provided for unified diffs in the package com.zutubi.diff.unified. Limited support for git diffs, an extension of the unified format used by git, Mercurial and other tools, is provided in the com.zutubi.diff.git package. At present application of git diffs is not implemented.

Building

A simple Gradle (http://gradle.org/) build is included. To build the library as a jar run:

$ gradle jar

The jar will appear in build/libs. There are no dependencies - the jar stands alone. The build has only been tested with Gradle 1.2.

Example

After building the main jar, you can build the example in a similar way. You can then run it as a very-limited version of patch:

$ cd examples/patch
$ gradle jar
$ java -jar build/libs/patch.jar -p3 < my.patch

The patch can only be applied to the working directory.

Javadoc

You can generate full Javadoc for the library by running:

$ gradle javadoc

The documentation will appear in build/docs/javadoc.

Feedback

Feedback and contributions are welcome! Please contact:

[email protected]

or simply fork away!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.