Skip to main content

Diff a directory and sync changes.

Project description

ddir

Lint commit message pytest release GitHub release

ddir is a command line tool to calculate diffs between two directories and resolve them.

Check out the diff file format as well.

Installation

pip install ddir

This will install a binary called ddir on your PATH that you can execute. Depending on your system, you may need sudo/admin permissions.

Installation on macOS

In case you're using Homebrew, the installation via pip fails (at least on my machine). In that case, create a virtual environment and install ddir in there. The venv directory will be set ignored when initializing a new directory. In case you have ddir-controlled directory that has been initialized with an older version, please add venv to .ddir/ddir.json.

Usage

Usage: ddir <commands>

Available commands:
    help                                - show this help
    version                             - show version
    init                                - initialize a source directory
    diff create <name>                  - create a diff for a target
    diff resolve <name> --modes <modes> - resolve a diff for a target
    diff list <name>                    - list all diffs for a target
    target create                       - create a target in interactive mode
    target list                         - list all targets
    target delete <name>                - delete target
    legacy migrate                      - migrate from legacy ddir

Fast mode

If you just want to compare change dates of files and not their content (md5 hash), you can use the fast mode. Set that option when creating a target.

Modes to resolve

The modes work like this: for each type (the order is +, -, >, <, ?) a number in the tuple indicates how to handle diffs of that type. There are the following modes:

  • 0: skip
  • 1: apply (type dependent, see below)
  • 2: choose manually

When choosing to apply diffs, the following will happen:

  • +, >, ?: override destination element with source element
  • <: override source element with destination element
  • -: delete destination element

The diff file format

A diff file stores the differences between a file or a directory at a source compared to a destination.

Specification

We call a file or a directory an element. The type of one element is either d for directory or f for file.

We differentiate between five diff types:

  • + (positive diff): an element exists in the source but not the destination
  • - (negative diff): an element exists in the destination but not the source
  • > (newer diff): the source element is newer than the destination element
  • < (older diff): the source element is older than the destination element
  • ? (unknown diff): the elements are somehow different, but we can't categorize them; used if files differ but change dates are equal; requires manual resolution

The diff file is a newline-separated text file with each line containing an individual diff. Each line has the format:

{diff type}:{element type}:{first element}:{second element}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ddir-3.0.1-py3-none-any.whl (14.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page