Mercurial > public > mercurial-scm > hg
comparison mercurial/server.py @ 52378:e1f0125bb8c6
server: stop using the `pycompat.open()` shim
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 04 Dec 2024 22:11:31 -0500 |
parents | f4733654f144 |
children | 72d461cbd1f3 |
comparison
equal
deleted
inserted
replaced
52377:ef83646d5f7d | 52378:e1f0125bb8c6 |
---|---|
8 from __future__ import annotations | 8 from __future__ import annotations |
9 | 9 |
10 import os | 10 import os |
11 | 11 |
12 from .i18n import _ | 12 from .i18n import _ |
13 from .pycompat import open | |
14 | 13 |
15 from . import ( | 14 from . import ( |
16 chgserver, | 15 chgserver, |
17 cmdutil, | 16 cmdutil, |
18 commandserver, | 17 commandserver, |
74 os.close(fd) | 73 os.close(fd) |
75 | 74 |
76 def writepid(pid): | 75 def writepid(pid): |
77 if opts[b'pid_file']: | 76 if opts[b'pid_file']: |
78 if appendpid: | 77 if appendpid: |
79 mode = b'ab' | 78 mode = 'ab' |
80 else: | 79 else: |
81 mode = b'wb' | 80 mode = 'wb' |
82 fp = open(opts[b'pid_file'], mode) | 81 fp = open(opts[b'pid_file'], mode) |
83 fp.write(b'%d\n' % pid) | 82 fp.write(b'%d\n' % pid) |
84 fp.close() | 83 fp.close() |
85 | 84 |
86 if opts[b'daemon'] and not opts[b'daemon_postexec']: | 85 if opts[b'daemon'] and not opts[b'daemon_postexec']: |
107 pid = procutil.rundetached(runargs, condfn) | 106 pid = procutil.rundetached(runargs, condfn) |
108 if pid < 0: | 107 if pid < 0: |
109 # If the daemonized process managed to write out an error msg, | 108 # If the daemonized process managed to write out an error msg, |
110 # report it. | 109 # report it. |
111 if pycompat.iswindows and os.path.exists(lockpath): | 110 if pycompat.iswindows and os.path.exists(lockpath): |
112 with open(lockpath, b'rb') as log: | 111 with open(lockpath, 'rb') as log: |
113 for line in log: | 112 for line in log: |
114 procutil.stderr.write(line) | 113 procutil.stderr.write(line) |
115 raise error.Abort(_(b'child process failed to start')) | 114 raise error.Abort(_(b'child process failed to start')) |
116 writepid(pid) | 115 writepid(pid) |
117 finally: | 116 finally: |