Skip to main content

vcsgraph

A Python library providing graph algorithms optimized for version control systems.

Overview

vcsgraph is a high-performance graph algorithms library specifically designed for working with version control system (VCS) data structures. It provides efficient implementations of common graph operations needed by VCS tools, with both pure Python and Rust-accelerated implementations for performance-critical operations.

Features

  • Topological Sorting: Multiple algorithms for sorting commits/revisions in topological order
  • Graph Traversal: Efficient algorithms for traversing revision graphs and finding common ancestors
  • Multi-parent Support: Handle complex merge scenarios with multiple parent revisions
  • Known Graph Operations: Optimized operations on graphs where the full structure is known in advance
  • Rust Acceleration: Performance-critical algorithms implemented in Rust with Python bindings via PyO3

Installation

pip install vcsgraph

Key Components

Graph Operations

The Graph class provides fundamental graph operations:

  • Finding least common ancestors (LCA)
  • Finding unique ancestors
  • Computing differences between revision sets
  • Finding merge bases between branches

Topological Sorting

Multiple sorting implementations optimized for different use cases:

  • topo_sort(): Fast sorting when the complete result is needed
  • TopoSorter: Iterator-based sorting for processing partial results
  • MergeSorter: Specialized sorting that preserves merge history

Multi-parent Diffs

The MultiParent class handles complex diff scenarios with multiple parent revisions, essential for three-way merges and conflict resolution.

Known Graph

The KnownGraph class provides optimized operations when the complete graph structure is known, enabling faster ancestor calculations and traversals.

Usage Examples

Basic Topological Sort

from vcsgraph import topo_sort

# Define a graph as a list of (node, parents) tuples
graph = [
    (b'rev1', []),
    (b'rev2', [b'rev1']),
    (b'rev3', [b'rev1']),
    (b'rev4', [b'rev2', b'rev3']),
]

# Sort nodes topologically (parents before children)
sorted_nodes = topo_sort(graph)

Using Graph for Ancestry Operations

from vcsgraph import Graph, DictParentsProvider

# Create a parents provider from a dictionary
ancestry = {
    b'rev1': (b'null:',),
    b'rev2a': (b'rev1',),
    b'rev2b': (b'rev1',),
    b'rev3': (b'rev2a',),
    b'rev4': (b'rev3', b'rev2b'),
}
parents_provider = DictParentsProvider(ancestry)

# Create a graph and find merge bases
graph = Graph(parents_provider)
merge_base = graph.find_merge_base(b'rev2a', b'rev2b')

Working with Known Graphs

from vcsgraph import KnownGraph

# Create a known graph from parent relationships
parent_map = {
    b'rev1': (b'null:',),
    b'rev2': (b'rev1',),
    b'rev3': (b'rev2',),
}
kg = KnownGraph(parent_map)

# Get heads (revisions with no children)
heads = kg.heads([b'rev1', b'rev2', b'rev3'])

Performance

The library uses Rust for performance-critical operations while maintaining a Python interface. Key optimizations include:

  • Memory-efficient graph representations
  • Optimized ancestor searching algorithms
  • Lazy evaluation where possible
  • Caching of frequently accessed data

License

This project is licensed under the GNU General Public License v2 or later. See the COPYING.txt file for details.

Origins

This library was originally part of the Breezy version control system and has been extracted as a standalone package for use in other VCS-related projects.

Release files for vcsgraph 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vcsgraph 0.3.2
File Size Uploaded
vcsgraph-0.3.2.tar.gz 99.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for vcsgraph 0.3.2
File
vcsgraph-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
vcsgraph-0.3.2-cp313-cp313-manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ ARM64 Details
vcsgraph-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
vcsgraph-0.3.2-cp312-cp312-manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64 Details
vcsgraph-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
vcsgraph-0.3.2-cp311-cp311-manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ ARM64 Details
vcsgraph-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
vcsgraph-0.3.2-cp310-cp310-manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ ARM64 Details

Total release size: 5.1 MB

Release files / vcsgraph-0.3.2.tar.gz

Download URL vcsgraph-0.3.2.tar.gz
Size 99.2 kB
Tags Source
SHA-256 checksum
How to use checksums
814a429ba0372b9e443c88b9708eee4bfac33aad3e97dc64fb4e5ffe34e1102b
BLAKE2b-256 checksum
How to use checksums
ff7af2d48eb3ee38aca9b11644a8240f16c6d445f2027437c566db71b6afcd0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / vcsgraph-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL vcsgraph-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl
Size 639.1 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
88031e5bcb0b00f2b138de406fb5a3b756fd3c107fb1b5062d01c7de38b94bb1
BLAKE2b-256 checksum
How to use checksums
17377d409457c63cac370109c0071f713f5588c95c5161108e3a93436c65bd4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / vcsgraph-0.3.2-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL vcsgraph-0.3.2-cp313-cp313-manylinux_2_28_aarch64.whl
Size 599.6 kB
Tags CPython 3.13 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
ce42bb6cf1cbe98fc6902e32722e1e5dc62d9442969875a51bce98556acab123
BLAKE2b-256 checksum
How to use checksums
ba4a9bd8194f14bbb17e4be68fc35b854d2c5943d9558cae42bf692ee321d1d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / vcsgraph-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL vcsgraph-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl
Size 639.5 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7148a038831136ffe0211ba71387d459fefc3f9bccf496affc92f481112b57d9
BLAKE2b-256 checksum
How to use checksums
c1209f66d99d8611572db6280013a3ae4acbfb50d7668fd789f139d696bc4b94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / vcsgraph-0.3.2-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL vcsgraph-0.3.2-cp312-cp312-manylinux_2_28_aarch64.whl
Size 600.2 kB
Tags CPython 3.12 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
0aa0de480fb694f516180138b906c89363f8d84b1d5527b4a4718b7f3d93c437
BLAKE2b-256 checksum
How to use checksums
14f8456731e85f795ac2067bb0b2a4233d84be8d3f820c8779ffd3aad5cab378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / vcsgraph-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL vcsgraph-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl
Size 642.4 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
fd9874a3489836e2f66cc69910f3d4c358d0c867b69aa1e645acd90e18839df0
BLAKE2b-256 checksum
How to use checksums
b9d4fb685b276cb1ff12d886307a82ba6d878364b79dba6ad46e2cc7d98a8eba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / vcsgraph-0.3.2-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL vcsgraph-0.3.2-cp311-cp311-manylinux_2_28_aarch64.whl
Size 605.1 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
8c7b17c5a142310fcf7189afd947d9c6939020e688b32c9343862aba32c6214b
BLAKE2b-256 checksum
How to use checksums
30d4bc024931540422989c16b4f8b123e27c911edb8b32fdc777f0657fa0d28b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / vcsgraph-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL vcsgraph-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl
Size 644.9 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9d23279f1cbf776b53c9e4b6fad86a3188ce775c6bdbfd552a8ad9efc7cc81bd
BLAKE2b-256 checksum
How to use checksums
1ef0c573562988efeb9aa5a10b3b8c60e788d405ddf85d4c5c283cd09624f896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release files / vcsgraph-0.3.2-cp310-cp310-manylinux_2_28_aarch64.whl

Download URL vcsgraph-0.3.2-cp310-cp310-manylinux_2_28_aarch64.whl
Size 608.1 kB
Tags CPython 3.10 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
bf453d9feffd55488432ebf4407a01930939b78d138172402a3bb4c5b8054a40
BLAKE2b-256 checksum
How to use checksums
5a9d51e0a83824c03b2ba41d8fc5ac72f123b2478105ce232a7c089d8106467b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.2 This release

9 release files

0.1.2

11 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page