Migration notes¶

Migration and deprecation notes for libvcs are here, see Changelog as well.

Welcome on board! đź‘‹

  1. 📌 For safety, always pin the package

  2. đź“– Check the migration notes (You are here)

  3. 📣 If you feel something got deprecated and it interrupted you - past, present, or future - voice your opinion on the tracker.

    We want to make libvcs fun, reliable, and useful for users.

    API changes can be painful.

    If we can do something to draw the sting, we’ll do it. We’re taking a balanced approach. That’s why these notes are here!

    (Please pin the package. 🙏)

Next release¶

Notes on the upcoming release will be added here

libvcs 0.48.0 (2026-11-29)¶

Git version handling API changes (#491)¶

  • Git.version() now returns a Version object instead of a string, and Git.version(build_options=True) moves to Git.build_options():

    Before:

    git = Git(path=path)
    version_str = git.version()
    build_str = git.version(build_options=True)
    

    After:

    git = Git(path=path)
    version_obj = git.version()
    version_str = ".".join(
        str(x) for x in (version_obj.major, version_obj.minor, version_obj.micro)
    )
    build_info = git.build_options()
    
  • GitSync.get_git_version() continues to return a string for backward compatibility.

API Naming Consistency (#507)¶

Parameters and remote getters follow Python community naming conventions (Django, pytest, Sphinx).

libvcs.cmd.git: Renamed _all parameters¶

_all parameters take descriptive names across Git and its managers:

Method

Old

New

clone()

_all

all_branches

fetch()

_all

all_remotes

pull()

_all

all_remotes

help()

_all

show_all

rev_list()

_all

include_all_refs

remote.get_url()

_all

all_urls

stash.save()

_all

include_ignored

stashes.push()

_all

include_ignored

branches.ls()

_all

all_branches

Before:

git.fetch(_all=True)
git.stash.save(_all=True)

After:

git.fetch(all_remotes=True)
git.stash.save(include_ignored=True)

libvcs.sync: Remote getter methods¶

Remote getters in GitSync and HgSync use the get_ prefix, and HgSync adds get_remote() for single-alias lookup:

Class

Old

New

GitSync

remotes()

get_remotes()

GitSync

remote(name)

get_remote(name)

HgSync

remotes()

get_remotes()

HgSync

—

get_remote(name)

Before:

git_repo.remotes()
git_repo.remote("origin")
hg_repo.remotes()

After:

git_repo.get_remotes()
git_repo.get_remote("origin")
hg_repo.get_remotes()
hg_repo.get_remote("default")

libvcs 0.47.0 (2026-11-28)¶

Sync results and dirty checkout policy¶

update_repo() creates or updates a checkout and returns SyncResult. Check result.ok and its ordered errors before proceeding. obtain() only creates the initial checkout.

The default is now SyncPolicy(drift="follow", dirty="abort"). Automation that updates dirty checkouts must choose dirty="preserve" to retain recoverable changes or explicitly choose dirty="discard" to remove them. The library does not prompt for discard. Preservation may report conflicts; it never falls back to discard.

Pass target=SyncTarget(...) and policy=SyncPolicy(...) to update_repo(). A method target replaces the constructor’s rev default. Existing Git/Hg keep/warn operations do not fetch or change attachment; new checkouts first establish their configured target. SVN keep/warn requires a numeric revision for local comparison.

Retain result.recovery on both successful and failed updates. Tokens stay available until release_changes(); list_recoveries() discovers them and recover_changes() writes a separate new checkout. See the executing recovery example and backend limits before deleting source repositories or recovery storage.

Mercurial remotes and selected pull sources¶

Use HgSync(remotes={"upstream": HgRemote("upstream", fetch_url, push_url)}) to declare native Mercurial paths. A string value sets both destinations to that URL. Pass SyncTarget(branch="default", remote="upstream") to choose the pull source independently of the push URL.

Following updates apply configured paths. On existing checkouts, keep/warn policies and dirty-abort preflight leave .hg/hgrc unchanged. The library owns a final marked [paths] block; comments and includes outside it remain intact. Leave that block last when editing native configuration manually.

Sync backends use typed options¶

Backend-specific constructor arguments move into frozen option objects. Import the option class from libvcs or beside its sync class:

>>> from libvcs import GitOptions, GitSync, HgOptions, SvnOptions
>>> git = GitSync(
...     url="https://example.com/project.git",
...     path=tmp_path / "project",
...     options=GitOptions(depth=1, tls_verify=True),
... )
>>> git.options
GitOptions(depth=1, filter=None, tls_verify=True)

Replace the released Git constructor arguments as follows:

  • git_shallow=True becomes options=GitOptions(depth=1).

  • depth=n becomes options=GitOptions(depth=n).

  • git_filter=value becomes options=GitOptions(filter=value).

  • The old tls_verify=True disabled verification. Use options=GitOptions(tls_verify=False) to retain that behavior. The new default, tls_verify=True, verifies certificates.

Mercurial transport settings belong to HgOptions. Subversion username, password, and svn_trust_cert become SvnOptions(username=...), SvnOptions(password=...), and SvnOptions(trust_server_cert=...). Constructors and create_project() reject unknown keywords instead of silently retaining or discarding them. Use dataclasses.fields(Sync.options_type) to enumerate a backend’s accepted configuration fields.

Git partial-clone filters have typed models¶

String _filter arguments remain valid. Callers that build filters from configuration can replace unchecked strings with models or kind-tagged mappings from libvcs.cmd.git_filter:

>>> from libvcs.cmd.git_filter import BlobLimit
>>> BlobLimit("4m")
BlobLimit(limit='4m')

GitOptions(filter=...) validates the value during construction, applies it to the initial clone and its submodules, and leaves existing checkout filters unchanged during updates. Auto requires Git 2.54 or newer. If the cloned repository contains gitlinks, GitSync retains the parent clone and raises before submodule initialization because Git’s submodule command rejects auto. Use an explicit filter for repositories with submodules.

pytest fixtures: gitconfig / hgconfig renamed to vcs_gitconfig / vcs_hgconfig (#528)¶

  • pytest: gitconfig renamed to vcs_gitconfig

  • pytest: set_gitconfig renamed to set_vcs_gitconfig

  • pytest: hgconfig renamed to vcs_hgconfig

  • pytest: set_hgconfig renamed to set_vcs_hgconfig

The unprefixed names collided with the third-party pytest-gitconfig plugin, which exposes a gitconfig fixture returning a GitConfig helper rather than a pathlib.Path. When both plugins auto-loaded, downstream tests crashed with AttributeError: 'PosixPath' object has no attribute 'set'.

No deprecation alias is provided – update parameter names in test suites, conftests, and any embedded pytester.makeconftest text that references these fixtures.

pytest fixtures: git_local_clone renamed to example_git_repo (#468)¶

  • pytest: git_local_clone renamed to example_git_repo

Commands: Listing method renamed (#466)¶

  • libvcs.cmd.git.GitCmd._list() -> libvcs.cmd.git.Git.ls()

  • libvcs.cmd.svn.Svn._list() -> libvcs.cmd.svn.Svn.ls()

libvcs 0.30.0 (2024-06-18)¶

URLs: Variable renamings and moves (#463)¶

  • RE_PIP_REV moved from libvcs.url.git to libvcs.url.constants.

  • RE_PATH has changed:

    • The pattern for user matching (e.g., git@) has been extracted to RE_USER.

    • RE_PATH and SCP_REGEX (now RE_SCP) no longer include user regex pattern

    • Existing patterns now use RE_USER explicitly.

  • REGEX_SCP renamed to RE_SCP for consistency.

libvcs 0.20.0 (2022-10-31)¶

URLs: Mapping now class attributes (#433)¶

URL.rule_map is now a class attribute rather than a dataclass attribute.

Before Python 3.11 rejected mutable dataclass defaults:

>>> import dataclasses
>>> from libvcs.url.base import RuleMap
>>> @dataclasses.dataclass(repr=False)
... class GitLabURL:
...     rule_map: RuleMap = RuleMap(_rule_map={})
Traceback (most recent call last):
...
ValueError: mutable default <class 'libvcs.url.base.RuleMap'> for field rule_map is not allowed: use default_factory

After release:

>>> import dataclasses
>>> from libvcs.url.base import RuleMap
>>> from libvcs.url.git import GitURL, DEFAULT_RULES
>>> @dataclasses.dataclass(repr=False)
... class MyGitURL(GitURL):
...     rule_map = RuleMap(
...         _rule_map={'gitlab_prefix': DEFAULT_RULES}
...     )