On Mon, 08 Jan 2018 12:00:18 +0100, Boris Feld wrote: > # HG changeset patch > # User Boris Feld <boris.f...@octobus.net> > # Date 1513326616 -3600 > # Fri Dec 15 09:30:16 2017 +0100 > # Node ID cfcfc7938b0411f91f8626500cafaad0d522e1ee > # Parent f04d16bef2c71986f256a7bf2c97163d726d4909 > # EXP-Topic largefile-url > # Available At https://bitbucket.org/octobus/mercurial-devel/ > # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r > cfcfc7938b04 > debug: add a 'debugdownload' command > > This command resolve and fetch and URL through the Mercurial logic. Mercurial > logic add various headers (including authentication) while resolving an URL so > the commands helps with building the same request Mercurial would be doing. > > A new test file is created because we'll add more logic regarding Mercurial > download logic and it will grow to a reasonable size. > > diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py > --- a/mercurial/debugcommands.py > +++ b/mercurial/debugcommands.py > @@ -69,6 +69,7 @@ from . import ( > templater, > treediscovery, > upgrade, > + url as urlmod, > util, > vfs as vfsmod, > ) > @@ -786,6 +787,28 @@ def debugdiscovery(ui, repo, remoteurl=" > localrevs = opts['rev'] > doit(localrevs, remoterevs) > > +
Please run test-check-commit.t. > +_chunksize = 4 << 10 > + > +@command('debugdownload', > + [ > + ('o', 'output', '', _('URL')), Nit: s/URL/output file/ ? > +def debugdownload(ui, url, output=None, **opts): > + """Download a resource using Mercurial logic and config > + """ > + fh = urlmod.open(ui, url, output) > + > + dest = ui > + if output: > + dest = open(output, "wb", _chunksize) > + > + data = fh.read(_chunksize) > + while data: > + dest.write(data) > + data = fh.read(_chunksize) Need to close dest if it isn't ui. Perhaps we can extract a subset of cmdutil.makefileobj() which requires a repo object. (We could make a repo argument optional, but that would conflict with my patches to port it to templater. :) _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel