Mercurial > hg
comparison mercurial/bundlerepo.py @ 23631:b8260abfeb7d
bundlerepo: implement safe phasecache
This patch makes bundlerepo use a subclass of phasecache that will allow phase
boundaries to be moved around, but will never write them to the underlying
repository.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Thu, 18 Dec 2014 11:38:48 -0800 |
parents | 510cafe72004 |
children | e7fcf58acd71 |
comparison
equal
deleted
inserted
replaced
23630:b9af235810cc | 23631:b8260abfeb7d |
---|---|
13 | 13 |
14 from node import nullid | 14 from node import nullid |
15 from i18n import _ | 15 from i18n import _ |
16 import os, tempfile, shutil | 16 import os, tempfile, shutil |
17 import changegroup, util, mdiff, discovery, cmdutil, scmutil, exchange | 17 import changegroup, util, mdiff, discovery, cmdutil, scmutil, exchange |
18 import localrepo, changelog, manifest, filelog, revlog, error | 18 import localrepo, changelog, manifest, filelog, revlog, error, phases |
19 | 19 |
20 class bundlerevlog(revlog.revlog): | 20 class bundlerevlog(revlog.revlog): |
21 def __init__(self, opener, indexfile, bundle, linkmapper): | 21 def __init__(self, opener, indexfile, bundle, linkmapper): |
22 # How it works: | 22 # How it works: |
23 # To retrieve a revision, we need to know the offset of the revision in | 23 # To retrieve a revision, we need to know the offset of the revision in |
182 | 182 |
183 class bundlepeer(localrepo.localpeer): | 183 class bundlepeer(localrepo.localpeer): |
184 def canpush(self): | 184 def canpush(self): |
185 return False | 185 return False |
186 | 186 |
187 class bundlephasecache(phases.phasecache): | |
188 def __init__(self, *args, **kwargs): | |
189 super(bundlephasecache, self).__init__(*args, **kwargs) | |
190 if util.safehasattr(self, 'opener'): | |
191 self.opener = scmutil.readonlyvfs(self.opener) | |
192 | |
193 def write(self): | |
194 raise NotImplementedError | |
195 | |
196 def _write(self, fp): | |
197 raise NotImplementedError | |
198 | |
199 def _updateroots(self, phase, newroots, tr): | |
200 self.phaseroots[phase] = newroots | |
201 self.invalidate() | |
202 self.dirty = True | |
203 | |
187 class bundlerepository(localrepo.localrepository): | 204 class bundlerepository(localrepo.localrepository): |
188 def __init__(self, ui, path, bundlename): | 205 def __init__(self, ui, path, bundlename): |
189 self._tempparent = None | 206 self._tempparent = None |
190 try: | 207 try: |
191 localrepo.localrepository.__init__(self, ui, path) | 208 localrepo.localrepository.__init__(self, ui, path) |
222 f = self.vfs.open(self.tempfile, mode="rb") | 239 f = self.vfs.open(self.tempfile, mode="rb") |
223 self.bundle = exchange.readbundle(ui, f, bundlename, self.vfs) | 240 self.bundle = exchange.readbundle(ui, f, bundlename, self.vfs) |
224 | 241 |
225 # dict with the mapping 'filename' -> position in the bundle | 242 # dict with the mapping 'filename' -> position in the bundle |
226 self.bundlefilespos = {} | 243 self.bundlefilespos = {} |
244 | |
245 @localrepo.unfilteredpropertycache | |
246 def _phasecache(self): | |
247 return bundlephasecache(self, self._phasedefaults) | |
227 | 248 |
228 @localrepo.unfilteredpropertycache | 249 @localrepo.unfilteredpropertycache |
229 def changelog(self): | 250 def changelog(self): |
230 # consume the header if it exists | 251 # consume the header if it exists |
231 self.bundle.changelogheader() | 252 self.bundle.changelogheader() |