comparison mercurial/commands.py @ 51154:c17cf2d51ff4 stable

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 27 Dec 2023 18:02:26 +0100
parents 752c5a5b73c6
children c6560ee526d2 7e6aae033d8d
comparison
equal deleted inserted replaced
51153:51021612aea7 51154:c17cf2d51ff4
1590 if cgversion == b's1': 1590 if cgversion == b's1':
1591 raise error.InputError( 1591 raise error.InputError(
1592 _(b'packed bundles cannot be produced by "hg bundle"'), 1592 _(b'packed bundles cannot be produced by "hg bundle"'),
1593 hint=_(b"use 'hg debugcreatestreamclonebundle'"), 1593 hint=_(b"use 'hg debugcreatestreamclonebundle'"),
1594 ) 1594 )
1595 1595 base_opt = opts.get('base')
1596 if opts.get('all'): 1596 if opts.get('all'):
1597 if dests: 1597 if dests:
1598 raise error.InputError( 1598 raise error.InputError(
1599 _(b"--all is incompatible with specifying destinations") 1599 _(b"--all is incompatible with specifying destinations")
1600 ) 1600 )
1601 if opts.get('base'): 1601 if base_opt:
1602 ui.warn(_(b"ignoring --base because --all was specified\n")) 1602 ui.warn(_(b"ignoring --base because --all was specified\n"))
1603 if opts.get('exact'): 1603 if opts.get('exact'):
1604 ui.warn(_(b"ignoring --exact because --all was specified\n")) 1604 ui.warn(_(b"ignoring --exact because --all was specified\n"))
1605 base = [nullrev] 1605 base = [nullrev]
1606 elif opts.get('exact'): 1606 elif opts.get('exact'):
1607 if dests: 1607 if dests:
1608 raise error.InputError( 1608 raise error.InputError(
1609 _(b"--exact is incompatible with specifying destinations") 1609 _(b"--exact is incompatible with specifying destinations")
1610 ) 1610 )
1611 if opts.get('base'): 1611 if base_opt:
1612 ui.warn(_(b"ignoring --base because --exact was specified\n")) 1612 ui.warn(_(b"ignoring --base because --exact was specified\n"))
1613 base = repo.revs(b'parents(%ld) - %ld', revs, revs) 1613 base = repo.revs(b'parents(%ld) - %ld', revs, revs)
1614 if not base: 1614 if not base:
1615 base = [nullrev] 1615 base = [nullrev]
1616 elif base_opt:
1617 base = logcmdutil.revrange(repo, base_opt)
1618 if not base:
1619 # base specified, but nothing was selected
1620 base = [nullrev]
1616 else: 1621 else:
1617 base = logcmdutil.revrange(repo, opts.get('base')) 1622 base = None
1618 if cgversion not in changegroup.supportedoutgoingversions(repo): 1623 if cgversion not in changegroup.supportedoutgoingversions(repo):
1619 raise error.Abort( 1624 raise error.Abort(
1620 _(b"repository does not support bundle version %s") % cgversion 1625 _(b"repository does not support bundle version %s") % cgversion
1621 ) 1626 )
1622 1627
1623 if base: 1628 if base is not None:
1624 if dests: 1629 if dests:
1625 raise error.InputError( 1630 raise error.InputError(
1626 _(b"--base is incompatible with specifying destinations") 1631 _(b"--base is incompatible with specifying destinations")
1627 ) 1632 )
1628 cl = repo.changelog 1633 cl = repo.changelog