# HG changeset patch # User Pierre-Yves David # Date 2022-07-11 23:34:18 # Node ID 2bbd7bc7d6c4d54476619a48073a8c10569d80bc # Parent 23dd636852b8d23e4afcfa2aec5dcf923312d711 bundle: introduce a --exact option I have been wanting this options for a long time. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1484,6 +1484,13 @@ def branches(ui, repo, active=False, clo @command( b'bundle', [ + + ( + b'', + b'exact', + None, + _(b'compute the base from the revision specified'), + ), ( b'f', b'force', @@ -1553,6 +1560,7 @@ def bundle(ui, repo, fname, *dests, **op Returns 0 on success, 1 if no changes found. """ opts = pycompat.byteskwargs(opts) + revs = None if b'rev' in opts: revstrings = opts[b'rev'] @@ -1586,7 +1594,19 @@ def bundle(ui, repo, fname, *dests, **op ) if opts.get(b'base'): ui.warn(_(b"ignoring --base because --all was specified\n")) + if opts.get(b'exact'): + ui.warn(_(b"ignoring --exact because --all was specified\n")) base = [nullrev] + elif opts.get(b'exact'): + if dests: + raise error.InputError( + _(b"--exact is incompatible with specifying destinations") + ) + if opts.get(b'base'): + ui.warn(_(b"ignoring --base because --exact was specified\n")) + base = repo.revs(b'parents(%ld) - %ld', revs, revs) + if not base: + base = [nullrev] else: base = logcmdutil.revrange(repo, opts.get(b'base')) if cgversion not in changegroup.supportedoutgoingversions(repo): diff --git a/tests/test-bundle.t b/tests/test-bundle.t --- a/tests/test-bundle.t +++ b/tests/test-bundle.t @@ -718,7 +718,7 @@ Unbundle incremental bundles into fresh $ hg init empty $ hg -R test bundle --base null -r 0 ../0.hg 1 changesets found - $ hg -R test bundle --base 0 -r 1 ../1.hg + $ hg -R test bundle --exact -r 1 ../1.hg 1 changesets found $ hg -R empty unbundle -u ../0.hg ../1.hg adding changesets diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -261,7 +261,7 @@ Show all commands + options bookmarks: force, rev, delete, rename, inactive, list, template branch: force, clean, rev branches: active, closed, rev, template - bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure + bundle: exact, force, rev, branch, base, all, type, ssh, remotecmd, insecure cat: output, rev, decode, include, exclude, template clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos