Mercurial > hg
comparison mercurial/scmutil.py @ 14720:36283a7b6856 stable
opener: add self._audit (issue2862)
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Wed, 22 Jun 2011 10:13:44 +0200 |
parents | 785bbc8634f8 |
children | 72e4fcb43227 |
comparison
equal
deleted
inserted
replaced
14719:c19de7f32961 | 14720:36283a7b6856 |
---|---|
167 This class is used to hide the details of COW semantics and | 167 This class is used to hide the details of COW semantics and |
168 remote file access from higher level code. | 168 remote file access from higher level code. |
169 ''' | 169 ''' |
170 def __init__(self, base, audit=True): | 170 def __init__(self, base, audit=True): |
171 self.base = base | 171 self.base = base |
172 self._audit = audit | |
172 if audit: | 173 if audit: |
173 self.auditor = pathauditor(base) | 174 self.auditor = pathauditor(base) |
174 else: | 175 else: |
175 self.auditor = util.always | 176 self.auditor = util.always |
176 self.createmode = None | 177 self.createmode = None |
184 if self.createmode is None: | 185 if self.createmode is None: |
185 return | 186 return |
186 os.chmod(name, self.createmode & 0666) | 187 os.chmod(name, self.createmode & 0666) |
187 | 188 |
188 def __call__(self, path, mode="r", text=False, atomictemp=False): | 189 def __call__(self, path, mode="r", text=False, atomictemp=False): |
189 r = util.checkosfilename(path) | 190 if self._audit: |
190 if r: | 191 r = util.checkosfilename(path) |
191 raise util.Abort("%s: %r" % (r, path)) | 192 if r: |
193 raise util.Abort("%s: %r" % (r, path)) | |
192 self.auditor(path) | 194 self.auditor(path) |
193 f = os.path.join(self.base, path) | 195 f = os.path.join(self.base, path) |
194 | 196 |
195 if not text and "b" not in mode: | 197 if not text and "b" not in mode: |
196 mode += "b" # for that other OS | 198 mode += "b" # for that other OS |