tests/test-newercgi.t
author Durham Goode <durham@fb.com>
Tue, 11 Feb 2014 21:04:12 -0800
changeset 20519 cda9d2b6beab
parent 15567 8b84d040d9f9
child 22046 7a9cbb315d84
permissions -rw-r--r--
template: add revset() template function Adds a template function that executes a revset and returns the list of revisions as the result. It has the signature 'revset(query [, args...])'. The args are optional and are applied to the query string using the standard python string.format(args) pattern. This allows things like: '{revset("parents({0})", rev)}' to produce the parents of each individual commit in the log output. If no args are specified, the revset result is cached for the duration of the templater; so it's better to not use args if performance is a concern. By itself, revset() can be used to print commit parents, print the common ancestor of a commit with the main branch, etc. It can be used with the ifcontains() function to do things like '{ifcontains(rev, revset('.'), label(...), ...)}' to color the working copy parent, to color certain branches, to color draft commits, etc.

  $ "$TESTDIR/hghave" no-msys || exit 80 # MSYS will translate web paths as if they were file paths

This is a rudimentary test of the CGI files as of d74fc8dec2b4.

  $ hg init test

  $ cat >hgweb.cgi <<HGWEB
  > #!/usr/bin/env python
  > #
  > # An example CGI script to use hgweb, edit as necessary
  > 
  > import cgitb
  > cgitb.enable()
  > 
  > from mercurial import demandimport; demandimport.enable()
  > from mercurial.hgweb import hgweb
  > from mercurial.hgweb import wsgicgi
  > 
  > application = hgweb("test", "Empty test repository")
  > wsgicgi.launch(application)
  > HGWEB

  $ chmod 755 hgweb.cgi

  $ cat >hgweb.config <<HGWEBDIRCONF
  > [paths]
  > test = test
  > HGWEBDIRCONF

  $ cat >hgwebdir.cgi <<HGWEBDIR
  > #!/usr/bin/env python
  > #
  > # An example CGI script to export multiple hgweb repos, edit as necessary
  > 
  > import cgitb
  > cgitb.enable()
  > 
  > from mercurial import demandimport; demandimport.enable()
  > from mercurial.hgweb import hgwebdir
  > from mercurial.hgweb import wsgicgi
  > 
  > application = hgwebdir("hgweb.config")
  > wsgicgi.launch(application)
  > HGWEBDIR

  $ chmod 755 hgwebdir.cgi

  $ . "$TESTDIR/cgienv"
  $ python hgweb.cgi > page1
  $ python hgwebdir.cgi > page2

  $ PATH_INFO="/test/"
  $ PATH_TRANSLATED="/var/something/test.cgi"
  $ REQUEST_URI="/test/test/"
  $ SCRIPT_URI="http://hg.omnifarious.org/test/test/"
  $ SCRIPT_URL="/test/test/"
  $ python hgwebdir.cgi > page3

  $ grep -i error page1 page2 page3
  [1]