Mercurial > public > mercurial-scm > hg-stable
diff mercurial/subrepo.py @ 46702:a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
I recommend looking at this with a diff that ignores indentation.
The test changes are because localrepo.close() updates some cache,
which appears happens earlier now on rollbacks or strips or something.
The http changes are because httppeer.close() prints stats with
--verbose.
Differential Revision: https://phab.mercurial-scm.org/D9999
author | Valentin Gatien-Baron <valentin.gatienbaron@gmail.com> |
---|---|
date | Mon, 15 Feb 2021 14:48:36 -0500 |
parents | 59fa3890d40a |
children | e2f7b2695ba1 |
line wrap: on
line diff
--- a/mercurial/subrepo.py Mon Feb 15 14:40:17 2021 -0500 +++ b/mercurial/subrepo.py Mon Feb 15 14:48:36 2021 -0500 @@ -716,13 +716,17 @@ _(b'sharing subrepo %s from %s\n') % (subrelpath(self), srcurl) ) - shared = hg.share( - self._repo._subparent.baseui, - getpeer(), - self._repo.root, - update=False, - bookmarks=False, - ) + peer = getpeer() + try: + shared = hg.share( + self._repo._subparent.baseui, + peer, + self._repo.root, + update=False, + bookmarks=False, + ) + finally: + peer.close() self._repo = shared.local() else: # TODO: find a common place for this and this code in the @@ -743,14 +747,18 @@ _(b'cloning subrepo %s from %s\n') % (subrelpath(self), util.hidepassword(srcurl)) ) - other, cloned = hg.clone( - self._repo._subparent.baseui, - {}, - getpeer(), - self._repo.root, - update=False, - shareopts=shareopts, - ) + peer = getpeer() + try: + other, cloned = hg.clone( + self._repo._subparent.baseui, + {}, + peer, + self._repo.root, + update=False, + shareopts=shareopts, + ) + finally: + peer.close() self._repo = cloned.local() self._initrepo(parentrepo, source, create=True) self._cachestorehash(srcurl) @@ -760,7 +768,11 @@ % (subrelpath(self), util.hidepassword(srcurl)) ) cleansub = self.storeclean(srcurl) - exchange.pull(self._repo, getpeer()) + peer = getpeer() + try: + exchange.pull(self._repo, peer) + finally: + peer.close() if cleansub: # keep the repo clean after pull self._cachestorehash(srcurl) @@ -845,7 +857,10 @@ % (subrelpath(self), util.hidepassword(dsturl)) ) other = hg.peer(self._repo, {b'ssh': ssh}, dsturl) - res = exchange.push(self._repo, other, force, newbranch=newbranch) + try: + res = exchange.push(self._repo, other, force, newbranch=newbranch) + finally: + other.close() # the repo is now clean self._cachestorehash(dsturl)