view tests/test-archive @ 2076:d007df6daf8e

Create an atomic opener that does not automatically rename on close The revlog.checkinlinesize() uses an atomic opener to replace the index file after converting it from inline to traditional .i and .d files. If this operation is interrupted, the atomic file class can overwrite a valid file with a partially written one. This patch introduces an atomic opener that does not automatically replace the destination file with the tempfile. This way an interrupted checkinlinesize() call turns into a noop.
author mason@suse.com
date Tue, 04 Apr 2006 16:38:44 -0400
parents 85daa4e03b4c
children 98cc126f9f3f
line wrap: on
line source

#!/bin/sh

mkdir test
cd test
hg init
echo foo>foo
hg addremove
hg commit -m 1
echo bar>bar
hg addremove
hg commit -m 2
mkdir baz
echo bletch>baz/bletch
hg addremove
hg commit -m 3
echo "[web]" >> .hg/hgrc
echo "name = test-archive" >> .hg/hgrc
echo "allowzip = true" >> .hg/hgrc
echo "allowgz = true" >> .hg/hgrc
echo "allowbz2 = true" >> .hg/hgrc
hg serve -p 20059 -d --pid-file=hg.pid

TIP=`hg id -v | cut -f1 -d' '`
QTIP=`hg id -q`
cat > getarchive.py <<EOF
import sys, urllib2
node, archive = sys.argv[1:]
f = urllib2.urlopen('http://127.0.0.1:20059/?cmd=archive;node=%s;type=%s'
                    % (node, archive))
sys.stdout.write(f.read())
EOF
http_proxy= python getarchive.py "$TIP" gz | gunzip -dc - | tar tf - | sed "s/$QTIP/TIP/"
http_proxy= python getarchive.py "$TIP" bz2 | bunzip2 -dc - | tar tf - | sed "s/$QTIP/TIP/"
http_proxy= python getarchive.py "$TIP" zip > archive.zip
unzip -t archive.zip | sed "s/$QTIP/TIP/"

kill `cat hg.pid`
sleep 1 # wait for server to scream and die