comparison mercurial/scmutil.py @ 16208:85db991780b7

merge with stable
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 02 Mar 2012 09:57:09 +0100
parents 336e61875335 8181bd808dc5
children 5cbfbb838198
comparison
equal deleted inserted replaced
16206:1970e6f61009 16208:85db991780b7
209 if self._audit: 209 if self._audit:
210 r = util.checkosfilename(path) 210 r = util.checkosfilename(path)
211 if r: 211 if r:
212 raise util.Abort("%s: %r" % (r, path)) 212 raise util.Abort("%s: %r" % (r, path))
213 self.auditor(path) 213 self.auditor(path)
214 f = os.path.join(self.base, path) 214 f = self.join(path)
215 215
216 if not text and "b" not in mode: 216 if not text and "b" not in mode:
217 mode += "b" # for that other OS 217 mode += "b" # for that other OS
218 218
219 nlink = -1 219 nlink = -1
253 self._fixfilemode(f) 253 self._fixfilemode(f)
254 return fp 254 return fp
255 255
256 def symlink(self, src, dst): 256 def symlink(self, src, dst):
257 self.auditor(dst) 257 self.auditor(dst)
258 linkname = os.path.join(self.base, dst) 258 linkname = self.join(dst)
259 try: 259 try:
260 os.unlink(linkname) 260 os.unlink(linkname)
261 except OSError: 261 except OSError:
262 pass 262 pass
263 263
277 f.close() 277 f.close()
278 self._fixfilemode(dst) 278 self._fixfilemode(dst)
279 279
280 def audit(self, path): 280 def audit(self, path):
281 self.auditor(path) 281 self.auditor(path)
282
283 def join(self, path):
284 return os.path.join(self.base, path)
282 285
283 class filteropener(abstractopener): 286 class filteropener(abstractopener):
284 '''Wrapper opener for filtering filenames with a function.''' 287 '''Wrapper opener for filtering filenames with a function.'''
285 288
286 def __init__(self, opener, filter): 289 def __init__(self, opener, filter):
802 Mercurial either atomic renames or appends for files under .hg, 805 Mercurial either atomic renames or appends for files under .hg,
803 so to ensure the cache is reliable we need the filesystem to be able 806 so to ensure the cache is reliable we need the filesystem to be able
804 to tell us if a file has been replaced. If it can't, we fallback to 807 to tell us if a file has been replaced. If it can't, we fallback to
805 recreating the object on every call (essentially the same behaviour as 808 recreating the object on every call (essentially the same behaviour as
806 propertycache).''' 809 propertycache).'''
807 def __init__(self, path, instore=False): 810 def __init__(self, path):
808 self.path = path 811 self.path = path
809 self.instore = instore 812
813 def join(self, obj, fname):
814 """Used to compute the runtime path of the cached file.
815
816 Users should subclass filecache and provide their own version of this
817 function to call the appropriate join function on 'obj' (an instance
818 of the class that its member function was decorated).
819 """
820 return obj.join(fname)
810 821
811 def __call__(self, func): 822 def __call__(self, func):
812 self.func = func 823 self.func = func
813 self.name = func.__name__ 824 self.name = func.__name__
814 return self 825 return self
822 833
823 if entry: 834 if entry:
824 if entry.changed(): 835 if entry.changed():
825 entry.obj = self.func(obj) 836 entry.obj = self.func(obj)
826 else: 837 else:
827 path = self.instore and obj.sjoin(self.path) or obj.join(self.path) 838 path = self.join(obj, self.path)
828 839
829 # We stat -before- creating the object so our cache doesn't lie if 840 # We stat -before- creating the object so our cache doesn't lie if
830 # a writer modified between the time we read and stat 841 # a writer modified between the time we read and stat
831 entry = filecacheentry(path) 842 entry = filecacheentry(path)
832 entry.obj = self.func(obj) 843 entry.obj = self.func(obj)