##// END OF EJS Templates
mq: fix corner cases for handling of patch 0 in qselect...
mq: fix corner cases for handling of patch 0 in qselect Most of the code paths in mq would always pass patch specifications as a string. Patches can be specified by their index, but one code path passed that (through pop) to lookup as an integer - all other code paths used a string. Unfortunately pop and lookup (like many other parts of mq) used the boolean value of the patch specification to see if it was None, and they would thus incorrectly handle patch 0 as None. This patch makes the code comply with the actual internal duck typing of patch specifications: patch indices must be encoded as strings. The (now) unused code for partial and thus incorrect handling of indices as integers is removed.

File last commit:

r15252:6e809bb4 default
r15256:8caf7a75 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