Patchwork committablectx: move __contains__ into workingctx

login
register
mail settings
Submitter Sean Farley
Date July 4, 2014, 4:15 a.m.
Message ID <80ba531b638149b08849.1404447313@laptop.local>
Download mbox | patch
Permalink /patch/5097/
State Accepted
Commit 04f5b5e3792e6bbdaf9b70aaf86db2649b2354aa
Headers show

Comments

Sean Farley - July 4, 2014, 4:15 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1404446497 18000
#      Thu Jul 03 23:01:37 2014 -0500
# Node ID 80ba531b638149b08849e499b12c1807d7640f7c
# Parent  13b258b21a9a2f2b37afc3f86f6d7d27b5128632
committablectx: move __contains__ into workingctx

This was mistakenly moved from workingctx to committablectx in
9d56a3359011. Since the method is querying the dirstate, the only logical place
is for it to reside is in workingctx.
Matt Mackall - July 7, 2014, 10:57 p.m.
On Thu, 2014-07-03 at 23:15 -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1404446497 18000
> #      Thu Jul 03 23:01:37 2014 -0500
> # Node ID 80ba531b638149b08849e499b12c1807d7640f7c
> # Parent  13b258b21a9a2f2b37afc3f86f6d7d27b5128632
> committablectx: move __contains__ into workingctx

Queued for default, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -974,13 +974,10 @@  class committablectx(basectx):
         return str(self._parents[0]) + "+"
 
     def __nonzero__(self):
         return True
 
-    def __contains__(self, key):
-        return self._repo.dirstate[key] not in "?r"
-
     def _buildflagfunc(self):
         # Create a fallback function for getting file flags when the
         # filesystem doesn't support them
 
         copiesget = self._repo.dirstate.copies().get
@@ -1177,10 +1174,13 @@  class workingctx(committablectx):
         d = self._repo.dirstate
         for f in d:
             if d[f] != 'r':
                 yield f
 
+    def __contains__(self, key):
+        return self._repo.dirstate[key] not in "?r"
+
     @propertycache
     def _parents(self):
         p = self._repo.dirstate.parents()
         if p[1] == nullid:
             p = p[:-1]