##// END OF EJS Templates
add "requires" file to the repo, specifying the requirements
Benoit Boissinot -
r3851:8f18e31c default
parent child Browse files
Show More
@@ -0,0 +1,14 b''
1 #!/bin/sh
2
3 mkdir t
4 cd t
5 hg init
6 echo a > a
7 hg add a
8 hg commit -m test -d "1000000 0"
9 rm .hg/requires
10 hg tip
11 echo indoor-pool > .hg/requires
12 hg tip
13
14 true
@@ -0,0 +1,7 b''
1 changeset: 0:0acdaf898367
2 tag: tip
3 user: test
4 date: Mon Jan 12 13:46:40 1970 +0000
5 summary: test
6
7 abort: requirement 'indoor-pool' not supported!
@@ -149,13 +149,23 b' def clone(ui, source, dest=None, pull=Fa'
149 copy = False
149 copy = False
150
150
151 if copy:
151 if copy:
152 # we lock here to avoid premature writing to the target
152 def force_copy(src, dst):
153 try:
154 util.copyfiles(src, dst)
155 except OSError, inst:
156 if inst.errno != errno.ENOENT:
157 raise
158
153 src_store = os.path.realpath(src_repo.spath)
159 src_store = os.path.realpath(src_repo.spath)
154 dest_path = os.path.realpath(os.path.join(dest, ".hg"))
160 dest_path = os.path.realpath(os.path.join(dest, ".hg"))
155 dest_store = dest_path
161 dest_store = dest_path
156 if not os.path.exists(dest):
162 if not os.path.exists(dest):
157 os.mkdir(dest)
163 os.mkdir(dest)
158 os.mkdir(dest_path)
164 os.mkdir(dest_path)
165 # copy the requires file
166 force_copy(src_repo.join("requires"),
167 os.path.join(dest_path, "requires"))
168 # we lock here to avoid premature writing to the target
159 dest_lock = lock.lock(os.path.join(dest_store, "lock"))
169 dest_lock = lock.lock(os.path.join(dest_store, "lock"))
160
170
161 files = ("data",
171 files = ("data",
@@ -164,11 +174,7 b' def clone(ui, source, dest=None, pull=Fa'
164 for f in files:
174 for f in files:
165 src = os.path.join(src_store, f)
175 src = os.path.join(src_store, f)
166 dst = os.path.join(dest_store, f)
176 dst = os.path.join(dest_store, f)
167 try:
177 force_copy(src, dst)
168 util.copyfiles(src, dst)
169 except OSError, inst:
170 if inst.errno != errno.ENOENT:
171 raise
172
178
173 # we need to re-init the repo after manually copying the data
179 # we need to re-init the repo after manually copying the data
174 # into it
180 # into it
@@ -16,6 +16,7 b' demandload(globals(), "os revlog time ut'
16
16
17 class localrepository(repo.repository):
17 class localrepository(repo.repository):
18 capabilities = ('lookup', 'changegroupsubset')
18 capabilities = ('lookup', 'changegroupsubset')
19 supported = ('revlogv1',)
19
20
20 def __del__(self):
21 def __del__(self):
21 self.transhandle = None
22 self.transhandle = None
@@ -44,10 +45,27 b' class localrepository(repo.repository):'
44 os.mkdir(self.path)
45 os.mkdir(self.path)
45 #if self.spath != self.path:
46 #if self.spath != self.path:
46 # os.mkdir(self.spath)
47 # os.mkdir(self.spath)
48 requirements = ("revlogv1",)
49 reqfile = self.opener("requires", "w")
50 for r in requirements:
51 reqfile.write("%s\n" % r)
52 reqfile.close()
47 else:
53 else:
48 raise repo.RepoError(_("repository %s not found") % path)
54 raise repo.RepoError(_("repository %s not found") % path)
49 elif create:
55 elif create:
50 raise repo.RepoError(_("repository %s already exists") % path)
56 raise repo.RepoError(_("repository %s already exists") % path)
57 else:
58 # find requirements
59 try:
60 requirements = self.opener("requires").read().splitlines()
61 except IOError, inst:
62 if inst.errno != errno.ENOENT:
63 raise
64 requirements = []
65 # check them
66 for r in requirements:
67 if r not in self.supported:
68 raise repo.RepoError(_("requirement '%s' not supported") % r)
51
69
52 # setup store
70 # setup store
53 self.spath = self.path
71 self.spath = self.path
@@ -37,7 +37,20 b' class statichttprepository(localrepo.loc'
37 self.ui = ui
37 self.ui = ui
38 self.revlogversion = 0
38 self.revlogversion = 0
39 self.opener = opener(self.path)
39 self.opener = opener(self.path)
40 # find requirements
41 try:
42 requirements = self.opener("requires").read().splitlines()
43 except IOError:
44 requirements = []
45 # check them
46 for r in requirements:
47 if r not in self.supported:
48 raise repo.RepoError(_("requirement '%s' not supported") % r)
49
50 # setup store
51 self.spath = self.path
40 self.sopener = opener(self.spath)
52 self.sopener = opener(self.spath)
53
41 self.manifest = manifest.manifest(self.sopener)
54 self.manifest = manifest.manifest(self.sopener)
42 self.changelog = changelog.changelog(self.sopener)
55 self.changelog = changelog.changelog(self.sopener)
43 self.tagscache = None
56 self.tagscache = None
@@ -6,3 +6,4 b' transaction abort!'
6 rollback completed
6 rollback completed
7 00changelog.i
7 00changelog.i
8 journal.dirstate
8 journal.dirstate
9 requires
General Comments 0
You need to be logged in to leave comments. Login now