hgweb.cgi
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
Fri, 14 Mar 2008 09:56:58 -0300
changeset 6254 3667b6e4bbd0
parent 6142 50a277e6ceae
child 11000 338167735124
permissions -rw-r--r--
localrepo.commit: normalize commit message even for rawcommit. This normalization consists of: - stripping trailing whitespace - always using "\n" as the line separator I think the main reason rawcommit was skipping this normalization was an attempt to preserve hashes during an hg->hg conversion. While this is a nice goal, it's not particularly interesting in practice. Since SHA-1 is so strong, the only safe way to do it is to have absolutely identical revisions. But: - if the original revision was created with a recent version of hg, the commit message will be the same, with or without that normalization - if it was created with an ancient version of hg that didn't do any normalization, even if the commit message is identical, the file list in the changelog is likely to be different (e.g. no removed files), and there were some old issues with e.g. extra file merging, which will end up changing the hash anyway - in any case, if one *really* has to preserve hashes, it's easier (and faster) to fake a partial conversion using something like: hg clone -U -r rev orig-repo new-repo hg -R new-repo log --template '#node# #node#\n' > new-repo/.hg/shamap Additionally, we've had some reports of problems arising from this lack of normalization - e.g. issue871, and a user that was wondering why hg export/hg import was not preserving hashes when there was nothing unusual going on (it was just import doing the normalization that had been skipped). This also means that it's even more unlikely to get identical revisions when going $VCS->hg->$VCS.
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
6080
4baad19c4801 hgweb: disable cgitb by default
Maxim Dounin <mdounin@mdounin.ru>
parents: 5995
diff changeset
    12
# Uncomment to send python tracebacks to the browser if an error occurs:
4baad19c4801 hgweb: disable cgitb by default
Maxim Dounin <mdounin@mdounin.ru>
parents: 5995
diff changeset
    13
#import cgitb
4baad19c4801 hgweb: disable cgitb by default
Maxim Dounin <mdounin@mdounin.ru>
parents: 5995
diff changeset
    14
#cgitb.enable()
391
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
6141
90e5c82a3859 Backed out changeset b913d3aacddc (see issue971/msg5317)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5995
diff changeset
    27
application = hgweb("/path/to/repo", "repository name")
90e5c82a3859 Backed out changeset b913d3aacddc (see issue971/msg5317)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5995
diff changeset
    28
wsgicgi.launch(application)