# HG changeset patch # User Benoit Boissinot # Date 1153855376 -7200 # Node ID 82864a2eb709b923632f8a4ac15af6c123a5ab5b # Parent 93eb49419760307b5a35de3900c544548878803e self.root == '/': prefix length computation out of the loop - put the computation out of the loop - change the variable to a more meaningful name diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -344,19 +344,19 @@ class dirstate(object): # directly by this function, but might be modified by your statmatch call. # def walkhelper(self, files, statmatch, dc, badmatch=None): + # self.root may end with a path separator when self.root == '/' + common_prefix_len = len(self.root) + if not self.root.endswith('/'): + common_prefix_len += 1 # recursion free walker, faster than os.walk. def findfiles(s): work = [s] - # self.root may end with a path separator when self.root == '/' - root_subtract_len = len(self.root) - if not self.root.endswith('/'): - root_subtract_len += 1 while work: top = work.pop() names = os.listdir(top) names.sort() # nd is the top of the repository dir tree - nd = util.normpath(top[root_subtract_len:]) + nd = util.normpath(top[common_prefix_len:]) if nd == '.': nd = '' else: