Mercurial > hg
comparison mercurial/util.py @ 42641:b5092c23ca35 stable
py: error out if a "skip" character was given with non-dict to util.dirs()
util.dirs() keeps track of the directories in its input collection. If
a "skip" character is given to it, it will assume the input is a
dirstate map and it will skip entries that are in the given "skip"
state. I think this is used only for skipping removed entries ("r") in
the dirtate. The C implementation of util.dirs() errors out if it was
given a skip character and a non-dict was passed. The pure
implementation simply ignored the request skip state. Let's make it
easier to discover bugs here by erroring out in the pure
implementation too. Let's also switch to checking for the dict-ness,
to make the C implementation (since that's clearly been sufficient for
many years). This last change makes test-issue660.t pass on py3 in
pure mode, since the old check was for existence of iteritems(), which
doesn't exist on py3.
Differential Revision: https://phab.mercurial-scm.org/D6669
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sun, 21 Jul 2019 18:04:05 -0700 |
parents | 2db96bf84a8f |
children | e94c8f584ee2 |
comparison
equal
deleted
inserted
replaced
42640:06ee841697a8 | 42641:b5092c23ca35 |
---|---|
3171 '''a multiset of directory names from a dirstate or manifest''' | 3171 '''a multiset of directory names from a dirstate or manifest''' |
3172 | 3172 |
3173 def __init__(self, map, skip=None): | 3173 def __init__(self, map, skip=None): |
3174 self._dirs = {} | 3174 self._dirs = {} |
3175 addpath = self.addpath | 3175 addpath = self.addpath |
3176 if safehasattr(map, 'iteritems') and skip is not None: | 3176 if isinstance(map, dict) and skip is not None: |
3177 for f, s in map.iteritems(): | 3177 for f, s in map.iteritems(): |
3178 if s[0] != skip: | 3178 if s[0] != skip: |
3179 addpath(f) | 3179 addpath(f) |
3180 elif skip is not None: | |
3181 raise error.ProgrammingError("skip character is only supported " | |
3182 "with a dict source") | |
3180 else: | 3183 else: |
3181 for f in map: | 3184 for f in map: |
3182 addpath(f) | 3185 addpath(f) |
3183 | 3186 |
3184 def addpath(self, path): | 3187 def addpath(self, path): |