##// END OF EJS Templates
revlog: fix revset in reachableroots docstring...
revlog: fix revset in reachableroots docstring `reachableroots` will only return a subset of `roots` when `includepath` is False. For example, given the following linear DAG: 2 | 1 | 0 Using roots=0+2, heads=1, the definition in the docstring does not match what `reachableroots` actually does: ipdb> repo.changelog.reachableroots(0, roots=[0,2],heads=[1]) [0] ipdb> repo.revs('heads(::(0+2) & (0+2)::1)') <baseset+ [1]> The fix is to do `heads & ::roots` (or `heads & heads::roots`) first, then select their ancestors: ipdb> repo.revs('heads(::((0+2) & (0+2)::1))') <baseset+ [0]> The docstring was introduced by fd92bfbbe02d9 (2015-06-19 "revset: rename revsbetween to reachableroots and add an argument"), which introduced the `includepath=False` behavior for graphlog grandparents use-case. I believe the docstring instead of the code should be changed because changing the code to match the docstring can result in suboptimal graphlog like: o :\ : o : : :/ o As opposite to the current "linearized" graphlog: o | o : o Differential Revision: https://phab.mercurial-scm.org/D7518

File last commit:

r43385:4aa72cdf default
r44218:2e30d7df default
Show More
connectionpool.py
88 lines | 2.4 KiB | text/x-python | PythonLexer
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 # connectionpool.py - class for pooling peer connections for reuse
#
# Copyright 2017 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from mercurial import (
extensions,
hg,
Gregory Szorc
py3: define and use pycompat.itervalues()...
r43374 pycompat,
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 sshpeer,
util,
)
_sshv1peer = sshpeer.sshv1peer
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 class connectionpool(object):
def __init__(self, repo):
self._repo = repo
self._pool = dict()
def get(self, path):
pathpool = self._pool.get(path)
if pathpool is None:
pathpool = list()
self._pool[path] = pathpool
conn = None
if len(pathpool) > 0:
try:
conn = pathpool.pop()
peer = conn.peer
# If the connection has died, drop it
if isinstance(peer, _sshv1peer):
if peer._subprocess.poll() is not None:
conn = None
except IndexError:
pass
if conn is None:
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 def _cleanup(orig):
# close pipee first so peer.cleanup reading it won't deadlock,
# if there are other processes with pipeo open (i.e. us).
peer = orig.im_self
Martin von Zweigbergk
py3: delete b'' prefix from safehasattr arguments...
r43385 if util.safehasattr(peer, 'pipee'):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 peer.pipee.close()
return orig()
peer = hg.peer(self._repo.ui, {}, path)
Martin von Zweigbergk
py3: delete b'' prefix from safehasattr arguments...
r43385 if util.safehasattr(peer, 'cleanup'):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 extensions.wrapfunction(peer, b'cleanup', _cleanup)
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530
conn = connection(pathpool, peer)
return conn
def close(self):
Gregory Szorc
py3: define and use pycompat.itervalues()...
r43374 for pathpool in pycompat.itervalues(self._pool):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 for conn in pathpool:
conn.close()
del pathpool[:]
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 class connection(object):
def __init__(self, pool, peer):
self._pool = pool
self.peer = peer
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
# Only add the connection back to the pool if there was no exception,
# since an exception could mean the connection is not in a reusable
# state.
if type is None:
self._pool.append(self)
else:
self.close()
def close(self):
Martin von Zweigbergk
py3: delete b'' prefix from safehasattr arguments...
r43385 if util.safehasattr(self.peer, 'cleanup'):
Augie Fackler
remotefilelog: import pruned-down remotefilelog extension from hg-experimental...
r40530 self.peer.cleanup()