Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 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 | 14c87708f432 |
children | a9454beb9dd8 |
comparison
equal
deleted
inserted
replaced
34925:8b95e420e248 | 34926:f7e4d6c20095 |
---|---|
469 return | 469 return |
470 if changeid == 'tip': | 470 if changeid == 'tip': |
471 self._node = repo.changelog.tip() | 471 self._node = repo.changelog.tip() |
472 self._rev = repo.changelog.rev(self._node) | 472 self._rev = repo.changelog.rev(self._node) |
473 return | 473 return |
474 if changeid == '.' or changeid == repo.dirstate.p1(): | 474 if (changeid == '.' |
475 or repo.local() and changeid == repo.dirstate.p1()): | |
475 # this is a hack to delay/avoid loading obsmarkers | 476 # this is a hack to delay/avoid loading obsmarkers |
476 # when we know that '.' won't be hidden | 477 # when we know that '.' won't be hidden |
477 self._node = repo.dirstate.p1() | 478 self._node = repo.dirstate.p1() |
478 self._rev = repo.unfiltered().changelog.rev(self._node) | 479 self._rev = repo.unfiltered().changelog.rev(self._node) |
479 return | 480 return |
534 # lookup failed | 535 # lookup failed |
535 # check if it might have come from damaged dirstate | 536 # check if it might have come from damaged dirstate |
536 # | 537 # |
537 # XXX we could avoid the unfiltered if we had a recognizable | 538 # XXX we could avoid the unfiltered if we had a recognizable |
538 # exception for filtered changeset access | 539 # exception for filtered changeset access |
539 if changeid in repo.unfiltered().dirstate.parents(): | 540 if (repo.local() |
541 and changeid in repo.unfiltered().dirstate.parents()): | |
540 msg = _("working directory has unknown parent '%s'!") | 542 msg = _("working directory has unknown parent '%s'!") |
541 raise error.Abort(msg % short(changeid)) | 543 raise error.Abort(msg % short(changeid)) |
542 try: | 544 try: |
543 if len(changeid) == 20 and nonascii(changeid): | 545 if len(changeid) == 20 and nonascii(changeid): |
544 changeid = hex(changeid) | 546 changeid = hex(changeid) |