D5253: remotefilelog: avoid accessing repo instance after dispatch

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Nov 9 21:17:38 EST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG157f0e29eaa3: remotefilelog: avoid accessing repo instance after dispatch (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5253?vs=12496&id=12500

REVISION DETAIL
  https://phab.mercurial-scm.org/D5253

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  tests/test-remotefilelog-share.t

CHANGE DETAILS

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
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 @@
 
     # 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



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list