comparison mercurial/store.py @ 17744:09d5b2055295

store: add a contains method to basicstore Adds a __contains__ method to basicstore that checks if a file/dir is present in the store
author smuralid
date Thu, 13 Sep 2012 17:00:34 -0700
parents b8424c92ba2b
children b9a56b816ff2
comparison
equal deleted inserted replaced
17743:6047947afb6b 17744:09d5b2055295
339 return ['requires'] + _data.split() 339 return ['requires'] + _data.split()
340 340
341 def write(self): 341 def write(self):
342 pass 342 pass
343 343
344 def __contains__(self, path):
345 '''Checks if the store contains path'''
346 path = "/".join(("data", path))
347 # file?
348 if os.path.exists(self.join(path + ".i")):
349 return True
350 # dir?
351 if not path.endswith("/"):
352 path = path + "/"
353 return os.path.exists(self.join(path))
354
344 class encodedstore(basicstore): 355 class encodedstore(basicstore):
345 def __init__(self, path, vfstype): 356 def __init__(self, path, vfstype):
346 vfs = vfstype(path + '/store') 357 vfs = vfstype(path + '/store')
347 self.path = vfs.base 358 self.path = vfs.base
348 self.createmode = _calcmode(vfs) 359 self.createmode = _calcmode(vfs)