mercurial/dirstate.py
changeset 2671 82864a2eb709
parent 2670 93eb49419760
child 2848 e78cad1f6b1f
equal deleted inserted replaced
2670:93eb49419760 2671:82864a2eb709
   342     #
   342     #
   343     # dc is an optional arg for the current dirstate.  dc is not modified
   343     # dc is an optional arg for the current dirstate.  dc is not modified
   344     # directly by this function, but might be modified by your statmatch call.
   344     # directly by this function, but might be modified by your statmatch call.
   345     #
   345     #
   346     def walkhelper(self, files, statmatch, dc, badmatch=None):
   346     def walkhelper(self, files, statmatch, dc, badmatch=None):
       
   347         # self.root may end with a path separator when self.root == '/'
       
   348         common_prefix_len = len(self.root)
       
   349         if not self.root.endswith('/'):
       
   350             common_prefix_len += 1
   347         # recursion free walker, faster than os.walk.
   351         # recursion free walker, faster than os.walk.
   348         def findfiles(s):
   352         def findfiles(s):
   349             work = [s]
   353             work = [s]
   350             # self.root may end with a path separator when self.root == '/'
       
   351             root_subtract_len = len(self.root)
       
   352             if not self.root.endswith('/'):
       
   353                 root_subtract_len += 1
       
   354             while work:
   354             while work:
   355                 top = work.pop()
   355                 top = work.pop()
   356                 names = os.listdir(top)
   356                 names = os.listdir(top)
   357                 names.sort()
   357                 names.sort()
   358                 # nd is the top of the repository dir tree
   358                 # nd is the top of the repository dir tree
   359                 nd = util.normpath(top[root_subtract_len:])
   359                 nd = util.normpath(top[common_prefix_len:])
   360                 if nd == '.':
   360                 if nd == '.':
   361                     nd = ''
   361                     nd = ''
   362                 else:
   362                 else:
   363                     # do not recurse into a repo contained in this
   363                     # do not recurse into a repo contained in this
   364                     # one. use bisect to find .hg directory so speed
   364                     # one. use bisect to find .hg directory so speed