equal
deleted
inserted
replaced
33 Exclude the .hg directory, any nested repos, and ignored dirs.''' |
33 Exclude the .hg directory, any nested repos, and ignored dirs.''' |
34 rootslash = repo.root + os.sep |
34 rootslash = repo.root + os.sep |
35 |
35 |
36 def walkit(dirname, top): |
36 def walkit(dirname, top): |
37 fullpath = rootslash + dirname |
37 fullpath = rootslash + dirname |
38 hginside = False |
|
39 try: |
38 try: |
40 for name, kind in osutil.listdir(fullpath): |
39 for name, kind in osutil.listdir(fullpath): |
41 if kind == stat.S_IFDIR: |
40 if kind == stat.S_IFDIR: |
42 if name == '.hg': |
41 if name == '.hg': |
43 hginside = True |
|
44 if not top: |
42 if not top: |
45 return |
43 return |
46 else: |
44 else: |
47 d = join(dirname, name) |
45 d = join(dirname, name) |
48 if repo.dirstate._ignore(d): |
46 if repo.dirstate._ignore(d): |
50 for subdir in walkit(d, False): |
48 for subdir in walkit(d, False): |
51 yield subdir |
49 yield subdir |
52 except OSError, err: |
50 except OSError, err: |
53 if err.errno not in walk_ignored_errors: |
51 if err.errno not in walk_ignored_errors: |
54 raise |
52 raise |
55 if top or not hginside: |
53 yield fullpath |
56 yield fullpath |
|
57 |
54 |
58 return walkit('', True) |
55 return walkit('', True) |
59 |
56 |
60 def walk(repo, root): |
57 def walk(repo, root): |
61 '''Like os.walk, but only yields regular files.''' |
58 '''Like os.walk, but only yields regular files.''' |
64 |
61 |
65 rootslash = repo.root + os.sep |
62 rootslash = repo.root + os.sep |
66 |
63 |
67 def walkit(root, reporoot): |
64 def walkit(root, reporoot): |
68 files, dirs = [], [] |
65 files, dirs = [], [] |
69 hginside = False |
|
70 |
66 |
71 try: |
67 try: |
72 fullpath = rootslash + root |
68 fullpath = rootslash + root |
73 for name, kind in osutil.listdir(fullpath): |
69 for name, kind in osutil.listdir(fullpath): |
74 if kind == stat.S_IFDIR: |
70 if kind == stat.S_IFDIR: |
75 if name == '.hg': |
71 if name == '.hg': |
76 hginside = True |
|
77 if reporoot: |
72 if reporoot: |
78 continue |
73 continue |
79 else: |
74 else: |
80 return |
75 return |
81 dirs.append(name) |
76 dirs.append(name) |
82 elif kind in (stat.S_IFREG, stat.S_IFLNK): |
77 elif kind in (stat.S_IFREG, stat.S_IFLNK): |
83 files.append((name, kind)) |
78 files.append((name, kind)) |
84 if reporoot or not hginside: |
79 yield fullpath, dirs, files |
85 yield fullpath, dirs, files |
|
86 |
80 |
87 for subdir in dirs: |
81 for subdir in dirs: |
88 path = join(root, subdir) |
82 path = join(root, subdir) |
89 if repo.dirstate._ignore(path): |
83 if repo.dirstate._ignore(path): |
90 continue |
84 continue |