# HG changeset patch # User Yuya Nishihara # Date 2017-10-25 12:58:03 # Node ID f7e4d6c20095d67857c912bd44bb45073ced6f2f # Parent 8b95e420e24838a51d3ee26f1d34b6278989400d statichttprepo: prevent loading dirstate over HTTP on node lookup (issue5717) This seems a bit hacky, but works well. There should be no reason that static-http repo had to load dirstate. Initially I tried to proxy os.stat() call through vfs so that statichttpvfs could hook it, but there wasn't a good error value which the statichttpvfs could return to get around the util.filestat issue. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -471,7 +471,8 @@ class changectx(basectx): self._node = repo.changelog.tip() self._rev = repo.changelog.rev(self._node) return - if changeid == '.' or changeid == repo.dirstate.p1(): + if (changeid == '.' + or repo.local() and changeid == repo.dirstate.p1()): # this is a hack to delay/avoid loading obsmarkers # when we know that '.' won't be hidden self._node = repo.dirstate.p1() @@ -536,7 +537,8 @@ class changectx(basectx): # # XXX we could avoid the unfiltered if we had a recognizable # exception for filtered changeset access - if changeid in repo.unfiltered().dirstate.parents(): + if (repo.local() + and changeid in repo.unfiltered().dirstate.parents()): msg = _("working directory has unknown parent '%s'!") raise error.Abort(msg % short(changeid)) try: diff --git a/tests/test-static-http.t b/tests/test-static-http.t --- a/tests/test-static-http.t +++ b/tests/test-static-http.t @@ -222,7 +222,6 @@ List of files accessed over HTTP: /.hg/bookmarks /.hg/bookmarks.current /.hg/cache/hgtagsfnodes1 - /.hg/dirstate /.hg/requires /.hg/store/00changelog.i /.hg/store/00manifest.i @@ -236,7 +235,6 @@ List of files accessed over HTTP: /remote-with-names/.hg/cache/branch2-served /remote-with-names/.hg/cache/hgtagsfnodes1 /remote-with-names/.hg/cache/tags2-served - /remote-with-names/.hg/dirstate /remote-with-names/.hg/localtags /remote-with-names/.hg/requires /remote-with-names/.hg/store/00changelog.i @@ -251,7 +249,6 @@ List of files accessed over HTTP: /remote/.hg/cache/hgtagsfnodes1 /remote/.hg/cache/rbc-names-v1 /remote/.hg/cache/tags2-served - /remote/.hg/dirstate /remote/.hg/localtags /remote/.hg/requires /remote/.hg/store/00changelog.i @@ -268,7 +265,6 @@ List of files accessed over HTTP: /sub/.hg/bookmarks /sub/.hg/bookmarks.current /sub/.hg/cache/hgtagsfnodes1 - /sub/.hg/dirstate /sub/.hg/requires /sub/.hg/store/00changelog.i /sub/.hg/store/00manifest.i