1. TortoiseHg
  2. TortoiseHg
  3. thg


Yuya Nishihara  committed f2e11b3

serve: have hgweb search subrepos recursively

It may include non-subrepo under the tree, but it won't hurt anyway.

  • Participants
  • Parent commits 2ad167f
  • Branches default

Comments (0)

Files changed (1)

File tortoisehg/hgqt/serve.py

View file
  • Ignore whitespace
 import sys, os, httplib, socket, tempfile
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
-from mercurial import extensions, hgweb, util, error, subrepo
+from mercurial import extensions, hgweb, util, error
 from mercurial.hgweb import server  # workaround for demandimport
 from tortoisehg.util import paths, wconfig, hglib
 from tortoisehg.hgqt import cmdui, qtlib, thgrepo
     return dlg
-def recursiveRepoSearch(repo):
-    yield repo.root
-    try:
-        wctx = repo[None]
-        for s in wctx.substate:
-            sub = wctx.sub(s)
-            if isinstance(sub, subrepo.hgsubrepo):
-                for root in recursiveRepoSearch(sub._repo):
-                    yield root
-    except (EnvironmentError, error.Abort, error.RepoError):
-        pass
 def _asconfigliststr(value):
     >>> _asconfigliststr('foo')
     elif repopath:  # imitate webconf for single repo
         c = wconfig.config()
+            # TODO: not nice to instantiate repo just for repo.shortname
             repo = thgrepo.repository(None, repopath)
-            roots = [root for root in recursiveRepoSearch(repo)]
-            if len(roots) == 1:
+            if not os.path.exists(os.path.join(repopath, '.hgsub')):
                 # no _asconfigliststr(repopath) for now, because ServeDialog
                 # cannot parse it as a list in single-repo mode.
                 c.set('paths', '/', repopath)
                 # since hg 8cbb59124e67, path entry is parsed as a list
                 base = hglib.fromunicode(repo.shortname)
-                c.set('paths', base, _asconfigliststr(repopath))
-                for root in roots[1:]:
-                    c.set('paths', base + root[len(repopath):],
-                          _asconfigliststr(root))
+                c.set('paths', base,
+                      _asconfigliststr(os.path.join(repopath, '**')))
         except (EnvironmentError, error.Abort, error.RepoError):
             c.set('paths', '/', repopath)
         return c