Skip to main content

Graph algorithms for version control systems

Project description

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.

Project details


Download files

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

Source Distribution

vcsgraph-0.1.2.tar.gz (73.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vcsgraph-0.1.2-cp313-cp313-manylinux_2_28_x86_64.whl (374.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

vcsgraph-0.1.2-cp313-cp313-manylinux_2_28_aarch64.whl (365.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

vcsgraph-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl (374.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

vcsgraph-0.1.2-cp312-cp312-manylinux_2_28_aarch64.whl (365.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

vcsgraph-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl (377.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

vcsgraph-0.1.2-cp311-cp311-manylinux_2_28_aarch64.whl (368.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

vcsgraph-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl (379.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

vcsgraph-0.1.2-cp310-cp310-manylinux_2_28_aarch64.whl (370.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

vcsgraph-0.1.2-cp39-cp39-manylinux_2_28_x86_64.whl (381.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

vcsgraph-0.1.2-cp39-cp39-manylinux_2_28_aarch64.whl (373.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ ARM64

File details

Details for the file vcsgraph-0.1.2.tar.gz.

File metadata

  • Download URL: vcsgraph-0.1.2.tar.gz
  • Upload date:
  • Size: 73.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for vcsgraph-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b6ffad7a271f2d19441e6a5795dbc2c08076acfe72958627ff2856e0691f0030
MD5 4555a7d686616eda2b3ecc235a83bcbc
BLAKE2b-256 f2d30fe11babb3d1fb21d5c87b9dcd54cf4966fe6dd9827148d837f47c3494d0

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d5f6f075c7993524cdf280c57b4353f64ef921bb668b51247df95f8f1f56aa23
MD5 5c8169ee68967587c56aefea772803b2
BLAKE2b-256 fd56232acff13ffea46be360afdd1754e61220a7934d566e02bc59325b3f5431

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 21252507f537cacf22f131425b64f9cfd32e91b4f0ae2bf160a4959e0dc92940
MD5 d74790d48769f97f05e96978bea5da71
BLAKE2b-256 c23845817f76e033b6b3036f09a2522018939c2e8f68e4f277182fc68e5b7b54

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b2a4c86ef41eabac3e0c3fcda695db1575508c063dc96b93c0bf85cab8608a39
MD5 25c6db87e34de2e21e3209711e6f3311
BLAKE2b-256 26bdc448d764c9ccbb5bd34dbf0bebd7ba503f757f95e92fe7ebd01f5454e9b6

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b279ad3b1ce510596d16bd137a7c258bcf4d166e48ef06fc47fc40e7b300b5df
MD5 83affb3cee966cf78ed5447552ae39c8
BLAKE2b-256 cd9e0330623508cfdeeee44cde2b83baa49a5adedc99bd1432cfee361d4dc66e

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fda1402cd5e7b3cbef680d0437a0bff361f1580eb14e85472b4b115c2f5dbacf
MD5 64bed6c7efa69010f0892e049e404f6f
BLAKE2b-256 ad1593ee56af9d42a8df964b846c8c71bf921ac05b92a6988f3bb2d5bacb264f

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e80757370dad5a2406dccf4747dbbfa072c2fcb7a6a6f2b4d4fd3073ce2a6ba2
MD5 c18d7fb081d0214cf3fa230a38562175
BLAKE2b-256 b9d3cc7179bea51ae1fd4bf82fba9d9bd1b3220673032fb54cb36a8106082808

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 904f40fd527facc0eedf063adf6406d41ac42f5bc8a22ff26b252a8bdb40f0d7
MD5 fcf78e6dfcbdf058017e7929a1d2dc78
BLAKE2b-256 497c175069f0d98daae30717c5d83d62391802e24318d0fb92aebb2bab177ea1

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fe55ed3ef4b4ff18f48c262efb3e5262e75a1d2eb0a0e30ce870a4f309f4655b
MD5 482eb03ce63c07c806cf8525fc63609e
BLAKE2b-256 8fe93207b0b6db3781fa26588c65da4df4f49aeca6e8e1d621d8ca8879e5e833

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ff05c9b029ca9ff8c7ccf45ce28e5d82277af8cb74ecb8e6f4d724dc094a7a02
MD5 4bcc25e4302e96ae4130372a1bad60dd
BLAKE2b-256 a09025a310a5bc9f4228cd246b8678317cd18f4d30fd3ebf998196aabdc8673d

See more details on using hashes here.

File details

Details for the file vcsgraph-0.1.2-cp39-cp39-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vcsgraph-0.1.2-cp39-cp39-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3922eafa4ca0aff108ddb60648c8df408a9930edd5cd3a3df26e4315a1b7077b
MD5 ce59f837b7ab98dc564a8d36e0ac70fb
BLAKE2b-256 81369c660181f44a927d4b1ad3845ad9ee0ae7b6e50a8bcef5549e2957914703

See more details on using hashes here.

Supported by

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