# HG changeset patch # User Martin von Zweigbergk # Date 2018-11-09 18:47:24 # Node ID 157f0e29eaa35adc2488709f5c00f2865a4d5361 # Parent 85bf93def0650ffaf1672b7fb21d9cff991bcffa remotefilelog: avoid accessing repo instance after dispatch Upstream commit c5e6c1ba1c79 (hg: don't reuse repo instance after unshare(), 2018-09-12) poisoned the repo instance after unshare(). That made `hg unshare` fail with remotefilelog because we tried to close the fileserverclient after dispatch by accessing it via the repo. This patch fixes that by storing the reference to the fileserverclient at the beginning of dispatch. An analogous patch was sent for remotefilelog version in FB's hg-experimental as D5246. Differential Revision: https://phab.mercurial-scm.org/D5253 diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py --- a/hgext/remotefilelog/__init__.py +++ b/hgext/remotefilelog/__init__.py @@ -542,14 +542,17 @@ def onetimeclientsetup(ui): # close cache miss server connection after the command has finished def runcommand(orig, lui, repo, *args, **kwargs): + fileservice = None + # repo can be None when running in chg: + # - at startup, reposetup was called because serve is not norepo + # - a norepo command like "help" is called + if repo and isenabled(repo): + fileservice = repo.fileservice try: return orig(lui, repo, *args, **kwargs) finally: - # repo can be None when running in chg: - # - at startup, reposetup was called because serve is not norepo - # - a norepo command like "help" is called - if repo and isenabled(repo): - repo.fileservice.close() + if fileservice: + fileservice.close() extensions.wrapfunction(dispatch, 'runcommand', runcommand) # disappointing hacks below diff --git a/tests/test-remotefilelog-share.t b/tests/test-remotefilelog-share.t --- a/tests/test-remotefilelog-share.t +++ b/tests/test-remotefilelog-share.t @@ -22,3 +22,4 @@ $ hg share source dest updating working directory 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg -R dest unshare