hgweb.cgi
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
Sat, 19 Jan 2008 18:01:16 -0200
changeset 5909 f45f7390c1c5
parent 5566 d74fc8dec2b4
child 5995 b913d3aacddc
permissions -rw-r--r--
strip: calculate list of extra nodes to save and pass it to changegroupsubset When we remove revision N from the repository, all revisions >= N are affected: either it's a descendant from N and will also be removed, or it's not a descendant of N and will be renumbered. As a consequence, we have to (at least temporarily) remove all filelog and manifest revisions that have a linkrev >= N, readding some of them later. Unfortunately, it's possible to have a revlog with two revisions r1 and r2 such that r1 < r2, but linkrev(r1) > linkrev(r2). If we try to strip revision linkrev(r1) from the repository, we'll also lose revision r2 when we truncate this revlog. We already use changegroupsubset to create a temporary changegroup containing the revisions that have to be restored, but that function is unable to detect that we also wanted to save the r2 in the case above. So we manually calculate these extra nodes and pass it to changegroupsubset. This should fix issue764.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
202
e875a0cf7f3a Call python via env in hgweb.cgi
mpm@selenic.com
parents: 159
diff changeset
     1
#!/usr/bin/env python
159
f9d8620ef469 Add example CGI script
mpm@selenic.com
parents:
diff changeset
     2
#
f9d8620ef469 Add example CGI script
mpm@selenic.com
parents:
diff changeset
     3
# An example CGI script to use hgweb, edit as necessary
f9d8620ef469 Add example CGI script
mpm@selenic.com
parents:
diff changeset
     4
5244
79279b5583c6 cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5197
diff changeset
     5
# adjust python path if not a system-wide install:
79279b5583c6 cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5197
diff changeset
     6
#import sys
79279b5583c6 cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5197
diff changeset
     7
#sys.path.insert(0, "/path/to/python/lib")
79279b5583c6 cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5197
diff changeset
     8
5197
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3868
diff changeset
     9
# enable importing on demand to reduce startup time
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3868
diff changeset
    10
from mercurial import demandimport; demandimport.enable()
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3868
diff changeset
    11
3868
6033d9f28052 hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3781
diff changeset
    12
# send python tracebacks to the browser if an error occurs:
6033d9f28052 hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3781
diff changeset
    13
import cgitb
391
5f65a108a559 hgweb: pull cgitb into CGI script example, where it can easily be disabled
mpm@selenic.com
parents: 202
diff changeset
    14
cgitb.enable()
5f65a108a559 hgweb: pull cgitb into CGI script example, where it can easily be disabled
mpm@selenic.com
parents: 202
diff changeset
    15
3781
713e35dcc321 hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents: 2506
diff changeset
    16
# If you'd like to serve pages with UTF-8 instead of your default
713e35dcc321 hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents: 2506
diff changeset
    17
# locale charset, you can do so by uncommenting the following lines.
713e35dcc321 hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents: 2506
diff changeset
    18
# Note that this will cause your .hgrc files to be interpreted in
713e35dcc321 hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents: 2506
diff changeset
    19
# UTF-8 and all your repo files to be displayed using UTF-8.
713e35dcc321 hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents: 2506
diff changeset
    20
#
3868
6033d9f28052 hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3781
diff changeset
    21
#import os
6033d9f28052 hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3781
diff changeset
    22
#os.environ["HGENCODING"] = "UTF-8"
6033d9f28052 hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3781
diff changeset
    23
6033d9f28052 hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3781
diff changeset
    24
from mercurial.hgweb.hgweb_mod import hgweb
6033d9f28052 hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3781
diff changeset
    25
import mercurial.hgweb.wsgicgi as wsgicgi
3781
713e35dcc321 hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents: 2506
diff changeset
    26
5566
d74fc8dec2b4 Less indirection in the WSGI web interface. This simplifies some code, and makes it more compliant with WSGI.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5244
diff changeset
    27
application = hgweb("/path/to/repo", "repository name")
d74fc8dec2b4 Less indirection in the WSGI web interface. This simplifies some code, and makes it more compliant with WSGI.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5244
diff changeset
    28
wsgicgi.launch(application)