7690 ) |
7689 ) |
7691 ], |
7690 ], |
7692 _(b'[-u] FILE...'), |
7691 _(b'[-u] FILE...'), |
7693 helpcategory=command.CATEGORY_IMPORT_EXPORT, |
7692 helpcategory=command.CATEGORY_IMPORT_EXPORT, |
7694 ) |
7693 ) |
7695 def unbundle(ui, repo, fname1, *fnames, _unbundle_source=b'unbundle', **opts): |
7694 def unbundle(ui, repo, fname1, *fnames, **opts): |
7696 """apply one or more bundle files |
7695 """apply one or more bundle files |
7697 |
7696 |
7698 Apply one or more bundle files generated by :hg:`bundle`. |
7697 Apply one or more bundle files generated by :hg:`bundle`. |
7699 |
7698 |
7700 Returns 0 on success, 1 if an update has unresolved files. |
7699 Returns 0 on success, 1 if an update has unresolved files. |
7701 """ |
7700 """ |
7702 fnames = (fname1,) + fnames |
7701 fnames = (fname1,) + fnames |
7703 |
7702 modheads = cmdutil.unbundle_files(ui, repo, fnames) |
7704 with repo.lock(): |
|
7705 for fname in fnames: |
|
7706 f = hg.openpath(ui, fname) |
|
7707 gen = exchange.readbundle(ui, f, fname) |
|
7708 if isinstance(gen, streamclone.streamcloneapplier): |
|
7709 raise error.InputError( |
|
7710 _( |
|
7711 b'packed bundles cannot be applied with ' |
|
7712 b'"hg unbundle"' |
|
7713 ), |
|
7714 hint=_(b'use "hg debugapplystreamclonebundle"'), |
|
7715 ) |
|
7716 url = b'bundle:' + fname |
|
7717 try: |
|
7718 txnname = b'unbundle' |
|
7719 if not isinstance(gen, bundle2.unbundle20): |
|
7720 txnname = b'unbundle\n%s' % urlutil.hidepassword(url) |
|
7721 with repo.transaction(txnname) as tr: |
|
7722 op = bundle2.applybundle( |
|
7723 repo, |
|
7724 gen, |
|
7725 tr, |
|
7726 source=_unbundle_source, # used by debug::unbundle |
|
7727 url=url, |
|
7728 ) |
|
7729 except error.BundleUnknownFeatureError as exc: |
|
7730 raise error.Abort( |
|
7731 _(b'%s: unknown bundle feature, %s') % (fname, exc), |
|
7732 hint=_( |
|
7733 b"see https://mercurial-scm.org/" |
|
7734 b"wiki/BundleFeature for more " |
|
7735 b"information" |
|
7736 ), |
|
7737 ) |
|
7738 modheads = bundle2.combinechangegroupresults(op) |
|
7739 |
7703 |
7740 if cmdutil.postincoming(ui, repo, modheads, opts.get('update'), None, None): |
7704 if cmdutil.postincoming(ui, repo, modheads, opts.get('update'), None, None): |
7741 return 1 |
7705 return 1 |
7742 else: |
7706 else: |
7743 return 0 |
7707 return 0 |