Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 32005:2406dbba49bd
serve: add support for Mercurial subrepositories
I've been using `hg serve --web-conf ...` with a simple '/=projects/**' [paths]
configuration for awhile without issue. Let's ditch the need for the manual
configuration in this case, and limit the repos served to the actual subrepos.
This doesn't attempt to handle the case where a new subrepo appears while the
server is running. That could probably be handled with a hook if somebody wants
it. But it's such a rare case, it probably doesn't matter for the temporary
serves.
The main repo is served at '/', just like a repository without subrepos. I'm
not sure why the duplicate 'adding ...' lines appear on Linux. They don't
appear on Windows (see 594dd384803c), so they are optional.
Subrepositories that are configured with '../path' or absolute paths are not
cloneable from the server. (They aren't cloneable locally either, unless they
also exist at their configured source, perhaps via the share extension.) They
are still served, so that they can be browsed, or cloned individually. If we
care about that cloning someday, we can probably just add the extra entries to
the webconf dictionary. Even if the entries use '../' to escape the root, only
the related subrepositories would end up in the dictionary.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 15 Apr 2017 18:05:40 -0400 |
parents | f97e90fa5ad7 |
children | a77e61b45384 173ecccb9ee7 |
comparison
equal
deleted
inserted
replaced
32004:bd3cb917761a | 32005:2406dbba49bd |
---|---|
442 """ | 442 """ |
443 self.ui = ctx.repo().ui | 443 self.ui = ctx.repo().ui |
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 |
450 cloned from or pushed to a given repository. | 459 cloned from or pushed to a given repository. |
451 """ | 460 """ |
648 if v: | 657 if v: |
649 self.ui.setconfig(s, k, v, 'subrepo') | 658 self.ui.setconfig(s, k, v, 'subrepo') |
650 # internal config: ui._usedassubrepo | 659 # internal config: ui._usedassubrepo |
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) |
662 | |
663 @annotatesubrepoerror | |
664 def addwebdirpath(self, serverpath, webconf): | |
665 cmdutil.addwebdirpath(self._repo, subrelpath(self), webconf) | |
653 | 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) |
657 | 670 |