Mercurial > hg
comparison mercurial/posix.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 | 147576a4e6a2 |
children | a0ec05d93c8e |
comparison
equal
deleted
inserted
replaced
43505:47fac1692ede | 43506:9f70512ae2cf |
---|---|
30 error, | 30 error, |
31 policy, | 31 policy, |
32 pycompat, | 32 pycompat, |
33 ) | 33 ) |
34 | 34 |
35 osutil = policy.importmod(r'osutil') | 35 osutil = policy.importmod('osutil') |
36 | 36 |
37 normpath = os.path.normpath | 37 normpath = os.path.normpath |
38 samestat = os.path.samestat | 38 samestat = os.path.samestat |
39 try: | 39 try: |
40 oslink = os.link | 40 oslink = os.link |
58 umask = os.umask(0) | 58 umask = os.umask(0) |
59 os.umask(umask) | 59 os.umask(umask) |
60 | 60 |
61 if not pycompat.ispy3: | 61 if not pycompat.ispy3: |
62 | 62 |
63 def posixfile(name, mode=r'r', buffering=-1): | 63 def posixfile(name, mode='r', buffering=-1): |
64 fp = open(name, mode=mode, buffering=buffering) | 64 fp = open(name, mode=mode, buffering=buffering) |
65 # The position when opening in append mode is implementation defined, so | 65 # The position when opening in append mode is implementation defined, so |
66 # make it consistent by always seeking to the end. | 66 # make it consistent by always seeking to the end. |
67 if r'a' in mode: | 67 if 'a' in mode: |
68 fp.seek(0, os.SEEK_END) | 68 fp.seek(0, os.SEEK_END) |
69 return fp | 69 return fp |
70 | 70 |
71 | 71 |
72 else: | 72 else: |
464 s += c | 464 s += c |
465 | 465 |
466 u = s.decode('utf-8') | 466 u = s.decode('utf-8') |
467 | 467 |
468 # Decompose then lowercase (HFS+ technote specifies lower) | 468 # Decompose then lowercase (HFS+ technote specifies lower) |
469 enc = unicodedata.normalize(r'NFD', u).lower().encode('utf-8') | 469 enc = unicodedata.normalize('NFD', u).lower().encode('utf-8') |
470 # drop HFS+ ignored characters | 470 # drop HFS+ ignored characters |
471 return encoding.hfsignoreclean(enc) | 471 return encoding.hfsignoreclean(enc) |
472 | 472 |
473 | 473 |
474 if pycompat.sysplatform == b'cygwin': | 474 if pycompat.sysplatform == b'cygwin': |