--- a/hgmerge
+++ b/hgmerge
@@ -17,31 +17,35 @@ fi
# find decent versions of our utilities, insisting on the GNU versions where we
# need to
-MERGE=merge
-DIFF3=gdiff3
-DIFF=gdiff
-PATCH=gpatch
+MERGE="merge"
+DIFF3="gdiff3"
+DIFF="gdiff"
+PATCH="gpatch"
-type $MERGE >/dev/null 2>&1 || MERGE=
-type $DIFF3 >/dev/null 2>&1 || DIFF3=diff3
-type $DIFF >/dev/null 2>&1 || DIFF=diff
-type $PATCH >/dev/null 2>&1 || PATCH=patch
+type "$MERGE" >/dev/null 2>&1 || MERGE=
+type "$DIFF3" >/dev/null 2>&1 || DIFF3="diff3"
$DIFF3 --version >/dev/null 2>&1 || DIFF3=
+type "$DIFF" >/dev/null 2>&1 || DIFF="diff"
+type "$DIFF" >/dev/null 2>&1 || DIFF=
+type "$PATCH" >/dev/null 2>&1 || PATCH="patch"
+type "$PATCH" >/dev/null 2>&1 || PATCH=
# find optional visual utilities
-FILEMERGE='/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge'
-KDIFF3=kdiff3
-TKDIFF=tkdiff
+FILEMERGE="/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge"
+KDIFF3="kdiff3"
+TKDIFF="tkdiff"
+MELD="meld"
-type $FILEMERGE >/dev/null 2>&1 || FILEMERGE=
-type $KDIFF3 >/dev/null 2>&1 || KDIFF3=
-type $TKDIFF >/dev/null 2>&1 || TKDIFF=
+type "$FILEMERGE" >/dev/null 2>&1 || FILEMERGE=
+type "$KDIFF3" >/dev/null 2>&1 || KDIFF3=
+type "$TKDIFF" >/dev/null 2>&1 || TKDIFF=
+type "$MELD" >/dev/null 2>&1 || MELD=
# random part of names
-RAND="$RANDOM.$RANDOM.$RANDOM.$$"
+RAND="$RANDOM$RANDOM"
# temporary directory for diff+patch merge
-HGTMP="${TMPDIR-/tmp}/hgmerge.$RAND"
+HGTMP="${TMPDIR-'/tmp'}/hgmerge.$RAND"
# backup file
BACKUP="$LOCAL.orig.$RAND"
@@ -68,6 +72,18 @@ failure() {
exit 1
}
+# Ask if the merge was successful
+ask_if_merged() {
+ while 1; do
+ echo "$LOCAL seems unchanged. Was the merge successful? [y/n]"
+ read answer
+ case answer in
+ y*|Y*) success;;
+ n*|N*) failure;;
+ esac
+ done
+}
+
# Clean up when interrupted
trap "failure" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
@@ -76,18 +92,16 @@ mv "$LOCAL" "$BACKUP"
cp "$BACKUP" "$LOCAL"
# Attempt to do a non-interactive merge
-if [ -n "$MERGE" ]; then
- $MERGE "$LOCAL" "$BASE" "$OTHER" 2> /dev/null && success
- cp "$BACKUP" "$LOCAL"
-elif [ -n "$DIFF3" ]; then
- echo $DIFF3 -m "$BACKUP" "$BASE" "$OTHER"
- $DIFF3 -m "$BACKUP" "$BASE" "$OTHER" > "$LOCAL" && success
- if [ $? -eq 2 ]; then
- echo "$DIFF3 failed! Exiting." 1>&2
- cp "$BACKUP" "$LOCAL"
+if [ -n "$MERGE" -o -n "$DIFF3" ]; then
+ if [ -n "$MERGE" ]; then
+ $MERGE "$LOCAL" "$BASE" "$OTHER" 2> /dev/null && success
+ elif [ -n "$DIFF3" ]; then
+ $DIFF3 -m "$BACKUP" "$BASE" "$OTHER" > "$LOCAL" && success
+ fi
+ if [ $? -gt 1 ]; then
+ echo "automatic merge failed! Exiting." 1>&2
failure
fi
- cp "$BACKUP" "$LOCAL"
fi
# on MacOS X try FileMerge.app, shipped with Apple's developer tools
@@ -97,71 +111,66 @@ if [ -n "$FILEMERGE" ]; then
# filemerge prefers the right by default
$FILEMERGE -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL"
[ $? -ne 0 ] && echo "FileMerge failed to launch" && failure
- if test "$LOCAL" -nt "$CHGTEST"
- then
- success
- else
- echo "$LOCAL seems unchanged. Was the merge successful?"
- select answer in yes no
- do
- test "$answer" == "yes" && success || failure
- done
- fi
- failure
+ test "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged
fi
if [ -n "$DISPLAY" ]; then
# try using kdiff3, which is fairly nice
if [ -n "$KDIFF3" ]; then
- $KDIFF3 --auto "$BASE" "$LOCAL" "$OTHER" -o "$LOCAL" || failure
- success
+ $KDIFF3 --auto "$BASE" "$LOCAL" "$OTHER" -o "$LOCAL" || failure
+ success
fi
# try using tkdiff, which is a bit less sophisticated
if [ -n "$TKDIFF" ]; then
- $TKDIFF "$LOCAL" "$OTHER" -a "$BASE" -o "$LOCAL" || failure
- success
+ $TKDIFF "$LOCAL" "$OTHER" -a "$BASE" -o "$LOCAL" || failure
+ success
+ fi
+
+ if [ -n "$MELD" ]; then
+ cp "$BACKUP" "$CHGTEST"
+ # protect our feet - meld allows us to save to the left file
+ cp "$BACKUP" "$LOCAL.tmp.$RAND"
+ # Meld doesn't have automatic merging, so to reduce intervention
+ # use the file with conflicts
+ $MELD "$LOCAL.tmp.$RAND" "$LOCAL" "$OTHER" || failure
+ # Also it doesn't return good error code
+ test "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged
fi
fi
# Attempt to do a merge with $EDITOR
-if [ -n "$MERGE" ]; then
- echo "conflicts detected in $LOCAL"
- $MERGE "$LOCAL" "$BASE" "$OTHER" 2>/dev/null || $EDITOR "$LOCAL"
- success
-fi
-
-if [ -n "$DIFF3" ]; then
+if [ -n "$MERGE" -o -n "$DIFF3" ]; then
echo "conflicts detected in $LOCAL"
- $DIFF3 -m "$BACKUP" "$BASE" "$OTHER" > "$LOCAL" || {
- case $? in
- 1)
- $EDITOR "$LOCAL" ;;
- 2) echo "$DIFF3 failed! Exiting." 1>&2
- cp "$BACKUP" "$LOCAL"
- failure ;;
- esac
- success
- }
+ cp "$BACKUP" "$CHGTEST"
+ $EDITOR "$LOCAL" || failure
+ # Some editors do not return meaningful error codes
+ # Do not take any chances
+ test "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged
fi
# attempt to manually merge with diff and patch
if [ -n "$DIFF" -a -n "$PATCH" ]; then
(umask 077 && mkdir "$HGTMP") || {
- echo "Could not create temporary directory $HGTMP" 1>&2
- failure
+ echo "Could not create temporary directory $HGTMP" 1>&2
+ failure
}
$DIFF -u "$BASE" "$OTHER" > "$HGTMP/diff" || :
if $PATCH "$LOCAL" < "$HGTMP/diff"; then
- success
+ success
else
- # If rejects are empty after using the editor, merge was ok
- $EDITOR "$LOCAL" "$LOCAL.rej" && test -s "$LOCAL.rej" || success
+ # If rejects are empty after using the editor, merge was ok
+ $EDITOR "$LOCAL" "$LOCAL.rej" || failure
+ test -s "$LOCAL.rej" || success
fi
failure
fi
-echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!"
+echo
+echo "hgmerge: unable to find any merge utility!"
+echo "supported programs:"
+echo "merge, FileMerge, tkdiff, kdiff3, meld, diff+patch"
+echo
failure
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -17,6 +17,10 @@
#define inline
#endif
+#ifdef __SUNPRO_C
+# define inline
+#endif
+
#ifdef _WIN32
#ifdef _MSC_VER
#define inline __inline
--- a/mercurial/hgweb.py
+++ b/mercurial/hgweb.py
@@ -7,6 +7,7 @@
# of the GNU General Public License, incorporated herein by reference.
import os, cgi, sys, urllib
+import mimetypes
from demandload import demandload
demandload(globals(), "mdiff time re socket zlib errno ui hg ConfigParser")
demandload(globals(), "zipfile tempfile StringIO tarfile BaseHTTPServer util")
@@ -845,6 +846,7 @@ class hgweb(object):
'ca': [('cmd', ['archive']), ('node', None)],
'tags': [('cmd', ['tags'])],
'tip': [('cmd', ['changeset']), ('node', ['tip'])],
+ 'static': [('cmd', ['static']), ('file', None)]
}
for k in shortcuts.iterkeys():
@@ -860,6 +862,7 @@ class hgweb(object):
expand_form(req.form)
t = self.repo.ui.config("web", "templates", templatepath())
+ static = self.repo.ui.config("web", "static", os.path.join(t,"static"))
m = os.path.join(t, "map")
style = self.repo.ui.config("web", "style", "")
if req.form.has_key('style'):
@@ -983,6 +986,38 @@ class hgweb(object):
req.write(self.t("error"))
+ elif req.form['cmd'][0] == 'static':
+ fname = req.form['file'][0]
+
+ fname = os.path.realpath(os.path.join(static, fname))
+
+ try:
+ # the static dir should be a substring in the real
+ # file path, if it is not, we have something strange
+ # going on => security breach attempt?
+ #
+ # This will either:
+ # 1) find the `static' path at index 0 = success
+ # 2) find the `static' path at other index = error
+ # 3) not find the `static' path = ValueError generated
+ if fname.index(static) != 0:
+ # generate ValueError manually
+ raise ValueError()
+
+ os.stat(fname)
+
+ ct = mimetypes.guess_type(fname)[0]
+ if ct == None:
+ ct = "text/plain"
+
+ req.write("Content-type: " + ct + "\n\n" + file(fname).read())
+ except ValueError:
+ # security breach attempt
+ req.write(self.t("error"))
+ except OSError, e:
+ if e.errno == errno.ENOENT:
+ req.write(self.t("error"))
+
else:
req.write(self.t("error"))
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -235,8 +235,7 @@ class localrepository(object):
if os.path.exists(self.join("journal")):
self.ui.status(_("rolling back interrupted transaction\n"))
transaction.rollback(self.opener, self.join("journal"))
- self.manifest = manifest.manifest(self.opener)
- self.changelog = changelog.changelog(self.opener)
+ self.reload()
return True
else:
self.ui.warn(_("no interrupted transaction available\n"))
@@ -250,10 +249,20 @@ class localrepository(object):
self.ui.status(_("rolling back last transaction\n"))
transaction.rollback(self.opener, self.join("undo"))
util.rename(self.join("undo.dirstate"), self.join("dirstate"))
- self.dirstate.read()
+ self.reload()
+ self.wreload()
else:
self.ui.warn(_("no undo information available\n"))
+ def wreload(self):
+ self.dirstate.read()
+
+ def reload(self):
+ self.changelog.load()
+ self.manifest.load()
+ self.tagscache = None
+ self.nodetagscache = None
+
def do_lock(self, lockname, wait, releasefn=None, acquirefn=None):
try:
l = lock.lock(self.join(lockname), 0, releasefn)
@@ -274,12 +283,12 @@ class localrepository(object):
return l
def lock(self, wait=1):
- return self.do_lock("lock", wait)
+ return self.do_lock("lock", wait, acquirefn=self.reload)
def wlock(self, wait=1):
return self.do_lock("wlock", wait,
self.dirstate.write,
- self.dirstate.read)
+ self.wreload)
def checkfilemerge(self, filename, text, filelog, manifest1, manifest2):
"determine whether a new filenode is needed"
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -13,7 +13,7 @@ of the GNU General Public License, incor
from node import *
from i18n import gettext as _
from demandload import demandload
-demandload(globals(), "binascii errno heapq mdiff sha struct zlib")
+demandload(globals(), "binascii errno heapq mdiff os sha struct zlib")
def hash(text, p1, p2):
"""generate a hash from the given text and its parent hashes
@@ -187,15 +187,33 @@ class revlog(object):
self.indexfile = indexfile
self.datafile = datafile
self.opener = opener
+
+ self.indexstat = None
self.cache = None
self.chunkcache = None
+ self.load()
+ def load(self):
try:
- i = self.opener(self.indexfile).read()
+ f = self.opener(self.indexfile)
except IOError, inst:
if inst.errno != errno.ENOENT:
raise
i = ""
+ else:
+ try:
+ st = os.fstat(f.fileno())
+ except AttributeError, inst:
+ st = None
+ else:
+ oldst = self.indexstat
+ if (oldst and st.st_dev == oldst.st_dev
+ and st.st_ino == oldst.st_ino
+ and st.st_mtime == oldst.st_mtime
+ and st.st_ctime == oldst.st_ctime):
+ return
+ self.indexstat = st
+ i = f.read()
if i and i[:4] != "\0\0\0\0":
raise RevlogError(_("incompatible revlog signature on %s") %
--- a/setup.py
+++ b/setup.py
@@ -89,7 +89,9 @@ try:
data_files=[('mercurial/templates',
['templates/map'] +
glob.glob('templates/map-*') +
- glob.glob('templates/*.tmpl'))],
+ glob.glob('templates/*.tmpl')),
+ ('mercurial/templates/static',
+ glob.glob('templates/static/*'))],
cmdclass=cmdclass,
scripts=['hg', 'hgmerge'],
options=dict(bdist_mpkg=dict(zipdist=True,
--- a/templates/error-gitweb.tmpl
+++ b/templates/error-gitweb.tmpl
@@ -1,11 +1,21 @@
#header#
+<title>#repo|escape#: Error</title>
+<link rel="alternate" type="application/rss+xml"
+ href="?cmd=changelog;style=rss" title="RSS feed for #repo|escape#">
+</head>
+<body>
+
+<div class="page_header">
+<a href="http://www.selenic.com/mercurial/" title="Mercurial"><div style="float:right;">Mercurial</div></a><a href="?cmd=summary;style=gitweb">#repo|escape#</a> / error
+</div>
+
<div class="page_nav">
-<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;style=gitweb">log</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a><br/>
+<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=manifest;manifest=#manifest#;path=/;style=gitweb">manifest</a><br/>
</div>
<div>
<br/>
-<i>Error parsing query string</i><br/>
+<i>An error occured while processing your request</i><br/>
<br/>
</div>
--- a/templates/header-gitweb.tmpl
+++ b/templates/header-gitweb.tmpl
@@ -6,54 +6,5 @@ Content-type: text/html
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="robots" content="index, nofollow"/>
-<style type="text/css">
-body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
-a { color:#0000cc; }
-a:hover, a:visited, a:active { color:#880000; }
-div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
-div.page_header a:visited { color:#0000cc; }
-div.page_header a:hover { color:#880000; }
-div.page_nav { padding:8px; }
-div.page_nav a:visited { color:#0000cc; }
-div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
-div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; }
-div.page_footer_text { float:left; color:#555555; font-style:italic; }
-div.page_body { padding:8px; }
-div.title, a.title {
- display:block; padding:6px 8px;
- font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
-}
-a.title:hover { background-color: #d9d8d1; }
-div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
-div.log_body { padding:8px 8px 8px 150px; }
-span.age { position:relative; float:left; width:142px; font-style:italic; }
-div.log_link {
- padding:0px 8px;
- font-size:10px; font-family:sans-serif; font-style:normal;
- position:relative; float:left; width:136px;
-}
-div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
-a.list { text-decoration:none; color:#000000; }
-a.list:hover { text-decoration:underline; color:#880000; }
-table { padding:8px 4px; }
-th { padding:2px 5px; font-size:12px; text-align:left; }
-tr.light:hover, .parity0:hover { background-color:#edece6; }
-tr.dark, .parity1 { background-color:#f6f6f0; }
-tr.dark:hover, .parity1:hover { background-color:#edece6; }
-td { padding:2px 5px; font-size:12px; vertical-align:top; }
-td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
-div.pre { font-family:monospace; font-size:12px; white-space:pre; }
-div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
-div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
-div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
-.linenr { color:#999999; text-decoration:none }
-a.rss_logo {
- float:right; padding:3px 0px; width:35px; line-height:10px;
- border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
- color:#ffffff; background-color:#ff6600;
- font-weight:bold; font-family:sans-serif; font-size:10px;
- text-align:center; text-decoration:none;
-}
-a.rss_logo:hover { background-color:#ee5500; }
-</style>
+<style type="text/css">/*<![CDATA[*/ @import "?static=style-gitweb.css"; /*]]>*/</style>
--- a/templates/header.tmpl
+++ b/templates/header.tmpl
@@ -4,77 +4,4 @@ Content-type: text/html
<html>
<head>
<meta name="robots" content="index, nofollow" />
-<style type="text/css">
-<!--
-a { text-decoration:none; }
-.parity0 { background-color: #dddddd; }
-.parity1 { background-color: #eeeeee; }
-.lineno { width: 60px; color: #aaaaaa; font-size: smaller;
- text-align: right; padding-right:1em; }
-.plusline { color: green; }
-.minusline { color: red; }
-.atline { color: purple; }
-.annotate { font-size: smaller; text-align: right; padding-right: 1em; }
-.buttons a {
- background-color: #666666;
- padding: 2pt;
- color: white;
- font-family: sans;
- font-weight: bold;
-}
-.navigate a {
- background-color: #ccc;
- padding: 2pt;
- font-family: sans;
- color: black;
-}
-
-.metatag {
- background-color: #888888;
- color: white;
- text-align: right;
-}
-
-/* Common */
-pre { margin: 0; }
-
-.logo {
- background-color: #333;
- padding: 4pt;
- margin: 8pt 0 8pt 8pt;
- font-family: sans;
- font-size: 60%;
- color: white;
- float: right;
- clear: right;
- text-align: left;
-}
-
-.logo a {
- font-weight: bold;
- font-size: 150%;
- color: #999;
-}
-
-/* Changelog entries */
-.changelogEntry { width: 100%; }
-.changelogEntry th { font-weight: normal; text-align: right; vertical-align: top; }
-.changelogEntry th.age, .changelogEntry th.firstline { font-weight: bold; }
-.changelogEntry th.firstline { text-align: left; width: inherit; }
-
-/* Tag entries */
-#tagEntries { list-style: none; margin: 0; padding: 0; }
-#tagEntries .tagEntry { list-style: none; margin: 0; padding: 0; }
-#tagEntries .tagEntry span.node { font-family: monospace; }
-
-/* Changeset entry */
-#changesetEntry { }
-#changesetEntry th { font-weight: normal; background-color: #888; color: #fff; text-align: right; }
-#changesetEntry th.files, #changesetEntry th.description { vertical-align: top; }
-
-/* File diff view */
-#filediffEntry { }
-#filediffEntry th { font-weight: normal; background-color: #888; color: #fff; text-align: right; }
-
--->
-</style>
+<style type="text/css">/*<![CDATA[*/ @import "?static=style.css"; /*]]>*/</style>
new file mode 100644
--- /dev/null
+++ b/templates/static/style-gitweb.css
@@ -0,0 +1,48 @@
+body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; }
+a { color:#0000cc; }
+a:hover, a:visited, a:active { color:#880000; }
+div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; }
+div.page_header a:visited { color:#0000cc; }
+div.page_header a:hover { color:#880000; }
+div.page_nav { padding:8px; }
+div.page_nav a:visited { color:#0000cc; }
+div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px}
+div.page_footer { height:17px; padding:4px 8px; background-color: #d9d8d1; }
+div.page_footer_text { float:left; color:#555555; font-style:italic; }
+div.page_body { padding:8px; }
+div.title, a.title {
+ display:block; padding:6px 8px;
+ font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000;
+}
+a.title:hover { background-color: #d9d8d1; }
+div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; }
+div.log_body { padding:8px 8px 8px 150px; }
+span.age { position:relative; float:left; width:142px; font-style:italic; }
+div.log_link {
+ padding:0px 8px;
+ font-size:10px; font-family:sans-serif; font-style:normal;
+ position:relative; float:left; width:136px;
+}
+div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; }
+a.list { text-decoration:none; color:#000000; }
+a.list:hover { text-decoration:underline; color:#880000; }
+table { padding:8px 4px; }
+th { padding:2px 5px; font-size:12px; text-align:left; }
+tr.light:hover, .parity0:hover { background-color:#edece6; }
+tr.dark, .parity1 { background-color:#f6f6f0; }
+tr.dark:hover, .parity1:hover { background-color:#edece6; }
+td { padding:2px 5px; font-size:12px; vertical-align:top; }
+td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; }
+div.pre { font-family:monospace; font-size:12px; white-space:pre; }
+div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; }
+div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; }
+div.search { margin:4px 8px; position:absolute; top:56px; right:12px }
+.linenr { color:#999999; text-decoration:none }
+a.rss_logo {
+ float:right; padding:3px 0px; width:35px; line-height:10px;
+ border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
+ color:#ffffff; background-color:#ff6600;
+ font-weight:bold; font-family:sans-serif; font-size:10px;
+ text-align:center; text-decoration:none;
+}
+a.rss_logo:hover { background-color:#ee5500; }
new file mode 100644
--- /dev/null
+++ b/templates/static/style.css
@@ -0,0 +1,70 @@
+a { text-decoration:none; }
+.parity0 { background-color: #dddddd; }
+.parity1 { background-color: #eeeeee; }
+.lineno { width: 60px; color: #aaaaaa; font-size: smaller;
+ text-align: right; padding-right:1em; }
+.plusline { color: green; }
+.minusline { color: red; }
+.atline { color: purple; }
+.annotate { font-size: smaller; text-align: right; padding-right: 1em; }
+.buttons a {
+ background-color: #666666;
+ padding: 2pt;
+ color: white;
+ font-family: sans;
+ font-weight: bold;
+}
+.navigate a {
+ background-color: #ccc;
+ padding: 2pt;
+ font-family: sans;
+ color: black;
+}
+
+.metatag {
+ background-color: #888888;
+ color: white;
+ text-align: right;
+}
+
+/* Common */
+pre { margin: 0; }
+
+.logo {
+ background-color: #333;
+ padding: 4pt;
+ margin: 8pt 0 8pt 8pt;
+ font-family: sans;
+ font-size: 60%;
+ color: white;
+ float: right;
+ clear: right;
+ text-align: left;
+}
+
+.logo a {
+ font-weight: bold;
+ font-size: 150%;
+ color: #999;
+}
+
+/* Changelog entries */
+.changelogEntry { width: 100%; }
+.changelogEntry th { font-weight: normal; text-align: right; vertical-align: top; }
+.changelogEntry th.age, .changelogEntry th.firstline { font-weight: bold; }
+.changelogEntry th.firstline { text-align: left; width: inherit; }
+
+/* Tag entries */
+#tagEntries { list-style: none; margin: 0; padding: 0; }
+#tagEntries .tagEntry { list-style: none; margin: 0; padding: 0; }
+#tagEntries .tagEntry span.node { font-family: monospace; }
+
+/* Changeset entry */
+#changesetEntry { }
+#changesetEntry th { font-weight: normal; background-color: #888; color: #fff; text-align: right; }
+#changesetEntry th.files, #changesetEntry th.description { vertical-align: top; }
+
+/* File diff view */
+#filediffEntry { }
+#filediffEntry th { font-weight: normal; background-color: #888; color: #fff; text-align: right; }
+
--- a/tests/test-archive
+++ b/tests/test-archive
@@ -18,8 +18,7 @@ echo "name = test-archive" >> .hg/hgrc
echo "allowzip = true" >> .hg/hgrc
echo "allowgz = true" >> .hg/hgrc
echo "allowbz2 = true" >> .hg/hgrc
-serverpid=`mktemp`
-hg serve -p 20059 -d --pid-file=$serverpid
+hg serve -p 20059 -d --pid-file=hg.pid
TIP=`hg id -v | cut -f1 -d' '`
QTIP=`hg id -q`
@@ -35,5 +34,4 @@ http_proxy= python getarchive.py "$TIP"
http_proxy= python getarchive.py "$TIP" zip > archive.zip
unzip -t archive.zip | sed "s/$QTIP/TIP/"
-kill `cat $serverpid`
-rm $serverpid
+kill `cat hg.pid`
new file mode 100755
--- /dev/null
+++ b/tests/test-clone-pull-corruption
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Corrupt an hg repo with a pull started during an aborted commit
+#
+
+# Create two repos, so that one of them can pull from the other one.
+hg init source
+cd source
+touch foo
+hg add foo
+hg ci -m 'add foo'
+hg clone . ../corrupted
+echo >> foo
+hg ci -m 'change foo'
+
+# Add a hook to wait 5 seconds and then abort the commit
+cd ../corrupted
+echo '[hooks]' >> .hg/hgrc
+echo 'pretxncommit = sleep 5; exit 1' >> .hg/hgrc
+
+# start a commit...
+touch bar
+hg add bar
+hg ci -m 'add bar' &
+
+# ... and start a pull while the commit is still running
+sleep 1
+hg pull ../source 2>/dev/null
+
+# see what happened
+wait
+hg verify
new file mode 100644
--- /dev/null
+++ b/tests/test-clone-pull-corruption.out
@@ -0,0 +1,15 @@
+pulling from ../source
+abort: pretxncommit hook exited with status 1
+transaction abort!
+rollback completed
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+(run 'hg update' to get a working copy)
+checking changesets
+checking manifests
+crosschecking files in changesets and manifests
+checking files
+1 files, 2 changesets, 2 total revisions
--- a/tests/test-pull
+++ b/tests/test-pull
@@ -7,8 +7,7 @@ hg init
hg addremove
hg commit -m 1
hg verify
-serverpid=`mktemp`
-hg serve -p 20059 -d --pid-file=$serverpid
+hg serve -p 20059 -d --pid-file=hg.pid
cd ..
hg clone http://localhost:20059/ copy
@@ -19,5 +18,4 @@ cat foo
hg manifest
hg pull
-kill `cat $serverpid`
-rm $serverpid
+kill `cat ../test/hg.pid`
new file mode 100755
--- /dev/null
+++ b/tests/test-pull-pull-corruption
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# Corrupt an hg repo with two pulls.
+#
+
+# create one repo with a long history
+hg init source1
+cd source1
+touch foo
+hg add foo
+for i in 1 2 3 4 5 6 7 8 9 10; do
+ echo $i >> foo
+ hg ci -m $i
+done
+cd ..
+
+# create one repo with a shorter history
+hg clone -r 0 source1 source2
+cd source2
+echo a >> foo
+hg ci -m a
+cd ..
+
+# create a third repo to pull both other repos into it
+hg init corrupted
+cd corrupted
+# use a hook to make the second pull start while the first one is still running
+echo '[hooks]' >> .hg/hgrc
+echo 'prechangegroup = sleep 5' >> .hg/hgrc
+
+# start a pull...
+hg pull ../source1 &
+
+# ... and start another pull before the first one has finished
+sleep 1
+hg pull ../source2 2>/dev/null
+
+# see the result
+wait
+hg verify
+
new file mode 100644
--- /dev/null
+++ b/tests/test-pull-pull-corruption.out
@@ -0,0 +1,24 @@
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+pulling from ../source2
+pulling from ../source1
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 10 changesets with 10 changes to 1 files
+(run 'hg update' to get a working copy)
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files (+1 heads)
+(run 'hg update' to get a working copy)
+checking changesets
+checking manifests
+crosschecking files in changesets and manifests
+checking files
+1 files, 11 changesets, 11 total revisions