[PATCH 5 of 5] switch to the .hg/store layout, fix the tests
Benoit Boissinot
benoit.boissinot at ens-lyon.org
Fri Dec 1 11:35:34 UTC 2006
# HG changeset patch
# User Benoit Boissinot <benoit.boissinot at ens-lyon.org>
# Date 1164976449 -3600
# Node ID aae7ecec56f82b1038ac8f9ce810a56757724528
# Parent 9ace08ca67ea2ba16f1a454d9573125473e87e46
switch to the .hg/store layout, fix the tests
diff -r 9ace08ca67ea -r aae7ecec56f8 mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py Fri Dec 01 11:33:18 2006 +0100
+++ b/mercurial/hgweb/common.py Fri Dec 01 13:34:09 2006 +0100
@@ -10,12 +10,14 @@ import os.path
import os.path
def get_mtime(repo_path):
- hg_path = os.path.join(repo_path, ".hg")
- cl_path = os.path.join(hg_path, "00changelog.i")
- if os.path.exists(os.path.join(cl_path)):
+ store_path = os.path.join(repo_path, ".hg")
+ if not os.path.isdir(os.path.join(store_path, "data")):
+ store_path = os.path.join(store_path, "store")
+ cl_path = os.path.join(store_path, "00changelog.i")
+ if os.path.exists(cl_path):
return os.stat(cl_path).st_mtime
else:
- return os.stat(hg_path).st_mtime
+ return os.stat(store_path).st_mtime
def staticfile(directory, fname, req):
"""return a file inside directory with guessed content-type header
diff -r 9ace08ca67ea -r aae7ecec56f8 mercurial/localrepo.py
--- a/mercurial/localrepo.py Fri Dec 01 11:33:18 2006 +0100
+++ b/mercurial/localrepo.py Fri Dec 01 13:34:09 2006 +0100
@@ -31,12 +31,23 @@ class localrepository(repo.repository):
" here (.hg not found)"))
path = p
self.path = os.path.join(path, ".hg")
- self.spath = self.path
+ if os.path.isdir(self.join("data")):
+ self.encodefn = None
+ self.decodefn = None
+ self.spath = self.path
+ else:
+ self.encodefn = util.encodefilename
+ self.decodefn = util.decodefilename
+ self.spath = os.path.join(self.path, "store")
self.root = os.path.realpath(path)
self.origroot = path
self.opener = util.opener(self.path)
- self.sopener = util.opener(self.spath)
+ if self.encodefn:
+ self.sopener = util.wrapopener(util.opener(self.spath),
+ self.encodefn)
+ else:
+ self.sopener = util.opener(self.spath)
self.wopener = util.opener(self.root)
if not os.path.isdir(self.path):
@@ -46,6 +57,8 @@ class localrepository(repo.repository):
os.mkdir(self.path)
if self.spath != self.path:
os.mkdir(self.spath)
+ # create an invalid changelog
+ self.opener("00changelog.i", "a").write('\0\0\0\2')
else:
raise repo.RepoError(_("repository %s not found") % path)
elif create:
@@ -385,6 +398,8 @@ class localrepository(repo.repository):
return os.path.join(self.path, f)
def sjoin(self, f):
+ if self.encodefn:
+ f = self.encodefn(f)
return os.path.join(self.spath, f)
def wjoin(self, f):
diff -r 9ace08ca67ea -r aae7ecec56f8 mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py Fri Dec 01 11:33:18 2006 +0100
+++ b/mercurial/statichttprepo.py Fri Dec 01 13:34:09 2006 +0100
@@ -32,10 +32,23 @@ class statichttprepository(localrepo.loc
class statichttprepository(localrepo.localrepository):
def __init__(self, ui, path):
self._url = path
- self.path = (path + "/.hg")
- self.spath = self.path
self.ui = ui
self.revlogversion = 0
+
+ self.path = (path + "/.hg")
+ self.encodefn = None
+ self.decodefn = None
+ self.spath = self.path
+ try:
+ urllib2.urlopen(self.path + "/data")
+ except urllib2.HTTPError, inst:
+ if inst.code == 404:
+ self.encodefn = util.encodefilename
+ self.decodefn = util.decodefilename
+ self.spath = self.path + "/store"
+ except:
+ pass
+
self.opener = opener(self.path)
self.sopener = opener(self.spath)
self.manifest = manifest.manifest(self.sopener)
diff -r 9ace08ca67ea -r aae7ecec56f8 mercurial/streamclone.py
--- a/mercurial/streamclone.py Fri Dec 01 11:33:18 2006 +0100
+++ b/mercurial/streamclone.py Fri Dec 01 13:34:09 2006 +0100
@@ -79,6 +79,8 @@ def stream_out(repo, fileobj):
entries = []
total_bytes = 0
for name, size in walkrepo(repo.spath):
+ if repo.decodefn:
+ name = repo.decodefn(name)
entries.append((name, size))
total_bytes += size
repolock.release()
diff -r 9ace08ca67ea -r aae7ecec56f8 mercurial/util.py
--- a/mercurial/util.py Fri Dec 01 11:33:18 2006 +0100
+++ b/mercurial/util.py Fri Dec 01 13:34:09 2006 +0100
@@ -820,6 +820,12 @@ def _buildencodefun():
encodefilename, decodefilename = _buildencodefun()
+def wrapopener(opener, fn):
+ def o(path, *args, **kw):
+ path = fn(path)
+ return opener(path, *args, **kw)
+ return o
+
def opener(base, audit=True):
"""
return a function that opens files relative to base
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-bundle-r
--- a/tests/test-bundle-r Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-bundle-r Fri Dec 01 13:34:09 2006 +0100
@@ -41,11 +41,11 @@ hg update -C 3
hg update -C 3
hg mv afile anotherfile
hg commit -m "0.3m" -d "1000000 0"
-hg debugindex .hg/data/afile.i
-hg debugindex .hg/data/adifferentfile.i
-hg debugindex .hg/data/anotherfile.i
-hg debugindex .hg/data/fred.i
-hg debugindex .hg/00manifest.i
+hg debugindex .hg/store/data/afile.i
+hg debugindex .hg/store/data/adifferentfile.i
+hg debugindex .hg/store/data/anotherfile.i
+hg debugindex .hg/store/data/fred.i
+hg debugindex .hg/store/00manifest.i
hg verify
cd ..
for i in 0 1 2 3 4 5 6 7 8; do
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-clone-r
--- a/tests/test-clone-r Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-clone-r Fri Dec 01 13:34:09 2006 +0100
@@ -41,11 +41,11 @@ hg update -C 3
hg update -C 3
hg mv afile anotherfile
hg commit -m "0.3m"
-hg debugindex .hg/data/afile.i
-hg debugindex .hg/data/adifferentfile.i
-hg debugindex .hg/data/anotherfile.i
-hg debugindex .hg/data/fred.i
-hg debugindex .hg/00manifest.i
+hg debugindex .hg/store/data/afile.i
+hg debugindex .hg/store/data/adifferentfile.i
+hg debugindex .hg/store/data/anotherfile.i
+hg debugindex .hg/store/data/fred.i
+hg debugindex .hg/store/00manifest.i
hg verify
cd ..
for i in 0 1 2 3 4 5 6 7 8; do
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-commit-copy
--- a/tests/test-commit-copy Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-commit-copy Fri Dec 01 13:34:09 2006 +0100
@@ -11,4 +11,4 @@ hg ci -m 'cp bar foo; change bar'
hg ci -m 'cp bar foo; change bar'
hg debugrename foo
-hg debugindex .hg/data/bar.i
+hg debugindex .hg/store/data/bar.i
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-copy
--- a/tests/test-copy Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-copy Fri Dec 01 13:34:09 2006 +0100
@@ -13,16 +13,16 @@ echo "we should see one log entry for a"
echo "we should see one log entry for a"
hg log a
echo "this should show a revision linked to changeset 0"
-hg debugindex .hg/data/a.i
+hg debugindex .hg/store/data/a.i
echo "we should see one log entry for b"
hg log b
echo "this should show a revision linked to changeset 1"
-hg debugindex .hg/data/b.i
+hg debugindex .hg/store/data/b.i
echo "this should show the rename information in the metadata"
-hg debugdata .hg/data/b.d 0 | head -3 | tail -2
+hg debugdata .hg/store/data/b.d 0 | head -3 | tail -2
-$TESTDIR/md5sum.py .hg/data/b.i
+$TESTDIR/md5sum.py .hg/store/data/b.i
hg cat b > bsum
$TESTDIR/md5sum.py bsum
hg cat a > asum
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-copy.out
--- a/tests/test-copy.out Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-copy.out Fri Dec 01 13:34:09 2006 +0100
@@ -41,7 +41,7 @@ this should show the rename information
this should show the rename information in the metadata
copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
copy: a
-ed156f22f0a6fde642de0b5eba0cbbb2 .hg/data/b.i
+ed156f22f0a6fde642de0b5eba0cbbb2 .hg/store/data/b.i
60b725f10c9c85c70d97880dfe8191b3 bsum
60b725f10c9c85c70d97880dfe8191b3 asum
checking changesets
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-copy2
--- a/tests/test-copy2 Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-copy2 Fri Dec 01 13:34:09 2006 +0100
@@ -14,7 +14,7 @@ hg debugstate|grep '^copy'
hg debugstate|grep '^copy'
echo "# should match"
-hg debugindex .hg/data/foo.i
+hg debugindex .hg/store/data/foo.i
hg debugrename bar
echo bleah > foo
@@ -30,9 +30,9 @@ hg commit -m3 -d"0 0"
hg commit -m3 -d"0 0"
echo "# should show no parents for tip"
-hg debugindex .hg/data/bar.i
+hg debugindex .hg/store/data/bar.i
echo "# should match"
-hg debugindex .hg/data/foo.i
+hg debugindex .hg/store/data/foo.i
hg debugrename bar
echo "# should show no copies"
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-empty-group
--- a/tests/test-empty-group Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-empty-group Fri Dec 01 13:34:09 2006 +0100
@@ -30,12 +30,12 @@ hg merge 1
hg merge 1
hg ci -A -m m1 -d "1000000 0"
#hg log
-#hg debugindex .hg/00manifest.i
+#hg debugindex .hg/store/00manifest.i
hg update -C 1
hg merge 2
hg ci -A -m m2 -d "1000000 0"
#hg log
-#hg debugindex .hg/00manifest.i
+#hg debugindex .hg/store/00manifest.i
cd ..
hg clone -r 3 a b
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-encode
--- a/tests/test-encode Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-encode Fri Dec 01 13:34:09 2006 +0100
@@ -22,7 +22,7 @@ hg status
hg status
echo %% uncompressed contents in repo
-hg debugdata .hg/data/a.gz.d 0
+hg debugdata .hg/store/data/a.gz.d 0
echo %% uncompress our working dir copy
gunzip < a.gz
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-excessive-merge
--- a/tests/test-excessive-merge Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-excessive-merge Fri Dec 01 13:34:09 2006 +0100
@@ -26,7 +26,7 @@ hg ci -m "merge a/b -> blah" -d "1000000
hg ci -m "merge a/b -> blah" -d "1000000 0"
hg log
-hg debugindex .hg/00changelog.i
+hg debugindex .hg/store/00changelog.i
echo
@@ -41,6 +41,6 @@ hg manifest 4
echo
-hg debugindex .hg/data/a.i
+hg debugindex .hg/store/data/a.i
hg verify
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-filebranch
--- a/tests/test-filebranch Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-filebranch Fri Dec 01 13:34:09 2006 +0100
@@ -53,22 +53,22 @@ hg ci -m "merge" -d "1000000 0"
hg ci -m "merge" -d "1000000 0"
echo "main: we should have a merge here"
-hg debugindex .hg/00changelog.i
+hg debugindex .hg/store/00changelog.i
echo "log should show foo and quux changed"
hg log -v -r tip
echo "foo: we should have a merge here"
-hg debugindex .hg/data/foo.i
+hg debugindex .hg/store/data/foo.i
echo "bar: we shouldn't have a merge here"
-hg debugindex .hg/data/bar.i
+hg debugindex .hg/store/data/bar.i
echo "baz: we shouldn't have a merge here"
-hg debugindex .hg/data/baz.i
+hg debugindex .hg/store/data/baz.i
echo "quux: we shouldn't have a merge here"
-hg debugindex .hg/data/quux.i
+hg debugindex .hg/store/data/quux.i
echo "manifest entries should match tips of all files"
hg manifest
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-flags
--- a/tests/test-flags Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-flags Fri Dec 01 13:34:09 2006 +0100
@@ -43,6 +43,6 @@ ls -l ../test[123]/a > foo
ls -l ../test[123]/a > foo
cut -b 1-10 < foo
-hg debugindex .hg/data/a.i
-hg debugindex ../test2/.hg/data/a.i
-hg debugindex ../test1/.hg/data/a.i
+hg debugindex .hg/store/data/a.i
+hg debugindex ../test2/.hg/store/data/a.i
+hg debugindex ../test1/.hg/store/data/a.i
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-http-clone-r
--- a/tests/test-http-clone-r Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-http-clone-r Fri Dec 01 13:34:09 2006 +0100
@@ -42,11 +42,11 @@ hg update -C 3
hg update -C 3
hg mv afile anotherfile
hg commit -m "0.3m"
-hg debugindex .hg/data/afile.i
-hg debugindex .hg/data/adifferentfile.i
-hg debugindex .hg/data/anotherfile.i
-hg debugindex .hg/data/fred.i
-hg debugindex .hg/00manifest.i
+hg debugindex .hg/store/data/afile.i
+hg debugindex .hg/store/data/adifferentfile.i
+hg debugindex .hg/store/data/anotherfile.i
+hg debugindex .hg/store/data/fred.i
+hg debugindex .hg/store/00manifest.i
hg verify
echo "# Starting server"
hg serve -p 20061 -d --pid-file=../hg1.pid
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-hup
--- a/tests/test-hup Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-hup Fri Dec 01 13:34:09 2006 +0100
@@ -10,7 +10,7 @@ sleep 3
sleep 3
kill -HUP $P
wait
-ls .hg
+ls -R .hg
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-hup.out
--- a/tests/test-hup.out Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-hup.out Fri Dec 01 13:34:09 2006 +0100
@@ -4,5 +4,10 @@ killed!
killed!
transaction abort!
rollback completed
+.hg:
00changelog.i
journal.dirstate
+store
+
+.hg/store:
+00changelog.i
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-lock-badness
--- a/tests/test-lock-badness Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-lock-badness Fri Dec 01 13:34:09 2006 +0100
@@ -6,6 +6,6 @@ hg clone a b
hg clone a b
echo b > b/b
hg --cwd b ci -A -m b
-chmod 100 a/.hg
+chmod 100 a/.hg/store
hg --cwd b push ../a
-chmod 700 a/.hg
+chmod 700 a/.hg/store
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-merge7
--- a/tests/test-merge7 Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-merge7 Fri Dec 01 13:34:09 2006 +0100
@@ -61,6 +61,6 @@ HGMERGE=merge hg merge --debug
cat test.txt | sed "s% .*%%"
-hg debugindex .hg/data/test.txt.i
+hg debugindex .hg/store/data/test.txt.i
hg log
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-parseindex
--- a/tests/test-parseindex Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-parseindex Fri Dec 01 13:34:09 2006 +0100
@@ -43,7 +43,7 @@ def opener(*args):
return singlebyteread(f)
return wrapper
-cl = changelog.changelog(opener('.hg'))
+cl = changelog.changelog(opener('.hg/store'))
print cl.count(), 'revisions:'
for r in xrange(cl.count()):
print short(cl.node(r))
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-permissions
--- a/tests/test-permissions Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-permissions Fri Dec 01 13:34:09 2006 +0100
@@ -5,11 +5,11 @@ hg add a
hg add a
hg commit -m "1" -d "1000000 0"
hg verify
-chmod -r .hg/data/a.i
+chmod -r .hg/store/data/a.i
hg verify 2>/dev/null || echo verify failed
-chmod +r .hg/data/a.i
+chmod +r .hg/store/data/a.i
hg verify 2>/dev/null || echo verify failed
-chmod -w .hg/data/a.i
+chmod -w .hg/store/data/a.i
echo barber > a
hg commit -m "2" -d "1000000 0" 2>/dev/null || echo commit failed
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-pull-permission
--- a/tests/test-pull-permission Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-pull-permission Fri Dec 01 13:34:09 2006 +0100
@@ -7,13 +7,13 @@ hg add b
hg add b
hg ci -m "b" -d "1000000 0"
-chmod -w .hg
+chmod -w .hg/store
cd ..
hg clone a b
-chmod +w a/.hg # let test clean up
+chmod +w a/.hg/store # let test clean up
cd b
hg verify
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-push-r
--- a/tests/test-push-r Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-push-r Fri Dec 01 13:34:09 2006 +0100
@@ -41,11 +41,11 @@ hg update -C 3
hg update -C 3
hg mv afile anotherfile
hg commit -m "0.3m"
-hg debugindex .hg/data/afile.i
-hg debugindex .hg/data/adifferentfile.i
-hg debugindex .hg/data/anotherfile.i
-hg debugindex .hg/data/fred.i
-hg debugindex .hg/00manifest.i
+hg debugindex .hg/store/data/afile.i
+hg debugindex .hg/store/data/adifferentfile.i
+hg debugindex .hg/store/data/anotherfile.i
+hg debugindex .hg/store/data/fred.i
+hg debugindex .hg/store/00manifest.i
hg verify
cd ..
for i in 0 1 2 3 4 5 6 7 8; do
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-rename-merge1
--- a/tests/test-rename-merge1 Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-rename-merge1 Fri Dec 01 13:34:09 2006 +0100
@@ -23,5 +23,5 @@ hg status -AC
hg status -AC
cat b
hg ci -m "merge" -d "0 0"
-hg debugindex .hg/data/b.i
+hg debugindex .hg/store/data/b.i
hg debugrename b
\ No newline at end of file
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-ssh
--- a/tests/test-ssh Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-ssh Fri Dec 01 13:34:09 2006 +0100
@@ -28,7 +28,8 @@ hg init remote
hg init remote
cd remote
echo this > foo
-hg ci -A -m "init" -d "1000000 0" foo
+echo this > fooO
+hg ci -A -m "init" -d "1000000 0" foo fooO
echo '[server]' > .hg/hgrc
echo 'uncompressed = True' >> .hg/hgrc
echo '[hooks]' >> .hg/hgrc
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-ssh-clone-r
--- a/tests/test-ssh-clone-r Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-ssh-clone-r Fri Dec 01 13:34:09 2006 +0100
@@ -66,11 +66,11 @@ hg update -C 3
hg update -C 3
hg mv afile anotherfile
hg commit -m "0.3m"
-hg debugindex .hg/data/afile.i
-hg debugindex .hg/data/adifferentfile.i
-hg debugindex .hg/data/anotherfile.i
-hg debugindex .hg/data/fred.i
-hg debugindex .hg/00manifest.i
+hg debugindex .hg/store/data/afile.i
+hg debugindex .hg/store/data/adifferentfile.i
+hg debugindex .hg/store/data/anotherfile.i
+hg debugindex .hg/store/data/fred.i
+hg debugindex .hg/store/00manifest.i
hg verify
cd ..
diff -r 9ace08ca67ea -r aae7ecec56f8 tests/test-ssh.out
--- a/tests/test-ssh.out Fri Dec 01 11:33:18 2006 +0100
+++ b/tests/test-ssh.out Fri Dec 01 13:34:09 2006 +0100
@@ -11,20 +11,20 @@ checking manifests
checking manifests
crosschecking files in changesets and manifests
checking files
-1 files, 1 changesets, 1 total revisions
+2 files, 1 changesets, 2 total revisions
# clone remote via pull
requesting all changes
adding changesets
adding manifests
adding file changes
-added 1 changesets with 1 changes to 1 files
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+added 1 changesets with 2 changes to 2 files
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
# verify
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
-1 files, 1 changesets, 1 total revisions
+2 files, 1 changesets, 2 total revisions
# empty default pull
default = ssh://user@dummy/remote
pulling from ssh://user@dummy/remote
@@ -34,7 +34,7 @@ no changes found
# updating rc
# find outgoing
searching for changes
-changeset: 1:c54836a570be
+changeset: 1:572896fe480d
tag: tip
user: test
date: Mon Jan 12 13:46:40 1970 +0000
@@ -42,7 +42,7 @@ summary: add
# find incoming on the remote side
searching for changes
-changeset: 1:c54836a570be
+changeset: 1:572896fe480d
tag: tip
user: test
date: Mon Jan 12 13:46:40 1970 +0000
@@ -56,7 +56,7 @@ remote: adding file changes
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
# check remote tip
-changeset: 1:c54836a570be
+changeset: 1:572896fe480d
tag: tip
user: test
date: Mon Jan 12 13:46:40 1970 +0000
@@ -66,7 +66,7 @@ checking manifests
checking manifests
crosschecking files in changesets and manifests
checking files
-1 files, 2 changesets, 2 total revisions
+2 files, 2 changesets, 3 total revisions
bleah
# push should succeed
pushing to ssh://user@dummy/remote
More information about the Mercurial-devel
mailing list