Mercurial > hg
changeset 34926:f7e4d6c20095 stable
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 25 Oct 2017 21:58:03 +0900 |
parents | 8b95e420e248 |
children | c2695cbb5fb1 |
files | mercurial/context.py tests/test-static-http.t |
diffstat | 2 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Wed Oct 25 21:21:42 2017 +0900 +++ b/mercurial/context.py Wed Oct 25 21:58:03 2017 +0900 @@ -471,7 +471,8 @@ 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 @@ # # 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:
--- a/tests/test-static-http.t Wed Oct 25 21:21:42 2017 +0900 +++ b/tests/test-static-http.t Wed Oct 25 21:58:03 2017 +0900 @@ -222,7 +222,6 @@ /.hg/bookmarks /.hg/bookmarks.current /.hg/cache/hgtagsfnodes1 - /.hg/dirstate /.hg/requires /.hg/store/00changelog.i /.hg/store/00manifest.i @@ -236,7 +235,6 @@ /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 @@ /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 @@ /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