Migration and deprecation notes for libvcs are here, see {ref}history as well.
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. 🙏)
[tracker]: https://github.com/vcs-python/libvcs/discussions
Notes on the upcoming release will be added here
-
Git.version()now returns aVersionobject instead of a string, andGit.version(build_options=True)moves toGit.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.
Parameters and remote getters follow Python community naming conventions (Django, pytest, Sphinx).
_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)Remote getters in {class}~libvcs.sync.git.GitSync and
{class}~libvcs.sync.hg.HgSync use the get_ prefix, and HgSync adds
{meth}~libvcs.sync.hg.HgSync.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")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
{ref}recovery example <sync-recovery> and backend limits before deleting
source repositories or recovery storage.
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.
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=Truebecomesoptions=GitOptions(depth=1).depth=nbecomesoptions=GitOptions(depth=n).git_filter=valuebecomesoptions=GitOptions(filter=value).- The old
tls_verify=Truedisabled verification. Useoptions=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.
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:
gitconfigrenamed tovcs_gitconfig - pytest:
set_gitconfigrenamed toset_vcs_gitconfig - pytest:
hgconfigrenamed tovcs_hgconfig - pytest:
set_hgconfigrenamed toset_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:
git_local_clonerenamed toexample_git_repo
libvcs.cmd.git.GitCmd._list()->libvcs.cmd.git.Git.ls()libvcs.cmd.svn.Svn._list()->libvcs.cmd.svn.Svn.ls()
-
RE_PIP_REVmoved fromlibvcs.url.gittolibvcs.url.constants. -
RE_PATHhas changed:- The pattern for user matching (e.g.,
git@) has been extracted toRE_USER. RE_PATHandSCP_REGEX(nowRE_SCP) no longer include user regex pattern- Existing patterns now use
RE_USERexplicitly.
- The pattern for user matching (e.g.,
-
REGEX_SCPrenamed toRE_SCPfor consistency.
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_factoryAfter 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}
... )