Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 43506:9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
This is the promised second step on single-quoted strings. These had
existed because our source transformer didn't turn r'' into b'', so we
had tagged some strings as r-strings to get "native" strings on both
Pythons. Now that the transformer is gone, we can dispense with this
nonsense.
Methodology:
I ran
hg locate 'set:added() or modified() or clean()' | egrep '.*\.py$' | xargs egrep --color=never -n -- \[\^b\]\[\^a-z\]r\'\[\^\'\\\\\]\*\'\[\^\'\
in an emacs grep-mode buffer, and then used a keyboard macro to
iterate over the results and remove the r prefix as needed.
# skip-blame removing unneeded r prefixes left over from Python 3 migration.
Differential Revision: https://phab.mercurial-scm.org/D7306
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 08 Nov 2019 11:19:20 -0800 |
parents | be384a2052aa |
children | 7f489b9a79a1 |
comparison
equal
deleted
inserted
replaced
43505:47fac1692ede | 43506:9f70512ae2cf |
---|---|
2457 filtered = self.filtered(filt) | 2457 filtered = self.filtered(filt) |
2458 filtered.branchmap().write(filtered) | 2458 filtered.branchmap().write(filtered) |
2459 | 2459 |
2460 def invalidatecaches(self): | 2460 def invalidatecaches(self): |
2461 | 2461 |
2462 if r'_tagscache' in vars(self): | 2462 if '_tagscache' in vars(self): |
2463 # can't use delattr on proxy | 2463 # can't use delattr on proxy |
2464 del self.__dict__[r'_tagscache'] | 2464 del self.__dict__['_tagscache'] |
2465 | 2465 |
2466 self._branchcaches.clear() | 2466 self._branchcaches.clear() |
2467 self.invalidatevolatilesets() | 2467 self.invalidatevolatilesets() |
2468 self._sparsesignaturecache.clear() | 2468 self._sparsesignaturecache.clear() |
2469 | 2469 |
2478 | 2478 |
2479 This is different to dirstate.invalidate() that it doesn't always | 2479 This is different to dirstate.invalidate() that it doesn't always |
2480 rereads the dirstate. Use dirstate.invalidate() if you want to | 2480 rereads the dirstate. Use dirstate.invalidate() if you want to |
2481 explicitly read the dirstate again (i.e. restoring it to a previous | 2481 explicitly read the dirstate again (i.e. restoring it to a previous |
2482 known good state).''' | 2482 known good state).''' |
2483 if hasunfilteredcache(self, r'dirstate'): | 2483 if hasunfilteredcache(self, 'dirstate'): |
2484 for k in self.dirstate._filecache: | 2484 for k in self.dirstate._filecache: |
2485 try: | 2485 try: |
2486 delattr(self.dirstate, k) | 2486 delattr(self.dirstate, k) |
2487 except AttributeError: | 2487 except AttributeError: |
2488 pass | 2488 pass |
2489 delattr(self.unfiltered(), r'dirstate') | 2489 delattr(self.unfiltered(), 'dirstate') |
2490 | 2490 |
2491 def invalidate(self, clearfilecache=False): | 2491 def invalidate(self, clearfilecache=False): |
2492 '''Invalidates both store and non-store parts other than dirstate | 2492 '''Invalidates both store and non-store parts other than dirstate |
2493 | 2493 |
2494 If a transaction is running, invalidation of store is omitted, | 2494 If a transaction is running, invalidation of store is omitted, |
2534 @unfilteredmethod | 2534 @unfilteredmethod |
2535 def _refreshfilecachestats(self, tr): | 2535 def _refreshfilecachestats(self, tr): |
2536 """Reload stats of cached files so that they are flagged as valid""" | 2536 """Reload stats of cached files so that they are flagged as valid""" |
2537 for k, ce in self._filecache.items(): | 2537 for k, ce in self._filecache.items(): |
2538 k = pycompat.sysstr(k) | 2538 k = pycompat.sysstr(k) |
2539 if k == r'dirstate' or k not in self.__dict__: | 2539 if k == 'dirstate' or k not in self.__dict__: |
2540 continue | 2540 continue |
2541 ce.refresh() | 2541 ce.refresh() |
2542 | 2542 |
2543 def _lock( | 2543 def _lock( |
2544 self, | 2544 self, |
3361 tr = self.currenttransaction() | 3361 tr = self.currenttransaction() |
3362 hookargs = {} | 3362 hookargs = {} |
3363 if tr is not None: | 3363 if tr is not None: |
3364 hookargs.update(tr.hookargs) | 3364 hookargs.update(tr.hookargs) |
3365 hookargs = pycompat.strkwargs(hookargs) | 3365 hookargs = pycompat.strkwargs(hookargs) |
3366 hookargs[r'namespace'] = namespace | 3366 hookargs['namespace'] = namespace |
3367 hookargs[r'key'] = key | 3367 hookargs['key'] = key |
3368 hookargs[r'old'] = old | 3368 hookargs['old'] = old |
3369 hookargs[r'new'] = new | 3369 hookargs['new'] = new |
3370 self.hook(b'prepushkey', throw=True, **hookargs) | 3370 self.hook(b'prepushkey', throw=True, **hookargs) |
3371 except error.HookAbort as exc: | 3371 except error.HookAbort as exc: |
3372 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc) | 3372 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc) |
3373 if exc.hint: | 3373 if exc.hint: |
3374 self.ui.write_err(_(b"(%s)\n") % exc.hint) | 3374 self.ui.write_err(_(b"(%s)\n") % exc.hint) |
3704 # | 3704 # |
3705 # But we have to allow the close() method because some constructors | 3705 # But we have to allow the close() method because some constructors |
3706 # of repos call close() on repo references. | 3706 # of repos call close() on repo references. |
3707 class poisonedrepository(object): | 3707 class poisonedrepository(object): |
3708 def __getattribute__(self, item): | 3708 def __getattribute__(self, item): |
3709 if item == r'close': | 3709 if item == 'close': |
3710 return object.__getattribute__(self, item) | 3710 return object.__getattribute__(self, item) |
3711 | 3711 |
3712 raise error.ProgrammingError( | 3712 raise error.ProgrammingError( |
3713 b'repo instances should not be used after unshare' | 3713 b'repo instances should not be used after unshare' |
3714 ) | 3714 ) |
3716 def close(self): | 3716 def close(self): |
3717 pass | 3717 pass |
3718 | 3718 |
3719 # We may have a repoview, which intercepts __setattr__. So be sure | 3719 # We may have a repoview, which intercepts __setattr__. So be sure |
3720 # we operate at the lowest level possible. | 3720 # we operate at the lowest level possible. |
3721 object.__setattr__(repo, r'__class__', poisonedrepository) | 3721 object.__setattr__(repo, '__class__', poisonedrepository) |