##// END OF EJS Templates
serve: add support for Mercurial subrepositories...
Matt Harbison -
r32005:2406dbba default
parent child Browse files
Show More
@@ -2290,6 +2290,15 b' def add(ui, repo, match, prefix, explici'
2290 bad.extend(f for f in rejected if f in match.files())
2290 bad.extend(f for f in rejected if f in match.files())
2291 return bad
2291 return bad
2292
2292
2293 def addwebdirpath(repo, serverpath, webconf):
2294 webconf[serverpath] = repo.root
2295 repo.ui.debug('adding %s = %s\n' % (serverpath, repo.root))
2296
2297 for r in repo.revs('filelog("path:.hgsub")'):
2298 ctx = repo[r]
2299 for subpath in ctx.substate:
2300 ctx.sub(subpath).addwebdirpath(serverpath, webconf)
2301
2293 def forget(ui, repo, match, prefix, explicitonly):
2302 def forget(ui, repo, match, prefix, explicitonly):
2294 join = lambda f: os.path.join(prefix, f)
2303 join = lambda f: os.path.join(prefix, f)
2295 bad = []
2304 bad = []
@@ -4619,7 +4619,8 b' def root(ui, repo):'
4619 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4619 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
4620 ('', 'style', '', _('template style to use'), _('STYLE')),
4620 ('', 'style', '', _('template style to use'), _('STYLE')),
4621 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4621 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4622 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
4622 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))]
4623 + subrepoopts,
4623 _('[OPTION]...'),
4624 _('[OPTION]...'),
4624 optionalrepo=True)
4625 optionalrepo=True)
4625 def serve(ui, repo, **opts):
4626 def serve(ui, repo, **opts):
@@ -136,6 +136,10 b' Interaction with Mercurial Commands'
136 subrepository changes are available when referenced by top-level
136 subrepository changes are available when referenced by top-level
137 repositories. Push is a no-op for Subversion subrepositories.
137 repositories. Push is a no-op for Subversion subrepositories.
138
138
139 :serve: serve does not recurse into subrepositories unless
140 -S/--subrepos is specified. Git and Subversion subrepositories
141 are currently silently ignored.
142
139 :status: status does not recurse into subrepositories unless
143 :status: status does not recurse into subrepositories unless
140 -S/--subrepos is specified. Subrepository changes are displayed as
144 -S/--subrepos is specified. Subrepository changes are displayed as
141 regular Mercurial changes on the subrepository
145 regular Mercurial changes on the subrepository
@@ -15,6 +15,7 b' from .i18n import _'
15
15
16 from . import (
16 from . import (
17 chgserver,
17 chgserver,
18 cmdutil,
18 commandserver,
19 commandserver,
19 error,
20 error,
20 hgweb,
21 hgweb,
@@ -130,11 +131,22 b' def _createhgwebservice(ui, repo, opts):'
130 baseui = ui
131 baseui = ui
131 webconf = opts.get('web_conf') or opts.get('webdir_conf')
132 webconf = opts.get('web_conf') or opts.get('webdir_conf')
132 if webconf:
133 if webconf:
134 if opts.get('subrepos'):
135 raise error.Abort(_('--web-conf cannot be used with --subrepos'))
136
133 # load server settings (e.g. web.port) to "copied" ui, which allows
137 # load server settings (e.g. web.port) to "copied" ui, which allows
134 # hgwebdir to reload webconf cleanly
138 # hgwebdir to reload webconf cleanly
135 servui = ui.copy()
139 servui = ui.copy()
136 servui.readconfig(webconf, sections=['web'])
140 servui.readconfig(webconf, sections=['web'])
137 alluis.add(servui)
141 alluis.add(servui)
142 elif opts.get('subrepos'):
143 servui = ui
144
145 # If repo is None, hgweb.createapp() already raises a proper abort
146 # message as long as webconf is None.
147 if repo:
148 webconf = dict()
149 cmdutil.addwebdirpath(repo, "", webconf)
138 else:
150 else:
139 servui = ui
151 servui = ui
140
152
@@ -444,6 +444,15 b' class abstractsubrepo(object):'
444 self._ctx = ctx
444 self._ctx = ctx
445 self._path = path
445 self._path = path
446
446
447 def addwebdirpath(self, serverpath, webconf):
448 """Add the hgwebdir entries for this subrepo, and any of its subrepos.
449
450 ``serverpath`` is the path component of the URL for this repo.
451
452 ``webconf`` is the dictionary of hgwebdir entries.
453 """
454 pass
455
447 def storeclean(self, path):
456 def storeclean(self, path):
448 """
457 """
449 returns true if the repository has not changed since it was last
458 returns true if the repository has not changed since it was last
@@ -651,6 +660,10 b' class hgsubrepo(abstractsubrepo):'
651 self.ui.setconfig('ui', '_usedassubrepo', 'True', 'subrepo')
660 self.ui.setconfig('ui', '_usedassubrepo', 'True', 'subrepo')
652 self._initrepo(r, state[0], create)
661 self._initrepo(r, state[0], create)
653
662
663 @annotatesubrepoerror
664 def addwebdirpath(self, serverpath, webconf):
665 cmdutil.addwebdirpath(self._repo, subrelpath(self), webconf)
666
654 def storeclean(self, path):
667 def storeclean(self, path):
655 with self._repo.lock():
668 with self._repo.lock():
656 return self._storeclean(path)
669 return self._storeclean(path)
@@ -184,6 +184,7 b' Show the options for the "serve" command'
184 --repository
184 --repository
185 --stdio
185 --stdio
186 --style
186 --style
187 --subrepos
187 --templates
188 --templates
188 --time
189 --time
189 --traceback
190 --traceback
@@ -194,6 +195,7 b' Show the options for the "serve" command'
194 -A
195 -A
195 -E
196 -E
196 -R
197 -R
198 -S
197 -a
199 -a
198 -d
200 -d
199 -h
201 -h
@@ -225,7 +227,7 b' Show all commands + options'
225 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
227 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
226 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
228 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
227 remove: after, force, subrepos, include, exclude
229 remove: after, force, subrepos, include, exclude
228 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
230 serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos
229 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
231 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
230 summary: remote
232 summary: remote
231 update: clean, check, merge, date, rev, tool
233 update: clean, check, merge, date, rev, tool
@@ -73,6 +73,43 b" Preparing the 'main' repo which depends "
73 adding main/main (glob)
73 adding main/main (glob)
74 $ hg commit -R main -m "main import"
74 $ hg commit -R main -m "main import"
75
75
76 #if serve
77
78 Unfortunately, subrepos not at their nominal location cannot be cloned. But
79 they are still served from their location within the local repository. The only
80 reason why 'main' can be cloned via the filesystem is because 'sub1' and 'sub2'
81 are also available as siblings of 'main'.
82
83 $ hg serve -R main --debug -S -p $HGPORT -d --pid-file=hg1.pid -E error.log -A access.log
84 adding = $TESTTMP/main (glob)
85 adding sub1 = $TESTTMP/main/sub1 (glob)
86 adding sub1/sub2 = $TESTTMP/main/sub1/sub2 (glob)
87 listening at http://*:$HGPORT/ (bound to *:$HGPORT) (glob) (?)
88 adding = $TESTTMP/main (glob) (?)
89 adding sub1 = $TESTTMP/main/sub1 (glob) (?)
90 adding sub1/sub2 = $TESTTMP/main/sub1/sub2 (glob) (?)
91 $ cat hg1.pid >> $DAEMON_PIDS
92
93 $ hg clone http://localhost:$HGPORT httpclone --config progress.disable=True
94 requesting all changes
95 adding changesets
96 adding manifests
97 adding file changes
98 added 1 changesets with 3 changes to 3 files
99 updating to branch default
100 abort: HTTP Error 404: Not Found
101 [255]
102
103 $ cat access.log
104 * "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
105 * "GET /?cmd=batch HTTP/1.1" 200 - * (glob)
106 * "GET /?cmd=getbundle HTTP/1.1" 200 - * (glob)
107 * "GET /../sub1?cmd=capabilities HTTP/1.1" 404 - (glob)
108
109 $ killdaemons.py
110 $ rm hg1.pid error.log access.log
111 #endif
112
76 Cleaning both repositories, just as a clone -U
113 Cleaning both repositories, just as a clone -U
77
114
78 $ hg up -C -R sub2 null
115 $ hg up -C -R sub2 null
@@ -251,6 +251,60 b' Status between revisions:'
251 z1
251 z1
252 +z2
252 +z2
253
253
254 #if serve
255 $ cd ..
256 $ hg serve -R repo --debug -S -p $HGPORT -d --pid-file=hg1.pid -E error.log -A access.log
257 adding = $TESTTMP/repo (glob)
258 adding foo = $TESTTMP/repo/foo (glob)
259 adding foo/bar = $TESTTMP/repo/foo/bar (glob)
260 listening at http://*:$HGPORT/ (bound to *:$HGPORT) (glob) (?)
261 adding = $TESTTMP/repo (glob) (?)
262 adding foo = $TESTTMP/repo/foo (glob) (?)
263 adding foo/bar = $TESTTMP/repo/foo/bar (glob) (?)
264 $ cat hg1.pid >> $DAEMON_PIDS
265
266 $ hg clone http://localhost:$HGPORT clone --config progress.disable=True
267 requesting all changes
268 adding changesets
269 adding manifests
270 adding file changes
271 added 3 changesets with 5 changes to 3 files
272 updating to branch default
273 cloning subrepo foo from http://localhost:$HGPORT/foo
274 requesting all changes
275 adding changesets
276 adding manifests
277 adding file changes
278 added 4 changesets with 7 changes to 3 files
279 cloning subrepo foo/bar from http://localhost:$HGPORT/foo/bar (glob)
280 requesting all changes
281 adding changesets
282 adding manifests
283 adding file changes
284 added 3 changesets with 3 changes to 1 files
285 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
286
287 $ cat clone/foo/bar/z.txt
288 z1
289 z2
290 z3
291
292 $ cat access.log
293 * "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
294 * "GET /?cmd=batch HTTP/1.1" 200 - * (glob)
295 * "GET /?cmd=getbundle HTTP/1.1" 200 - * (glob)
296 * "GET /foo?cmd=capabilities HTTP/1.1" 200 - (glob)
297 * "GET /foo?cmd=batch HTTP/1.1" 200 - * (glob)
298 * "GET /foo?cmd=getbundle HTTP/1.1" 200 - * (glob)
299 * "GET /foo/bar?cmd=capabilities HTTP/1.1" 200 - (glob)
300 * "GET /foo/bar?cmd=batch HTTP/1.1" 200 - * (glob)
301 * "GET /foo/bar?cmd=getbundle HTTP/1.1" 200 - * (glob)
302
303 $ killdaemons.py
304 $ rm hg1.pid error.log access.log
305 $ cd repo
306 #endif
307
254 Enable progress extension for archive tests:
308 Enable progress extension for archive tests:
255
309
256 $ cp $HGRCPATH $HGRCPATH.no-progress
310 $ cp $HGRCPATH $HGRCPATH.no-progress
General Comments 0
You need to be logged in to leave comments. Login now