Submitter | via Mercurial-devel |
---|---|
Date | June 24, 2017, 3:38 p.m. |
Message ID | <a5adc63a7b001cc4c489.1498318717@martinvonz.svl.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/21673/ |
State | Accepted |
Headers | show |
Comments
On Sat, 24 Jun 2017 08:38:37 -0700, Martin von Zweigbergk via Mercurial-devel wrote: > # HG changeset patch > # User Martin von Zweigbergk <martinvonz@google.com> > # Date 1498168819 25200 > # Thu Jun 22 15:00:19 2017 -0700 > # Node ID a5adc63a7b001cc4c489e7ea4d574e71adccafe7 > # Parent 15326b3ffdaf861d6c7dd9dad850f8790a869427 > bundle: make applybundle() delegate v1 bundles to applybundle1() > diff --git a/hgext/shelve.py b/hgext/shelve.py > --- a/hgext/shelve.py > +++ b/hgext/shelve.py > @@ -126,17 +126,9 @@ > fp = self.opener() > try: > gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs) > - if not isinstance(gen, bundle2.unbundle20): > - bundle2.applybundle1(self.repo, gen, > - self.repo.currenttransaction(), > - source='unshelve', > - url='bundle:' + self.vfs.join(self.fname), > - targetphase=phases.secret) > - else: > - bundle2.applybundle(self.repo, gen, > - self.repo.currenttransaction(), > - source='unshelve', > - url='bundle:' + self.vfs.join(self.fname)) > + bundle2.applybundle(self.repo, gen, self.repo.currenttransaction(), > + source='unshelve', > + url='bundle:' + self.vfs.join(self.fname)) targetphase appears lost. Can you send a follow up? FWIW, this is why unshelving revision can be seen if bundle2 is used. https://bz.mercurial-scm.org/show_bug.cgi?id=5267
On Sun, Jun 25, 2017 at 5:56 AM, Yuya Nishihara <yuya@tcha.org> wrote: > On Sat, 24 Jun 2017 08:38:37 -0700, Martin von Zweigbergk via Mercurial-devel wrote: >> # HG changeset patch >> # User Martin von Zweigbergk <martinvonz@google.com> >> # Date 1498168819 25200 >> # Thu Jun 22 15:00:19 2017 -0700 >> # Node ID a5adc63a7b001cc4c489e7ea4d574e71adccafe7 >> # Parent 15326b3ffdaf861d6c7dd9dad850f8790a869427 >> bundle: make applybundle() delegate v1 bundles to applybundle1() > >> diff --git a/hgext/shelve.py b/hgext/shelve.py >> --- a/hgext/shelve.py >> +++ b/hgext/shelve.py >> @@ -126,17 +126,9 @@ >> fp = self.opener() >> try: >> gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs) >> - if not isinstance(gen, bundle2.unbundle20): >> - bundle2.applybundle1(self.repo, gen, >> - self.repo.currenttransaction(), >> - source='unshelve', >> - url='bundle:' + self.vfs.join(self.fname), >> - targetphase=phases.secret) >> - else: >> - bundle2.applybundle(self.repo, gen, >> - self.repo.currenttransaction(), >> - source='unshelve', >> - url='bundle:' + self.vfs.join(self.fname)) >> + bundle2.applybundle(self.repo, gen, self.repo.currenttransaction(), >> + source='unshelve', >> + url='bundle:' + self.vfs.join(self.fname)) > > targetphase appears lost. Can you send a follow up? If the commit is not yet public, feel free to just amend that in (or maybe I'll find a few minutes to do it myself in a while). The applybundle() method will delegate **kwargs, so we just need to add ", targetphase=phases.secret" to the call. > > FWIW, this is why unshelving revision can be seen if bundle2 is used. > > https://bz.mercurial-scm.org/show_bug.cgi?id=5267 Oh, good point! I'll look into that bug later. Seems like my recent work on adding phases to bundles can be useful (just need to make sure that the temporary commit is in secret phase perhaps).
On Sun, Jun 25, 2017 at 8:11 AM, Martin von Zweigbergk <martinvonz@google.com> wrote: > On Sun, Jun 25, 2017 at 5:56 AM, Yuya Nishihara <yuya@tcha.org> wrote: >> On Sat, 24 Jun 2017 08:38:37 -0700, Martin von Zweigbergk via Mercurial-devel wrote: >>> # HG changeset patch >>> # User Martin von Zweigbergk <martinvonz@google.com> >>> # Date 1498168819 25200 >>> # Thu Jun 22 15:00:19 2017 -0700 >>> # Node ID a5adc63a7b001cc4c489e7ea4d574e71adccafe7 >>> # Parent 15326b3ffdaf861d6c7dd9dad850f8790a869427 >>> bundle: make applybundle() delegate v1 bundles to applybundle1() >> >>> diff --git a/hgext/shelve.py b/hgext/shelve.py >>> --- a/hgext/shelve.py >>> +++ b/hgext/shelve.py >>> @@ -126,17 +126,9 @@ >>> fp = self.opener() >>> try: >>> gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs) >>> - if not isinstance(gen, bundle2.unbundle20): >>> - bundle2.applybundle1(self.repo, gen, >>> - self.repo.currenttransaction(), >>> - source='unshelve', >>> - url='bundle:' + self.vfs.join(self.fname), >>> - targetphase=phases.secret) >>> - else: >>> - bundle2.applybundle(self.repo, gen, >>> - self.repo.currenttransaction(), >>> - source='unshelve', >>> - url='bundle:' + self.vfs.join(self.fname)) >>> + bundle2.applybundle(self.repo, gen, self.repo.currenttransaction(), >>> + source='unshelve', >>> + url='bundle:' + self.vfs.join(self.fname)) >> >> targetphase appears lost. Can you send a follow up? > > If the commit is not yet public, feel free to just amend that in (or > maybe I'll find a few minutes to do it myself in a while). The > applybundle() method will delegate **kwargs, so we just need to add ", > targetphase=phases.secret" to the call. Done.
Patch
diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -1198,14 +1198,8 @@ f = hg.openpath(ui, backupfile) gen = exchange.readbundle(ui, f, backupfile) with repo.transaction('histedit.abort') as tr: - if not isinstance(gen, bundle2.unbundle20): - bundle2.applybundle1(repo, gen, tr, - source='histedit', - url='bundle:' + backupfile) - else: - bundle2.applybundle(repo, gen, tr, - source='histedit', - url='bundle:' + backupfile) + bundle2.applybundle(repo, gen, tr, source='histedit', + url='bundle:' + backupfile) os.remove(backupfile) diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -126,17 +126,9 @@ fp = self.opener() try: gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs) - if not isinstance(gen, bundle2.unbundle20): - bundle2.applybundle1(self.repo, gen, - self.repo.currenttransaction(), - source='unshelve', - url='bundle:' + self.vfs.join(self.fname), - targetphase=phases.secret) - else: - bundle2.applybundle(self.repo, gen, - self.repo.currenttransaction(), - source='unshelve', - url='bundle:' + self.vfs.join(self.fname)) + bundle2.applybundle(self.repo, gen, self.repo.currenttransaction(), + source='unshelve', + url='bundle:' + self.vfs.join(self.fname)) finally: fp.close() diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -316,14 +316,17 @@ _processchangegroup(op, cg, tr, source, url, **kwargs) return op -def applybundle(repo, unbundler, tr, source=None, url=None): +def applybundle(repo, unbundler, tr, source=None, url=None, **kwargs): # transform me into unbundler.apply() as soon as the freeze is lifted - tr.hookargs['bundle2'] = '1' - if source is not None and 'source' not in tr.hookargs: - tr.hookargs['source'] = source - if url is not None and 'url' not in tr.hookargs: - tr.hookargs['url'] = url - return processbundle(repo, unbundler, lambda: tr) + if isinstance(unbundler, unbundle20): + tr.hookargs['bundle2'] = '1' + if source is not None and 'source' not in tr.hookargs: + tr.hookargs['source'] = source + if url is not None and 'url' not in tr.hookargs: + tr.hookargs['url'] = url + return processbundle(repo, unbundler, lambda: tr) + else: + return applybundle1(repo, unbundler, tr, source, url, **kwargs) def processbundle(repo, unbundler, transactiongetter=None, op=None): """This function process a bundle, apply effect to/from a repo diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5207,13 +5207,8 @@ if not isinstance(gen, bundle2.unbundle20): txnname = 'unbundle\n%s' % util.hidepassword(url) with repo.transaction(txnname) as tr: - if isinstance(gen, bundle2.unbundle20): - op = bundle2.applybundle(repo, gen, tr, - source='unbundle', - url=url) - else: - op = bundle2.applybundle1(repo, gen, tr, - source='unbundle', url=url) + op = bundle2.applybundle(repo, gen, tr, source='unbundle', + url=url) except error.BundleUnknownFeatureError as exc: raise error.Abort( _('%s: unknown bundle feature, %s') % (fname, exc), diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -1448,8 +1448,8 @@ "changegroupsubset.")) else: cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull') - bundleop = bundle2.applybundle1(pullop.repo, cg, tr, 'pull', - pullop.remote.url()) + bundleop = bundle2.applybundle(pullop.repo, cg, tr, 'pull', + pullop.remote.url()) pullop.cgresult = bundle2.combinechangegroupresults(bundleop) def _pullphase(pullop): @@ -1738,7 +1738,7 @@ # legacy case: bundle1 (changegroup 01) txnname = "\n".join([source, util.hidepassword(url)]) with repo.lock(), repo.transaction(txnname) as tr: - op = bundle2.applybundle1(repo, cg, tr, source, url) + op = bundle2.applybundle(repo, cg, tr, source, url) r = bundle2.combinechangegroupresults(op) else: r = None @@ -1999,12 +1999,10 @@ fh = urlmod.open(ui, url) cg = readbundle(ui, fh, 'stream') - if isinstance(cg, bundle2.unbundle20): - bundle2.applybundle(repo, cg, tr, 'clonebundles', url) - elif isinstance(cg, streamclone.streamcloneapplier): + if isinstance(cg, streamclone.streamcloneapplier): cg.apply(repo) else: - bundle2.applybundle1(repo, cg, tr, 'clonebundles', url) + bundle2.applybundle(repo, cg, tr, 'clonebundles', url) return True except urlerr.httperror as e: ui.warn(_('HTTP error fetching bundle: %s\n') % str(e)) diff --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -211,12 +211,8 @@ if not isinstance(gen, bundle2.unbundle20): txnname = "strip\n%s" % util.hidepassword(tmpbundleurl) with repo.transaction(txnname) as tr: - if isinstance(gen, bundle2.unbundle20): - bundle2.applybundle(repo, gen, tr, source='strip', - url=tmpbundleurl) - else: - bundle2.applybundle1(repo, gen, tr, 'strip', tmpbundleurl, - emptyok=True) + bundle2.applybundle(repo, gen, tr, source='strip', + url=tmpbundleurl, emptyok=True) if not repo.ui.verbose: repo.ui.popbuffer() f.close()