# HG changeset patch # User Pierre-Yves David # Date 1703696546 -3600 # Node ID c17cf2d51ff48ea840e29ab941cec900419170ab # Parent 51021612aea72e6dc4bdf0bbe85659530b32c18b bundle: do not detect --base argument that match nothing as lack of argument With the previous version of the code, if --base did not match anything, it will be handled as if no --base was provided and will fallback to using discovery with the default path. This has two issues : - The resulting bundle won't match what the user requested, - if not default path is configured, it will crash. We now properly distinct between the two cases and if the --base query does not find any changeset, we will assume that everything under --rev needs to be sent. diff -r 51021612aea7 -r c17cf2d51ff4 mercurial/commands.py --- a/mercurial/commands.py Wed Dec 27 18:42:13 2023 +0100 +++ b/mercurial/commands.py Wed Dec 27 18:02:26 2023 +0100 @@ -1592,13 +1592,13 @@ _(b'packed bundles cannot be produced by "hg bundle"'), hint=_(b"use 'hg debugcreatestreamclonebundle'"), ) - + base_opt = opts.get('base') if opts.get('all'): if dests: raise error.InputError( _(b"--all is incompatible with specifying destinations") ) - if opts.get('base'): + if base_opt: ui.warn(_(b"ignoring --base because --all was specified\n")) if opts.get('exact'): ui.warn(_(b"ignoring --exact because --all was specified\n")) @@ -1608,19 +1608,24 @@ raise error.InputError( _(b"--exact is incompatible with specifying destinations") ) - if opts.get('base'): + if base_opt: ui.warn(_(b"ignoring --base because --exact was specified\n")) base = repo.revs(b'parents(%ld) - %ld', revs, revs) if not base: base = [nullrev] + elif base_opt: + base = logcmdutil.revrange(repo, base_opt) + if not base: + # base specified, but nothing was selected + base = [nullrev] else: - base = logcmdutil.revrange(repo, opts.get('base')) + base = None if cgversion not in changegroup.supportedoutgoingversions(repo): raise error.Abort( _(b"repository does not support bundle version %s") % cgversion ) - if base: + if base is not None: if dests: raise error.InputError( _(b"--base is incompatible with specifying destinations") diff -r 51021612aea7 -r c17cf2d51ff4 tests/test-bundle-r.t --- a/tests/test-bundle-r.t Wed Dec 27 18:42:13 2023 +0100 +++ b/tests/test-bundle-r.t Wed Dec 27 18:02:26 2023 +0100 @@ -141,14 +141,9 @@ ignoring --base because --all was specified 9 changesets found $ hg -R test bundle --base 3-3 -r tip test-base-match-nothing-with-dest.hg --config paths.default=$TESTTMP/test-3 - searching for changes (known-bad-output !) - 1 changesets found (known-bad-output !) - 5 changesets found (missing-correct-output !) + 5 changesets found $ hg -R test bundle --base 3-3 -r tip test-base-match-nothing-no-dest.hg - config error: default repository not configured! (known-bad-output !) - (see 'hg help config.paths') (known-bad-output !) - 5 changesets found (missing-correct-output !) - [30] + 5 changesets found $ hg -R test bundle --base 3 -r tip test-bundle-should-fail.hg 1 changesets found