Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 51552:15e680a44502
unbundle: move most of the logic on cmdutil to help debug::unbundle reuse
This make sure `hg debug::unbundle` focus on the core logic.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 27 Mar 2024 17:46:23 +0000 |
parents | a151fd01e98c |
children | cc44b3df9bb4 |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Mar 27 17:29:48 2024 +0000 +++ b/mercurial/commands.py Wed Mar 27 17:46:23 2024 +0000 @@ -60,7 +60,6 @@ server, shelve as shelvemod, state as statemod, - streamclone, tags as tagsmod, ui as uimod, util, @@ -7692,7 +7691,7 @@ _(b'[-u] FILE...'), helpcategory=command.CATEGORY_IMPORT_EXPORT, ) -def unbundle(ui, repo, fname1, *fnames, _unbundle_source=b'unbundle', **opts): +def unbundle(ui, repo, fname1, *fnames, **opts): """apply one or more bundle files Apply one or more bundle files generated by :hg:`bundle`. @@ -7700,42 +7699,7 @@ Returns 0 on success, 1 if an update has unresolved files. """ fnames = (fname1,) + fnames - - with repo.lock(): - for fname in fnames: - f = hg.openpath(ui, fname) - gen = exchange.readbundle(ui, f, fname) - if isinstance(gen, streamclone.streamcloneapplier): - raise error.InputError( - _( - b'packed bundles cannot be applied with ' - b'"hg unbundle"' - ), - hint=_(b'use "hg debugapplystreamclonebundle"'), - ) - url = b'bundle:' + fname - try: - txnname = b'unbundle' - if not isinstance(gen, bundle2.unbundle20): - txnname = b'unbundle\n%s' % urlutil.hidepassword(url) - with repo.transaction(txnname) as tr: - op = bundle2.applybundle( - repo, - gen, - tr, - source=_unbundle_source, # used by debug::unbundle - url=url, - ) - except error.BundleUnknownFeatureError as exc: - raise error.Abort( - _(b'%s: unknown bundle feature, %s') % (fname, exc), - hint=_( - b"see https://mercurial-scm.org/" - b"wiki/BundleFeature for more " - b"information" - ), - ) - modheads = bundle2.combinechangegroupresults(op) + modheads = cmdutil.unbundle_files(ui, repo, fnames) if cmdutil.postincoming(ui, repo, modheads, opts.get('update'), None, None): return 1