Patchwork [1,of,2,RFC] completion: add a debugpathcomplete command

mail settings
Submitter Kevin Bullock
Date March 14, 2013, 4:53 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/1127/
State Superseded
Commit 10669e24eb6c664f13110cf6012e381778c730b3
Headers show


Bryan O'Sullivan - March 14, 2013, 5:37 p.m.
On Thu, Mar 14, 2013 at 9:53 AM, Kevin Bullock <> wrote:

> ...but I just tried to create a read-only proxy that gets you the unsorted
> map, and it's easy and functional.

Sure. But I don't want to add it. It's complex, slow, and defends us
against a problem we do not have.
Augie Fackler - March 14, 2013, 6:54 p.m.
On Mar 14, 2013, at 11:23 AM, Kevin Bullock <> wrote:

> Law of Demeter violations are something we need _less_ of in the codebase, not more. My naïve example is almost certainly not the right solution, but I still don't like pulling out a _marked private_ dict from inside an object just so that you can complete filenames faster.
> Could we just add an accessor to dirstate for the unsorted map keys?

+1 - I'm reaally unhappy with adding a demeter violation here.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -45,6 +45,17 @@  def _decdirs(dirs, path):
         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
+    def map(self):
+        return mapproxy(self._map)
+    @propertycache
     def _copymap(self):
         return self._copymap