##// END OF EJS Templates
localrepo: make supported features manageable in each repositories individually...
localrepo: make supported features manageable in each repositories individually Before this patch, all localrepositories support same features, because supported features are managed by the class variable "supported" of "localrepository". For example, "largefiles" feature provided by largefiles extension is recognized as supported, by adding the feature name to "supported" of "localrepository". So, commands handling multiple repositories at a time like below misunderstand that such features are supported also in repositories not enabling corresponded extensions: - clone/pull from or push to localhost - recursive execution in subrepo tree "reposetup()" can't be used to fix this problem, because it is invoked after checking whether supported features satisfy ones required in the target repository. So, this patch adds the set object named as "featuresetupfuncs" to "localrepository" to manage hook functions to setup supported features of each repositories. If any functions are added to "featuresetupfuncs", they are invoked, and information about supported features is managed in each repositories individually. This patch also adds checking below: - pull from localhost: whether features supported in the local(= dst) repository satisfies ones required in the remote(= src) - push to localhost: whether features supported in the remote(= dst) repository satisfies ones required in the local(= src) Managing supported features by the class variable means that there is no difference of supported features between each instances of "localrepository" in the same Python process, so such checking is not needed before this patch. Even with this patch, if intermediate bundlefile is used as pulling source, pulling indirectly from the remote repository, which requires features more than ones supported in the local, can't be prevented, because bundlefile has no information about "required features" in it.

File last commit:

r19007:266b5fb7 default
r19778:55ef7903 default
Show More
localstore.py
73 lines | 2.4 KiB | text/x-python | PythonLexer
various
hgext: add largefiles extension...
r15168 # Copyright 2009-2010 Gregory P. Ward
# Copyright 2009-2010 Intelerad Medical Systems Incorporated
# Copyright 2010-2011 Fog Creek Software
# Copyright 2010-2011 Unity Technologies
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
Greg Ward
largefiles: improve comments, internal docstrings...
r15252 '''store class for local filesystem'''
various
hgext: add largefiles extension...
r15168
from mercurial.i18n import _
import lfutil
import basestore
class localstore(basestore.basestore):
Benjamin Pollack
largefiles: make the store primary, and the user cache secondary...
r15317 '''localstore first attempts to grab files out of the store in the remote
Mads Kiilerich
fix trivial spelling errors
r17424 Mercurial repository. Failing that, it attempts to grab the files from
Benjamin Pollack
largefiles: make the store primary, and the user cache secondary...
r15317 the user cache.'''
various
hgext: add largefiles extension...
r15168
def __init__(self, ui, repo, remote):
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 self.remote = remote.local()
Mads Kiilerich
largefiles: cleanup of warnings on errors getting largefiles...
r18155 super(localstore, self).__init__(ui, repo, self.remote.url())
various
hgext: add largefiles extension...
r15168
Benjamin Pollack
largefiles: make the store primary, and the user cache secondary...
r15317 def put(self, source, hash):
if lfutil.instore(self.remote, hash):
return
Mads Kiilerich
largefiles: 'put' should store 'source' file in under 'hash', also in localstore
r19007 lfutil.link(source, lfutil.storepath(self.remote, hash))
various
hgext: add largefiles extension...
r15168
Matt Harbison
largefiles: adjust localstore to handle batch statlfile requests (issue3583)...
r17411 def exists(self, hashes):
retval = {}
for hash in hashes:
retval[hash] = lfutil.instore(self.remote, hash)
return retval
various
hgext: add largefiles extension...
r15168
def _getfile(self, tmpfile, filename, hash):
Mads Kiilerich
largefiles: refactoring - use findfile in localstore._getfile
r19000 path = lfutil.findfile(self.remote, hash)
if not path:
Mads Kiilerich
largefiles: cleanup of warnings on errors getting largefiles...
r18155 raise basestore.StoreError(filename, hash, self.url,
Martin Geisler
largefiles: lowercase messages
r16928 _("can't get file locally"))
Benjamin Pollack
largefiles: make the store primary, and the user cache secondary...
r15317 fd = open(path, 'rb')
try:
return lfutil.copyandhash(fd, tmpfile)
finally:
fd.close()
various
hgext: add largefiles extension...
r15168
def _verifyfile(self, cctx, cset, contents, standin, verified):
filename = lfutil.splitstandin(standin)
if not filename:
return False
fctx = cctx[standin]
key = (filename, fctx.filenode())
if key in verified:
return False
expecthash = fctx.data()[0:40]
Mads Kiilerich
largefiles: report localstore errors with single line warnings messages...
r18545 storepath = lfutil.storepath(self.remote, expecthash)
various
hgext: add largefiles extension...
r15168 verified.add(key)
Benjamin Pollack
largefiles: make the store primary, and the user cache secondary...
r15317 if not lfutil.instore(self.remote, expecthash):
various
hgext: add largefiles extension...
r15168 self.ui.warn(
Mads Kiilerich
largefiles: report localstore errors with single line warnings messages...
r18545 _('changeset %s: %s references missing %s\n')
% (cset, filename, storepath))
various
hgext: add largefiles extension...
r15168 return True # failed
if contents:
actualhash = lfutil.hashfile(storepath)
if actualhash != expecthash:
self.ui.warn(
Mads Kiilerich
largefiles: report localstore errors with single line warnings messages...
r18545 _('changeset %s: %s references corrupted %s\n')
% (cset, filename, storepath))
various
hgext: add largefiles extension...
r15168 return True # failed
return False