Mercurial > hg
comparison mercurial/lock.py @ 35897:4b1c04082cdc
py3: replace "if ispy3" by encoding.strtolocal()
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 27 Jan 2018 13:09:49 +0900 |
parents | 9153871d50e0 |
children | c303eda316be |
comparison
equal
deleted
inserted
replaced
35896:ed3a7300b7b5 | 35897:4b1c04082cdc |
---|---|
28 | 28 |
29 It's useful to detect "dead" processes and remove stale locks with | 29 It's useful to detect "dead" processes and remove stale locks with |
30 confidence. Typically it's just hostname. On modern linux, we include an | 30 confidence. Typically it's just hostname. On modern linux, we include an |
31 extra Linux-specific pid namespace identifier. | 31 extra Linux-specific pid namespace identifier. |
32 """ | 32 """ |
33 result = socket.gethostname() | 33 result = encoding.strtolocal(socket.gethostname()) |
34 if pycompat.ispy3: | |
35 result = result.encode(pycompat.sysstr(encoding.encoding), 'replace') | |
36 if pycompat.sysplatform.startswith('linux'): | 34 if pycompat.sysplatform.startswith('linux'): |
37 try: | 35 try: |
38 result += '/%x' % os.stat('/proc/self/ns/pid').st_ino | 36 result += '/%x' % os.stat('/proc/self/ns/pid').st_ino |
39 except OSError as ex: | 37 except OSError as ex: |
40 if ex.errno not in (errno.ENOENT, errno.EACCES, errno.ENOTDIR): | 38 if ex.errno not in (errno.ENOENT, errno.EACCES, errno.ENOTDIR): |