--- a/mercurial/hg.py Sun Dec 10 00:06:45 2006 +0100
+++ b/mercurial/hg.py Sun Dec 10 00:06:59 2006 +0100
@@ -149,13 +149,23 @@
copy = False
if copy:
- # we lock here to avoid premature writing to the target
+ def force_copy(src, dst):
+ try:
+ util.copyfiles(src, dst)
+ except OSError, inst:
+ if inst.errno != errno.ENOENT:
+ 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)
os.mkdir(dest_path)
+ # copy the requires file
+ force_copy(src_repo.join("requires"),
+ os.path.join(dest_path, "requires"))
+ # we lock here to avoid premature writing to the target
dest_lock = lock.lock(os.path.join(dest_store, "lock"))
files = ("data",
@@ -164,11 +174,7 @@
for f in files:
src = os.path.join(src_store, f)
dst = os.path.join(dest_store, f)
- try:
- util.copyfiles(src, dst)
- except OSError, inst:
- if inst.errno != errno.ENOENT:
- raise
+ force_copy(src, dst)
# we need to re-init the repo after manually copying the data
# into it
--- a/mercurial/localrepo.py Sun Dec 10 00:06:45 2006 +0100
+++ b/mercurial/localrepo.py Sun Dec 10 00:06:59 2006 +0100
@@ -16,6 +16,7 @@
class localrepository(repo.repository):
capabilities = ('lookup', 'changegroupsubset')
+ supported = ('revlogv1',)
def __del__(self):
self.transhandle = None
@@ -44,10 +45,27 @@
os.mkdir(self.path)
#if self.spath != self.path:
# os.mkdir(self.spath)
+ requirements = ("revlogv1",)
+ reqfile = self.opener("requires", "w")
+ for r in requirements:
+ reqfile.write("%s\n" % r)
+ reqfile.close()
else:
raise repo.RepoError(_("repository %s not found") % path)
elif create:
raise repo.RepoError(_("repository %s already exists") % path)
+ else:
+ # find requirements
+ try:
+ requirements = self.opener("requires").read().splitlines()
+ except IOError, inst:
+ if inst.errno != errno.ENOENT:
+ raise
+ requirements = []
+ # check them
+ for r in requirements:
+ if r not in self.supported:
+ raise repo.RepoError(_("requirement '%s' not supported") % r)
# setup store
self.spath = self.path
--- a/mercurial/statichttprepo.py Sun Dec 10 00:06:45 2006 +0100
+++ b/mercurial/statichttprepo.py Sun Dec 10 00:06:59 2006 +0100
@@ -37,7 +37,20 @@
self.ui = ui
self.revlogversion = 0
self.opener = opener(self.path)
+ # find requirements
+ try:
+ requirements = self.opener("requires").read().splitlines()
+ except IOError:
+ requirements = []
+ # check them
+ for r in requirements:
+ if r not in self.supported:
+ raise repo.RepoError(_("requirement '%s' not supported") % r)
+
+ # setup store
+ self.spath = self.path
self.sopener = opener(self.spath)
+
self.manifest = manifest.manifest(self.sopener)
self.changelog = changelog.changelog(self.sopener)
self.tagscache = None
--- a/tests/test-hup.out Sun Dec 10 00:06:45 2006 +0100
+++ b/tests/test-hup.out Sun Dec 10 00:06:59 2006 +0100
@@ -6,3 +6,4 @@
rollback completed
00changelog.i
journal.dirstate
+requires
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-requires Sun Dec 10 00:06:59 2006 +0100
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+mkdir t
+cd t
+hg init
+echo a > a
+hg add a
+hg commit -m test -d "1000000 0"
+rm .hg/requires
+hg tip
+echo indoor-pool > .hg/requires
+hg tip
+
+true
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-requires.out Sun Dec 10 00:06:59 2006 +0100
@@ -0,0 +1,7 @@
+changeset: 0:0acdaf898367
+tag: tip
+user: test
+date: Mon Jan 12 13:46:40 1970 +0000
+summary: test
+
+abort: requirement 'indoor-pool' not supported!