changeset 3853:c0b449154a90

switch to the .hg/store layout, fix the tests
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Fri, 01 Dec 2006 13:34:09 +0100
parents 8a9a1a7e1698
children 4f6db0233606
files mercurial/hg.py mercurial/hgweb/common.py mercurial/localrepo.py mercurial/statichttprepo.py mercurial/streamclone.py mercurial/util.py tests/test-bundle-r tests/test-clone-r tests/test-commit-copy tests/test-copy tests/test-copy.out tests/test-copy2 tests/test-empty-group tests/test-encode tests/test-excessive-merge tests/test-filebranch tests/test-flags tests/test-http-clone-r tests/test-hup tests/test-hup.out tests/test-lock-badness tests/test-merge7 tests/test-parseindex tests/test-permissions tests/test-pull-permission tests/test-push-r tests/test-rename-merge1 tests/test-requires.out tests/test-ssh tests/test-ssh-clone-r tests/test-ssh.out
diffstat 31 files changed, 118 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Sun Dec 10 00:07:02 2006 +0100
+++ b/mercurial/hg.py	Fri Dec 01 13:34:09 2006 +0100
@@ -157,11 +157,15 @@
                     raise
 
         src_store = os.path.realpath(src_repo.spath)
-        dest_path = os.path.realpath(os.path.join(dest, ".hg"))
-        dest_store = dest_path
         if not os.path.exists(dest):
             os.mkdir(dest)
+        dest_path = os.path.realpath(os.path.join(dest, ".hg"))
         os.mkdir(dest_path)
+        if src_repo.spath != src_repo.path:
+            dest_store = os.path.join(dest_path, "store")
+            os.mkdir(dest_store)
+        else:
+            dest_store = dest_path
         # copy the requires file
         force_copy(src_repo.join("requires"),
                    os.path.join(dest_path, "requires"))
--- a/mercurial/hgweb/common.py	Sun Dec 10 00:07:02 2006 +0100
+++ b/mercurial/hgweb/common.py	Fri Dec 01 13:34:09 2006 +0100
@@ -10,12 +10,14 @@
 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
--- a/mercurial/localrepo.py	Sun Dec 10 00:07:02 2006 +0100
+++ b/mercurial/localrepo.py	Fri Dec 01 13:34:09 2006 +0100
@@ -16,7 +16,7 @@
 
 class localrepository(repo.repository):
     capabilities = ('lookup', 'changegroupsubset')
-    supported = ('revlogv1',)
+    supported = ('revlogv1', 'store')
 
     def __del__(self):
         self.transhandle = None
@@ -43,13 +43,14 @@
                 if not os.path.exists(path):
                     os.mkdir(path)
                 os.mkdir(self.path)
-                #if self.spath != self.path:
-                #    os.mkdir(self.spath)
-                requirements = ("revlogv1",)
+                os.mkdir(os.path.join(self.path, "store"))
+                requirements = ("revlogv1", "store")
                 reqfile = self.opener("requires", "w")
                 for r in requirements:
                     reqfile.write("%s\n" % r)
                 reqfile.close()
+                # 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:
@@ -68,8 +69,15 @@
                 raise repo.RepoError(_("requirement '%s' not supported") % r)
 
         # setup store
-        self.spath = self.path
-        self.sopener = util.opener(self.spath)
+        if "store" in requirements:
+            self.encodefn = util.encodefilename
+            self.decodefn = util.decodefilename
+            self.spath = os.path.join(self.path, "store")
+        else:
+            self.encodefn = lambda x: x
+            self.decodefn = lambda x: x
+            self.spath = self.path
+        self.sopener = util.encodedopener(util.opener(self.spath), self.encodefn)
 
         self.ui = ui.ui(parentui=parentui)
         try:
@@ -420,6 +428,7 @@
         return os.path.join(self.path, f)
 
     def sjoin(self, f):
+        f = self.encodefn(f)
         return os.path.join(self.spath, f)
 
     def wjoin(self, f):
--- a/mercurial/statichttprepo.py	Sun Dec 10 00:07:02 2006 +0100
+++ b/mercurial/statichttprepo.py	Fri Dec 01 13:34:09 2006 +0100
@@ -32,10 +32,10 @@
 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.opener = opener(self.path)
         # find requirements
         try:
@@ -48,8 +48,15 @@
                 raise repo.RepoError(_("requirement '%s' not supported") % r)
 
         # setup store
-        self.spath = self.path
-        self.sopener = opener(self.spath)
+        if "store" in requirements:
+            self.encodefn = util.encodefilename
+            self.decodefn = util.decodefilename
+            self.spath = self.path + "/store"
+        else:
+            self.encodefn = lambda x: x
+            self.decodefn = lambda x: x
+            self.spath = self.path
+        self.sopener = util.encodedopener(opener(self.spath), self.encodefn)
 
         self.manifest = manifest.manifest(self.sopener)
         self.changelog = changelog.changelog(self.sopener)
--- a/mercurial/streamclone.py	Sun Dec 10 00:07:02 2006 +0100
+++ b/mercurial/streamclone.py	Fri Dec 01 13:34:09 2006 +0100
@@ -79,6 +79,8 @@
     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()
--- a/mercurial/util.py	Sun Dec 10 00:07:02 2006 +0100
+++ b/mercurial/util.py	Fri Dec 01 13:34:09 2006 +0100
@@ -897,6 +897,10 @@
 
 encodefilename, decodefilename = _buildencodefun()
 
+def encodedopener(openerfn, fn):
+    def o(path, *args, **kw):
+        return openerfn(fn(path), *args, **kw)
+    return o
 
 def opener(base, audit=True):
     """
--- a/tests/test-bundle-r	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-bundle-r	Fri Dec 01 13:34:09 2006 +0100
@@ -41,11 +41,11 @@
 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
--- a/tests/test-clone-r	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-clone-r	Fri Dec 01 13:34:09 2006 +0100
@@ -41,11 +41,11 @@
 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
--- a/tests/test-commit-copy	Sun Dec 10 00:07:02 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 debugrename foo
-hg debugindex .hg/data/bar.i
+hg debugindex .hg/store/data/bar.i
--- a/tests/test-copy	Sun Dec 10 00:07:02 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"
 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
--- a/tests/test-copy.out	Sun Dec 10 00:07:02 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 in the metadata
 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
 copy: a
-ed156f22f0a6fde642de0b5eba0cbbb2  .hg/data/b.i
+ed156f22f0a6fde642de0b5eba0cbbb2  .hg/store/data/b.i
 60b725f10c9c85c70d97880dfe8191b3  bsum
 60b725f10c9c85c70d97880dfe8191b3  asum
 checking changesets
--- a/tests/test-copy2	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-copy2	Fri Dec 01 13:34:09 2006 +0100
@@ -14,7 +14,7 @@
 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"
 
 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"
--- a/tests/test-empty-group	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-empty-group	Fri Dec 01 13:34:09 2006 +0100
@@ -30,12 +30,12 @@
 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
--- a/tests/test-encode	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-encode	Fri Dec 01 13:34:09 2006 +0100
@@ -22,7 +22,7 @@
 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
--- a/tests/test-excessive-merge	Sun Dec 10 00:07:02 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 0"
 
 hg log
-hg debugindex .hg/00changelog.i
+hg debugindex .hg/store/00changelog.i
 
 echo
 
@@ -41,6 +41,6 @@
 
 echo
 
-hg debugindex .hg/data/a.i
+hg debugindex .hg/store/data/a.i
 
 hg verify
--- a/tests/test-filebranch	Sun Dec 10 00:07:02 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"
 
 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 --debug
--- a/tests/test-flags	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-flags	Fri Dec 01 13:34:09 2006 +0100
@@ -43,6 +43,6 @@
 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
--- a/tests/test-http-clone-r	Sun Dec 10 00:07:02 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 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
--- a/tests/test-hup	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-hup	Fri Dec 01 13:34:09 2006 +0100
@@ -10,7 +10,7 @@
 sleep 3
 kill -HUP $P
 wait
-ls .hg
+ls -R .hg
 
 
 
--- a/tests/test-hup.out	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-hup.out	Fri Dec 01 13:34:09 2006 +0100
@@ -4,6 +4,11 @@
 killed!
 transaction abort!
 rollback completed
+.hg:
 00changelog.i
 journal.dirstate
 requires
+store
+
+.hg/store:
+00changelog.i
--- a/tests/test-lock-badness	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-lock-badness	Fri Dec 01 13:34:09 2006 +0100
@@ -6,6 +6,6 @@
 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
--- a/tests/test-merge7	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-merge7	Fri Dec 01 13:34:09 2006 +0100
@@ -61,6 +61,6 @@
 
 cat test.txt | sed "s% .*%%"
 
-hg debugindex .hg/data/test.txt.i
+hg debugindex .hg/store/data/test.txt.i
 
 hg log
--- a/tests/test-parseindex	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-parseindex	Fri Dec 01 13:34:09 2006 +0100
@@ -43,7 +43,7 @@
         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))
--- a/tests/test-permissions	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-permissions	Fri Dec 01 13:34:09 2006 +0100
@@ -5,11 +5,11 @@
 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
 
--- a/tests/test-pull-permission	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-pull-permission	Fri Dec 01 13:34:09 2006 +0100
@@ -7,13 +7,13 @@
 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
--- a/tests/test-push-r	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-push-r	Fri Dec 01 13:34:09 2006 +0100
@@ -41,11 +41,11 @@
 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
--- a/tests/test-rename-merge1	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-rename-merge1	Fri Dec 01 13:34:09 2006 +0100
@@ -23,5 +23,5 @@
 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
--- a/tests/test-requires.out	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-requires.out	Fri Dec 01 13:34:09 2006 +0100
@@ -1,7 +1,2 @@
-changeset:   0:0acdaf898367
-tag:         tip
-user:        test
-date:        Mon Jan 12 13:46:40 1970 +0000
-summary:     test
-
+abort: index 00changelog.i unknown format 2!
 abort: requirement 'indoor-pool' not supported!
--- a/tests/test-ssh	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-ssh	Fri Dec 01 13:34:09 2006 +0100
@@ -28,7 +28,8 @@
 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
--- a/tests/test-ssh-clone-r	Sun Dec 10 00:07:02 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 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 ..
 
--- a/tests/test-ssh.out	Sun Dec 10 00:07:02 2006 +0100
+++ b/tests/test-ssh.out	Fri Dec 01 13:34:09 2006 +0100
@@ -11,20 +11,20 @@
 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 @@
 # 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 @@
 
 # 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: 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
 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