1874 if len(text) <= maxlength: |
1874 if len(text) <= maxlength: |
1875 return text |
1875 return text |
1876 else: |
1876 else: |
1877 return "%s..." % (text[:maxlength-3]) |
1877 return "%s..." % (text[:maxlength-3]) |
1878 |
1878 |
1879 def walkrepos(path, followsym=False, seen_dirs=None): |
1879 def walkrepos(path, followsym=False, seen_dirs=None, recurse=False): |
1880 '''yield every hg repository under path, recursively.''' |
1880 '''yield every hg repository under path, recursively.''' |
1881 def errhandler(err): |
1881 def errhandler(err): |
1882 if err.filename == path: |
1882 if err.filename == path: |
1883 raise err |
1883 raise err |
1884 if followsym and hasattr(os.path, 'samestat'): |
1884 if followsym and hasattr(os.path, 'samestat'): |
1899 if (seen_dirs is None) and followsym: |
1899 if (seen_dirs is None) and followsym: |
1900 seen_dirs = [] |
1900 seen_dirs = [] |
1901 _add_dir_if_not_there(seen_dirs, path) |
1901 _add_dir_if_not_there(seen_dirs, path) |
1902 for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler): |
1902 for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler): |
1903 if '.hg' in dirs: |
1903 if '.hg' in dirs: |
1904 dirs[:] = [] # don't descend further |
|
1905 yield root # found a repository |
1904 yield root # found a repository |
1906 qroot = os.path.join(root, '.hg', 'patches') |
1905 if recurse: |
1907 if os.path.isdir(os.path.join(qroot, '.hg')): |
1906 # avoid recursing inside the .hg directory |
1908 yield qroot # we have a patch queue repo here |
1907 # the mq repository is added in any case |
|
1908 dirs.remove('.hg') |
|
1909 qroot = os.path.join(root, '.hg', 'patches') |
|
1910 if os.path.isdir(os.path.join(qroot, '.hg')): |
|
1911 yield qroot # we have a patch queue repo here |
|
1912 else: |
|
1913 dirs[:] = [] # don't descend further |
1909 elif followsym: |
1914 elif followsym: |
1910 newdirs = [] |
1915 newdirs = [] |
1911 for d in dirs: |
1916 for d in dirs: |
1912 fname = os.path.join(root, d) |
1917 fname = os.path.join(root, d) |
1913 if _add_dir_if_not_there(seen_dirs, fname): |
1918 if _add_dir_if_not_there(seen_dirs, fname): |