comparison mercurial/localrepo.py @ 6586:d3463007d368

walk: return a single value
author Matt Mackall <mpm@selenic.com>
date Mon, 12 May 2008 11:37:08 -0500
parents d3d1d39da2fa
children a259e217bc0c
comparison
equal deleted inserted replaced
6585:d3d1d39da2fa 6586:d3463007d368
934 def walk(self, match, node=None): 934 def walk(self, match, node=None):
935 ''' 935 '''
936 walk recursively through the directory tree or a given 936 walk recursively through the directory tree or a given
937 changeset, finding all files matched by the match 937 changeset, finding all files matched by the match
938 function 938 function
939
940 results are yielded in a tuple (src, filename), where src
941 is one of:
942 'f' the file was found in the directory tree
943 'm' the file was only in the dirstate and not in the tree
944 ''' 939 '''
945 940
946 if node: 941 if node:
947 fdict = dict.fromkeys(match.files()) 942 fdict = dict.fromkeys(match.files())
948 # for dirstate.walk, files=['.'] means "walk the whole tree". 943 # for dirstate.walk, files=['.'] means "walk the whole tree".
956 # match if the file is the exact name or a directory 951 # match if the file is the exact name or a directory
957 if ffn == fn or fn.startswith("%s/" % ffn): 952 if ffn == fn or fn.startswith("%s/" % ffn):
958 del fdict[ffn] 953 del fdict[ffn]
959 break 954 break
960 if match(fn): 955 if match(fn):
961 yield 'm', fn 956 yield fn
962 ffiles = fdict.keys() 957 ffiles = fdict.keys()
963 ffiles.sort() 958 ffiles.sort()
964 for fn in ffiles: 959 for fn in ffiles:
965 if match.bad(fn, 'No such file in rev ' + short(node)) \ 960 if match.bad(fn, 'No such file in rev ' + short(node)) \
966 and match(fn): 961 and match(fn):
967 yield 'f', fn 962 yield fn
968 else: 963 else:
969 for src, fn in self.dirstate.walk(match): 964 for src, fn in self.dirstate.walk(match):
970 yield src, fn 965 yield fn
971 966
972 def status(self, node1=None, node2=None, files=[], match=util.always, 967 def status(self, node1=None, node2=None, files=[], match=util.always,
973 list_ignored=False, list_clean=False, list_unknown=True): 968 list_ignored=False, list_clean=False, list_unknown=True):
974 """return status of files between two nodes or node and working directory 969 """return status of files between two nodes or node and working directory
975 970