mercurial/commands.py
changeset 51555 15e680a44502
parent 51554 a151fd01e98c
child 51557 cc44b3df9bb4
--- 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