# HG changeset patch # User Siddharth Agarwal # Date 1441256723 25200 # Node ID 51a30cae2bff1baf02abead8203d2a6439230a6f # Parent 242853e14804b7c4d6a9ef3d308cbe3782f6323a localrepo: move dirstate validate function to class scope This will allow the function to be referred to by subclasses, as required for upcoming patches. diff -r 242853e14804 -r 51a30cae2bff mercurial/localrepo.py --- 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: