##// END OF EJS Templates
debug: add a 'debugdownload' command...
Boris Feld -
r35578:6580cf75 default
parent child Browse files
Show More
@@ -0,0 +1,36 b''
1 #require serve
2
3 $ hg init server
4 $ hg serve -R server -p $HGPORT -d --pid-file=hg1.pid -E ../error.log
5 $ cat hg1.pid >> $DAEMON_PIDS
6
7 Check basic fetching
8
9 $ hg debugdownload "http://localhost:$HGPORT/?cmd=lookup&key=tip"
10 1 0000000000000000000000000000000000000000
11 $ hg debugdownload -o null.txt "http://localhost:$HGPORT/?cmd=lookup&key=null"
12 $ cat null.txt
13 1 0000000000000000000000000000000000000000
14
15 Check the request is made from the usual Mercurial logic
16 (rev details, give different content if the request has a Mercurial user agent)
17
18 $ get-with-headers.py --headeronly "localhost:$HGPORT" "rev/tip" content-type
19 200 Script output follows
20 content-type: text/html; charset=ascii
21 $ hg debugdownload "http://localhost:$HGPORT/rev/tip"
22
23 # HG changeset patch
24 # User
25 # Date 0 0
26 # Node ID 0000000000000000000000000000000000000000
27
28
29
30
31
32 Check other kind of compatible url
33
34 $ hg debugdownload ./null.txt
35 1 0000000000000000000000000000000000000000
36
@@ -69,6 +69,7 b' from . import ('
69 templater,
69 templater,
70 treediscovery,
70 treediscovery,
71 upgrade,
71 upgrade,
72 url as urlmod,
72 util,
73 util,
73 vfs as vfsmod,
74 vfs as vfsmod,
74 )
75 )
@@ -786,6 +787,30 b' def debugdiscovery(ui, repo, remoteurl="'
786 localrevs = opts['rev']
787 localrevs = opts['rev']
787 doit(localrevs, remoterevs)
788 doit(localrevs, remoterevs)
788
789
790 _chunksize = 4 << 10
791
792 @command('debugdownload',
793 [
794 ('o', 'output', '', _('path')),
795 ],
796 norepo=True)
797 def debugdownload(ui, url, output=None, **opts):
798 """download a resource using Mercurial logic and config
799 """
800 fh = urlmod.open(ui, url, output)
801
802 dest = ui
803 if output:
804 dest = open(output, "wb", _chunksize)
805 try:
806 data = fh.read(_chunksize)
807 while data:
808 dest.write(data)
809 data = fh.read(_chunksize)
810 finally:
811 if output:
812 dest.close()
813
789 @command('debugextensions', cmdutil.formatteropts, [], norepo=True)
814 @command('debugextensions', cmdutil.formatteropts, [], norepo=True)
790 def debugextensions(ui, **opts):
815 def debugextensions(ui, **opts):
791 '''show information about active extensions'''
816 '''show information about active extensions'''
@@ -85,6 +85,7 b' Show debug commands if there are no othe'
85 debugdeltachain
85 debugdeltachain
86 debugdirstate
86 debugdirstate
87 debugdiscovery
87 debugdiscovery
88 debugdownload
88 debugextensions
89 debugextensions
89 debugfileset
90 debugfileset
90 debugformat
91 debugformat
@@ -263,6 +264,7 b' Show all commands + options'
263 debugdeltachain: changelog, manifest, dir, template
264 debugdeltachain: changelog, manifest, dir, template
264 debugdirstate: nodates, datesort
265 debugdirstate: nodates, datesort
265 debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure
266 debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure
267 debugdownload: output
266 debugextensions: template
268 debugextensions: template
267 debugfileset: rev
269 debugfileset: rev
268 debugformat: template
270 debugformat: template
@@ -919,6 +919,8 b' Test list of internal help commands'
919 show the contents of the current dirstate
919 show the contents of the current dirstate
920 debugdiscovery
920 debugdiscovery
921 runs the changeset discovery protocol in isolation
921 runs the changeset discovery protocol in isolation
922 debugdownload
923 download a resource using Mercurial logic and config
922 debugextensions
924 debugextensions
923 show information about active extensions
925 show information about active extensions
924 debugfileset parse and apply a fileset specification
926 debugfileset parse and apply a fileset specification
General Comments 0
You need to be logged in to leave comments. Login now