mercurial/cmdutil.py
changeset 51552 15e680a44502
parent 51551 a151fd01e98c
child 51686 493034cc3265
equal deleted inserted replaced
51551:a151fd01e98c 51552:15e680a44502
    33 )
    33 )
    34 from .thirdparty import attr
    34 from .thirdparty import attr
    35 
    35 
    36 from . import (
    36 from . import (
    37     bookmarks,
    37     bookmarks,
       
    38     bundle2,
    38     changelog,
    39     changelog,
    39     copies,
    40     copies,
    40     crecord as crecordmod,
    41     crecord as crecordmod,
    41     encoding,
    42     encoding,
    42     error,
    43     error,
       
    44     exchange,
    43     formatter,
    45     formatter,
    44     logcmdutil,
    46     logcmdutil,
    45     match as matchmod,
    47     match as matchmod,
    46     merge as mergemod,
    48     merge as mergemod,
    47     mergestate as mergestatemod,
    49     mergestate as mergestatemod,
    54     repair,
    56     repair,
    55     revlog,
    57     revlog,
    56     rewriteutil,
    58     rewriteutil,
    57     scmutil,
    59     scmutil,
    58     state as statemod,
    60     state as statemod,
       
    61     streamclone,
    59     subrepoutil,
    62     subrepoutil,
    60     templatekw,
    63     templatekw,
    61     templater,
    64     templater,
    62     util,
    65     util,
    63     vfs as vfsmod,
    66     vfs as vfsmod,
    64 )
    67 )
    65 
    68 
    66 from .utils import (
    69 from .utils import (
    67     dateutil,
    70     dateutil,
    68     stringutil,
    71     stringutil,
       
    72     urlutil,
    69 )
    73 )
    70 
    74 
    71 from .revlogutils import (
    75 from .revlogutils import (
    72     constants as revlog_constants,
    76     constants as revlog_constants,
    73 )
    77 )
  4176         else:
  4180         else:
  4177             ui.status(_(b"(run 'hg heads' to see heads)\n"))
  4181             ui.status(_(b"(run 'hg heads' to see heads)\n"))
  4178     elif not ui.configbool(b'commands', b'update.requiredest'):
  4182     elif not ui.configbool(b'commands', b'update.requiredest'):
  4179         ui.status(_(b"(run 'hg update' to get a working copy)\n"))
  4183         ui.status(_(b"(run 'hg update' to get a working copy)\n"))
  4180     return False
  4184     return False
       
  4185 
       
  4186 
       
  4187 def unbundle_files(ui, repo, fnames, unbundle_source=b'unbundle'):
       
  4188     """utility for `hg unbundle` and `hg debug::unbundle`"""
       
  4189     assert fnames
       
  4190     # avoid circular import
       
  4191     from . import hg
       
  4192 
       
  4193     with repo.lock():
       
  4194         for fname in fnames:
       
  4195             f = hg.openpath(ui, fname)
       
  4196             gen = exchange.readbundle(ui, f, fname)
       
  4197             if isinstance(gen, streamclone.streamcloneapplier):
       
  4198                 raise error.InputError(
       
  4199                     _(
       
  4200                         b'packed bundles cannot be applied with '
       
  4201                         b'"hg unbundle"'
       
  4202                     ),
       
  4203                     hint=_(b'use "hg debugapplystreamclonebundle"'),
       
  4204                 )
       
  4205             url = b'bundle:' + fname
       
  4206             try:
       
  4207                 txnname = b'unbundle'
       
  4208                 if not isinstance(gen, bundle2.unbundle20):
       
  4209                     txnname = b'unbundle\n%s' % urlutil.hidepassword(url)
       
  4210                 with repo.transaction(txnname) as tr:
       
  4211                     op = bundle2.applybundle(
       
  4212                         repo,
       
  4213                         gen,
       
  4214                         tr,
       
  4215                         source=unbundle_source,  # used by debug::unbundle
       
  4216                         url=url,
       
  4217                     )
       
  4218             except error.BundleUnknownFeatureError as exc:
       
  4219                 raise error.Abort(
       
  4220                     _(b'%s: unknown bundle feature, %s') % (fname, exc),
       
  4221                     hint=_(
       
  4222                         b"see https://mercurial-scm.org/"
       
  4223                         b"wiki/BundleFeature for more "
       
  4224                         b"information"
       
  4225                     ),
       
  4226                 )
       
  4227             modheads = bundle2.combinechangegroupresults(op)
       
  4228     return modheads