Show More
@@ -35,11 +35,13 b' from .thirdparty import attr' | |||
|
35 | 35 | |
|
36 | 36 | from . import ( |
|
37 | 37 | bookmarks, |
|
38 | bundle2, | |
|
38 | 39 | changelog, |
|
39 | 40 | copies, |
|
40 | 41 | crecord as crecordmod, |
|
41 | 42 | encoding, |
|
42 | 43 | error, |
|
44 | exchange, | |
|
43 | 45 | formatter, |
|
44 | 46 | logcmdutil, |
|
45 | 47 | match as matchmod, |
@@ -56,6 +58,7 b' from . import (' | |||
|
56 | 58 | rewriteutil, |
|
57 | 59 | scmutil, |
|
58 | 60 | state as statemod, |
|
61 | streamclone, | |
|
59 | 62 | subrepoutil, |
|
60 | 63 | templatekw, |
|
61 | 64 | templater, |
@@ -66,6 +69,7 b' from . import (' | |||
|
66 | 69 | from .utils import ( |
|
67 | 70 | dateutil, |
|
68 | 71 | stringutil, |
|
72 | urlutil, | |
|
69 | 73 | ) |
|
70 | 74 | |
|
71 | 75 | from .revlogutils import ( |
@@ -4178,3 +4182,47 b' def postincoming(ui, repo, modheads, opt' | |||
|
4178 | 4182 | elif not ui.configbool(b'commands', b'update.requiredest'): |
|
4179 | 4183 | ui.status(_(b"(run 'hg update' to get a working copy)\n")) |
|
4180 | 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 |
@@ -60,7 +60,6 b' from . import (' | |||
|
60 | 60 | server, |
|
61 | 61 | shelve as shelvemod, |
|
62 | 62 | state as statemod, |
|
63 | streamclone, | |
|
64 | 63 | tags as tagsmod, |
|
65 | 64 | ui as uimod, |
|
66 | 65 | util, |
@@ -7692,7 +7691,7 b' def tip(ui, repo, **opts):' | |||
|
7692 | 7691 | _(b'[-u] FILE...'), |
|
7693 | 7692 | helpcategory=command.CATEGORY_IMPORT_EXPORT, |
|
7694 | 7693 | ) |
|
7695 |
def unbundle(ui, repo, fname1, *fnames, |
|
|
7694 | def unbundle(ui, repo, fname1, *fnames, **opts): | |
|
7696 | 7695 | """apply one or more bundle files |
|
7697 | 7696 | |
|
7698 | 7697 | Apply one or more bundle files generated by :hg:`bundle`. |
@@ -7700,42 +7699,7 b' def unbundle(ui, repo, fname1, *fnames, ' | |||
|
7700 | 7699 | Returns 0 on success, 1 if an update has unresolved files. |
|
7701 | 7700 | """ |
|
7702 | 7701 | fnames = (fname1,) + fnames |
|
7703 | ||
|
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) | |
|
7702 | modheads = cmdutil.unbundle_files(ui, repo, fnames) | |
|
7739 | 7703 | |
|
7740 | 7704 | if cmdutil.postincoming(ui, repo, modheads, opts.get('update'), None, None): |
|
7741 | 7705 | return 1 |
@@ -4078,26 +4078,17 b' def debugupgraderepo(ui, repo, run=False' | |||
|
4078 | 4078 | |
|
4079 | 4079 | @command( |
|
4080 | 4080 | b'debug::unbundle', |
|
4081 | [ | |
|
4082 | ( | |
|
4083 | b'u', | |
|
4084 | b'update', | |
|
4085 | None, | |
|
4086 | _(b'update to new branch head if changesets were unbundled'), | |
|
4087 | ) | |
|
4088 | ], | |
|
4089 | _(b'[-u] FILE...'), | |
|
4081 | [], | |
|
4082 | _(b'FILE...'), | |
|
4090 | 4083 | helpcategory=command.CATEGORY_IMPORT_EXPORT, |
|
4091 | 4084 | ) |
|
4092 |
def debugunbundle(ui, repo, |
|
|
4085 | def debugunbundle(ui, repo, fname1, *fnames): | |
|
4093 | 4086 | """same as `hg unbundle`, but pretent to come from a push |
|
4094 | 4087 | |
|
4095 | 4088 | This is useful to debug behavior and performance change in this case. |
|
4096 | 4089 | """ |
|
4097 | from . import commands # avoid cycle | |
|
4098 | ||
|
4099 | unbundle = cmdutil.findcmd(b'unbundle', commands.table)[1][0] | |
|
4100 | return unbundle(ui, repo, *args, _unbundle_source=b'push', **kwargs) | |
|
4090 | fnames = (fname1,) + fnames | |
|
4091 | cmdutil.unbundle_files(ui, repo, fnames) | |
|
4101 | 4092 | |
|
4102 | 4093 | |
|
4103 | 4094 | @command( |
@@ -284,7 +284,7 b' Show all commands + options' | |||
|
284 | 284 | debug-revlog-stats: changelog, manifest, filelogs, template |
|
285 | 285 | debug::stable-tail-sort: template |
|
286 | 286 | debug::stable-tail-sort-leaps: template, specific |
|
287 |
debug::unbundle: |
|
|
287 | debug::unbundle: | |
|
288 | 288 | debugancestor: |
|
289 | 289 | debugantivirusrunning: |
|
290 | 290 | debugapplystreamclonebundle: |
@@ -663,9 +663,6 b' Test debug::unbundle' | |||
|
663 | 663 | adding manifests |
|
664 | 664 | adding file changes |
|
665 | 665 | added 0 changesets with 0 changes to 1 files (no-pure !) |
|
666 | 9 local changesets published (no-pure !) | |
|
667 | 3 local changesets published (pure !) | |
|
668 | (run 'hg update' to get a working copy) | |
|
669 | 666 | |
|
670 | 667 | Test debugcolor |
|
671 | 668 |
General Comments 0
You need to be logged in to leave comments.
Login now