From patchwork Thu Mar 14 16:53:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,2,RFC] completion: add a debugpathcomplete command From: Kevin Bullock X-Patchwork-Id: 1127 Message-Id: <9A8A264A-B1DB-4FA8-A3A1-E5928D1B5C8C@ringworld.org> To: "Bryan O'Sullivan" Cc: mercurial-devel@selenic.com Date: Thu, 14 Mar 2013 11:53:42 -0500 diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -45,6 +45,17 @@ def _decdirs(dirs, path): return del dirs[base] +class mapproxy(object): + def __init__(self, target): + self._map = target + def __getitem__(self, key): + return self._map.get(key, ("?",))[0] + def __contains__(self, key): + return key in self._map + def __iter__(self): + for x in self._map: + yield x + class dirstate(object): def __init__(self, opener, ui, root, validate): @@ -72,6 +83,10 @@ class dirstate(object): return self._map @propertycache + def map(self): + return mapproxy(self._map) + + @propertycache def _copymap(self): self._read() return self._copymap