[PATCH 1 of 2 RFC] completion: add a debugpathcomplete command
Kevin Bullock
kbullock+mercurial at ringworld.org
Thu Mar 14 11:53:42 CDT 2013
On 14 Mar 2013, at 11:35 AM, Bryan O'Sullivan wrote:
> On Thu, Mar 14, 2013 at 9:27 AM, Kevin Bullock <kbullock+mercurial at ringworld.org> wrote:
>> I figured you'd say that ;) Digging into the map directly is still ugly though.
>
> Agreed.
...but I just tried to create a read-only proxy that gets you the unsorted map, and it's easy and functional. Something like this, which is actually more than necessary for this user (please excuse my brain-damaged diff-corrupting MUA, you should be able to get the gist):
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
pacem in terris / мир / शान्ति / سَلاَم / 平和
Kevin R. Bullock
More information about the Mercurial-devel
mailing list