localrepo: move dirstate validate function to class scope
This will allow the function to be referred to by subclasses, as required for
upcoming patches.
--- a/mercurial/localrepo.py Thu Sep 03 10:29:42 2015 -0700
+++ b/mercurial/localrepo.py Wed Sep 02 22:05:23 2015 -0700
@@ -300,6 +300,7 @@
if create:
self._writerequirements()
+ self._dirstatevalidatewarned = False
self._branchcaches = {}
self._revbranchcache = None
@@ -473,19 +474,19 @@
@repofilecache('dirstate')
def dirstate(self):
- warned = [0]
- def validate(node):
- try:
- self.changelog.rev(node)
- return node
- except error.LookupError:
- if not warned[0]:
- warned[0] = True
- self.ui.warn(_("warning: ignoring unknown"
- " working parent %s!\n") % short(node))
- return nullid
+ return dirstate.dirstate(self.vfs, self.ui, self.root,
+ self._dirstatevalidate)
- return dirstate.dirstate(self.vfs, self.ui, self.root, validate)
+ def _dirstatevalidate(self, node):
+ try:
+ self.changelog.rev(node)
+ return node
+ except error.LookupError:
+ if not self._dirstatevalidatewarned:
+ self._dirstatevalidatewarned = True
+ self.ui.warn(_("warning: ignoring unknown"
+ " working parent %s!\n") % short(node))
+ return nullid
def __getitem__(self, changeid):
if changeid is None or changeid == wdirrev: