mercurial/dirstate.py
changeset 5002 4d079df2871a
parent 5001 62e3fd2baca4
child 5003 4b1acb3ecb3c
equal deleted inserted replaced
5001:62e3fd2baca4 5002:4d079df2871a
   377         known = {'.hg': 1}
   377         known = {'.hg': 1}
   378 
   378 
   379         # recursion free walker, faster than os.walk.
   379         # recursion free walker, faster than os.walk.
   380         def findfiles(s):
   380         def findfiles(s):
   381             work = [s]
   381             work = [s]
       
   382             wadd = work.append
       
   383             found = []
       
   384             add = found.append
   382             if directories:
   385             if directories:
   383                 yield 'd', normpath(s[common_prefix_len:]), lstat(s)
   386                 add((normpath(s[common_prefix_len:]), 'd', lstat(s)))
   384             while work:
   387             while work:
   385                 top = work.pop()
   388                 top = work.pop()
   386                 names = listdir(top)
   389                 names = listdir(top)
   387                 names.sort()
   390                 names.sort()
   388                 # nd is the top of the repository dir tree
   391                 # nd is the top of the repository dir tree
   405                     p = join(top, f)
   408                     p = join(top, f)
   406                     # don't trip over symlinks
   409                     # don't trip over symlinks
   407                     st = lstat(p)
   410                     st = lstat(p)
   408                     if s_isdir(st.st_mode):
   411                     if s_isdir(st.st_mode):
   409                         if not ignore(np):
   412                         if not ignore(np):
   410                             work.append(p)
   413                             wadd(p)
   411                             if directories:
   414                             if directories:
   412                                 yield 'd', np, st
   415                                 add((np, 'd', st))
   413                         if np in dc and match(np):
   416                         if np in dc and match(np):
   414                             yield 'm', np, st
   417                             add((np, 'm', st))
   415                     elif imatch(np):
   418                     elif imatch(np):
   416                         if supported(np, st.st_mode):
   419                         if supported(np, st.st_mode):
   417                             yield 'f', np, st
   420                             add((np, 'f', st))
   418                         elif np in dc:
   421                         elif np in dc:
   419                             yield 'm', np, st
   422                             add((np, 'm', st))
       
   423             found.sort()
       
   424             return found
   420 
   425 
   421         # step one, find all files that match our criteria
   426         # step one, find all files that match our criteria
   422         files.sort()
   427         files.sort()
   423         for ff in files:
   428         for ff in files:
   424             nf = normpath(ff)
   429             nf = normpath(ff)
   437                                       (self.pathto(ff), inst.strerror))
   442                                       (self.pathto(ff), inst.strerror))
   438                     elif badmatch and badmatch(ff) and imatch(nf):
   443                     elif badmatch and badmatch(ff) and imatch(nf):
   439                         yield 'b', ff, None
   444                         yield 'b', ff, None
   440                 continue
   445                 continue
   441             if s_isdir(st.st_mode):
   446             if s_isdir(st.st_mode):
   442                 cmp1 = (lambda x, y: cmp(x[1], y[1]))
   447                 for f, src, st in findfiles(f):
   443                 sorted_ = [ x for x in findfiles(f) ]
   448                     yield src, f, st
   444                 sorted_.sort(cmp1)
       
   445                 for e in sorted_:
       
   446                     yield e
       
   447             else:
   449             else:
   448                 if nf in known:
   450                 if nf in known:
   449                     continue
   451                     continue
   450                 known[nf] = 1
   452                 known[nf] = 1
   451                 if match(nf):
   453                 if match(nf):