##// END OF EJS Templates
mq: cleanup of lookup - handling of None is not relevant...
mq: cleanup of lookup - handling of None is not relevant Patch specifications in mq is passed around as a string or None. None is generally used when no patch has been specified and there thus is nothing to lookup and the calling code should do something else. One code path did however pass None all the way to lookup. That case was handled in lookup, but there was really need for that, it was undocumented, and it used to cause trouble back when patches was specified as integers.

File last commit:

r15252:6e809bb4 default
r15257:a8555f99 default
Show More
localstore.py
71 lines | 2.5 KiB | text/x-python | PythonLexer
# 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.
'''store class for local filesystem'''
import os
from mercurial import util
from mercurial.i18n import _
import lfutil
import basestore
class localstore(basestore.basestore):
'''Because there is a system-wide cache, the local store always
uses that cache. Since the cache is updated elsewhere, we can
just read from it here as if it were the store.'''
def __init__(self, ui, repo, remote):
url = os.path.join(remote.path, '.hg', lfutil.longname)
super(localstore, self).__init__(ui, repo, util.expandpath(url))
def put(self, source, filename, hash):
'''Any file that is put must already be in the system-wide
cache so do nothing.'''
return
def exists(self, hash):
return lfutil.insystemcache(self.repo.ui, hash)
def _getfile(self, tmpfile, filename, hash):
if lfutil.insystemcache(self.ui, hash):
return lfutil.systemcachepath(self.ui, hash)
raise basestore.StoreError(filename, hash, '',
_("Can't get file locally"))
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]
verified.add(key)
if not lfutil.insystemcache(self.ui, expecthash):
self.ui.warn(
_('changeset %s: %s missing\n'
' (looked for hash %s)\n')
% (cset, filename, expecthash))
return True # failed
if contents:
storepath = lfutil.systemcachepath(self.ui, expecthash)
actualhash = lfutil.hashfile(storepath)
if actualhash != expecthash:
self.ui.warn(
_('changeset %s: %s: contents differ\n'
' (%s:\n'
' expected hash %s,\n'
' but got %s)\n')
% (cset, filename, storepath, expecthash, actualhash))
return True # failed
return False