mirror of
https://github.com/facebook/sapling.git
synced 2025-01-06 04:43:19 +03:00
dispatch: move deferred to atexit handler
Summary: See D14606986 for context. `repo.close` should be protected by not crashing on stdout or stderr write errors (SIGPIPE or EPIPE). Move `deferred` to `atexit` handler to get the protection. Test changes are caused by ordering changes. Differential Revision: D14607407 fbshipit-source-id: 5a42aefcec395f48b8ecb67426429ef2e41f5666
This commit is contained in:
parent
7873db8242
commit
077313f1af
@ -1344,11 +1344,10 @@ def _dispatch(req):
|
||||
msg = _formatargs(fullargs)
|
||||
with perftrace.trace("hg " + msg):
|
||||
repo = None
|
||||
deferred = []
|
||||
if func.cmdtemplate:
|
||||
templ = cmdtemplatestate(ui, cmdoptions)
|
||||
args.insert(0, templ)
|
||||
deferred.append(lambda: templ.end())
|
||||
ui.atexit(templ.end)
|
||||
cmdpats = args[:]
|
||||
if not func.norepo:
|
||||
# use the repo from the request only if we don't have -R
|
||||
@ -1393,7 +1392,7 @@ def _dispatch(req):
|
||||
if options["hidden"]:
|
||||
repo = repo.unfiltered()
|
||||
if repo != req.repo:
|
||||
deferred.append(repo.close)
|
||||
ui.atexit(repo.close)
|
||||
args.insert(0, repo)
|
||||
elif rpath:
|
||||
ui.warn(_("warning: --repository ignored\n"))
|
||||
@ -1405,15 +1404,11 @@ def _dispatch(req):
|
||||
ui.log("command", "%s\n", msg)
|
||||
strcmdopt = pycompat.strkwargs(cmdoptions)
|
||||
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
|
||||
try:
|
||||
ret = runcommand(
|
||||
lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions
|
||||
)
|
||||
hintutil.show(lui)
|
||||
return ret
|
||||
finally:
|
||||
for func in deferred:
|
||||
func()
|
||||
ret = runcommand(
|
||||
lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions
|
||||
)
|
||||
hintutil.show(lui)
|
||||
return ret
|
||||
|
||||
|
||||
def _runcommand(ui, options, cmd, cmdfunc):
|
||||
|
@ -34,6 +34,6 @@ Verify error message when no fallback specified
|
||||
$ rm .hg/hgrc
|
||||
$ clearcache
|
||||
$ hg up tip
|
||||
3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over *s (glob)
|
||||
abort: no remotefilelog server configured - is your .hg/hgrc trusted?
|
||||
3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over *s (glob)
|
||||
[255]
|
||||
|
@ -235,8 +235,8 @@
|
||||
$ clearcache
|
||||
$ hg up tip
|
||||
x: untracked file differs
|
||||
3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob)
|
||||
abort: untracked files in working directory differ from files in requested revision
|
||||
3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob)
|
||||
[255]
|
||||
$ hg revert --all
|
||||
|
||||
@ -318,8 +318,8 @@
|
||||
forgetting y2
|
||||
adding z
|
||||
forgetting z3
|
||||
3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob)
|
||||
abort: z2@109c3a557a73: not found in manifest! (?)
|
||||
3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob)
|
||||
|
||||
# Test connection pool lifetime
|
||||
$ clearcache
|
||||
|
@ -148,19 +148,19 @@ The local data for n is still available
|
||||
|
||||
The history for n is lost
|
||||
$ hg log -qf n
|
||||
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
|
||||
abort: error downloading file contents:
|
||||
'connection closed early for filename n and node c972a0820002b32c6fec4b7ca47d3aecdad8e1c5'
|
||||
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
|
||||
[255]
|
||||
|
||||
The local data and history for o is lost
|
||||
$ hg cat -q o
|
||||
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
|
||||
abort: error downloading file contents:
|
||||
'connection closed early for filename o and node fd94f81d01bf8c9d960bb57abdd4e8375309ae43'
|
||||
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
|
||||
[255]
|
||||
$ hg log -qf o
|
||||
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
|
||||
abort: error downloading file contents:
|
||||
'connection closed early for filename o and node fd94f81d01bf8c9d960bb57abdd4e8375309ae43'
|
||||
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
|
||||
[255]
|
||||
|
Loading…
Reference in New Issue
Block a user