D2819: hgweb: refactor repository name URL parsing

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Thu Apr 5 14:59:41 EDT 2018


mharbison72 added a comment.


  In https://phab.mercurial-scm.org/D2819#49519, @mharbison72 wrote:
  
  > I installed the latest default branch with SCM Manager, and it 404s even simple things like `hg id https://...`.  I bisected back to this.  The paths in the access log looks unchanged:
  >
  > With this commit:
  >
  > 127.0.0.1 - - [04/Apr/2018:12:44:12 -0400] "GET /hook/hg/?ping=true HTTP/1.1" 204 -
  >  10.10.1.36 - - [04/Apr/2018:12:44:12 -0400] "GET /hg/eng/devsetup?cmd=capabilities HTTP/1.1" 404 949
  >
  > Parent of this commit:
  >
  > 127.0.0.1 - - [04/Apr/2018:12:47:18 -0400] "GET /hook/hg/?ping=true HTTP/1.1" 204 -
  >  10.10.1.36 - - [04/Apr/2018:12:47:19 -0400] "GET /hg/eng/devsetup?cmd=capabilities HTTP/1.1" 200 422
  >  10.10.1.36 - - [04/Apr/2018:12:47:19 -0400] "GET /hg/eng/devsetup?cmd=lookup HTTP/1.1" 200 43
  >  10.10.1.36 - - [04/Apr/2018:12:47:20 -0400] "GET /hg/eng/devsetup?cmd=listkeys HTTP/1.1" 200 30
  >  10.10.1.36 - - [04/Apr/2018:12:47:20 -0400] "GET /hg/eng/devsetup?cmd=listkeys HTTP/1.1" 200 -
  >
  > I'm going to try to add print statements, but if you have any darts you'd like to throw, I'd be happy to try it.
  
  
  Finally figured this out.  SCM Manager must be generating this stub hgweb.py (it gets rewritten every time tomcat is restarted):
  
    import os
    from mercurial import demandimport
    from mercurial.hgweb import hgweb, wsgicgi
    
    repositoryPath = os.environ['SCM_REPOSITORY_PATH']
    
    demandimport.enable()
    
    application = hgweb(repositoryPath)
    wsgicgi.launch(application)
  
  Note that it's not using hgweb**dir**.  (I have no idea why not, but it does let you organize repos into virtual directories under '/hg', and git repos under '/git'.)  If we simply set the reponame value in request.parserequestfromenv() from env if it wasn't passed in, then everything works.  Not real nice, but I assume that we don't want to break existing hosting packages when upgrading just Mercurial?  I'll send a patch if this is acceptable.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2819

To: indygreg, #hg-reviewers, durin42
Cc: mharbison72, mercurial-devel


More information about the Mercurial-devel mailing list