comparison mercurial/pathutil.py @ 47944:e02f9af7aed1

pathutil: replace the `skip` argument of `dirs` with a boolean It is ever only used for `r` file. So we make it a boolean this will give use more versatility later as we will stop storing the state explicitly. Differential Revision: https://phab.mercurial-scm.org/D11383
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 30 Aug 2021 18:45:54 +0200
parents a9f38b144096
children 35f1ecd84bd0
comparison
equal deleted inserted replaced
47943:fea24454f919 47944:e02f9af7aed1
313 313
314 314
315 class dirs(object): 315 class dirs(object):
316 '''a multiset of directory names from a set of file paths''' 316 '''a multiset of directory names from a set of file paths'''
317 317
318 def __init__(self, map, skip=None): 318 def __init__(self, map, only_tracked=False):
319 """ 319 """
320 a dict map indicates a dirstate while a list indicates a manifest 320 a dict map indicates a dirstate while a list indicates a manifest
321 """ 321 """
322 self._dirs = {} 322 self._dirs = {}
323 addpath = self.addpath 323 addpath = self.addpath
324 if isinstance(map, dict) and skip is not None: 324 if isinstance(map, dict) and only_tracked:
325 for f, s in pycompat.iteritems(map): 325 for f, s in pycompat.iteritems(map):
326 if s.state != skip: 326 if s.state != b'r':
327 addpath(f) 327 addpath(f)
328 elif skip is not None: 328 elif only_tracked:
329 raise error.ProgrammingError( 329 msg = b"`only_tracked` is only supported with a dict source"
330 b"skip character is only supported with a dict source" 330 raise error.ProgrammingError(msg)
331 )
332 else: 331 else:
333 for f in map: 332 for f in map:
334 addpath(f) 333 addpath(f)
335 334
336 def addpath(self, path): 335 def addpath(self, path):