##// END OF EJS Templates
Allow hgwebdir collections to follow symlinks.
Eric Hopper -
r6284:c93b6c0e default
parent child Browse files
Show More
@@ -55,7 +55,7 b' class hgwebdir(object):'
55 self.repos.extend(cleannames(cp.items('paths')))
55 self.repos.extend(cleannames(cp.items('paths')))
56 if cp.has_section('collections'):
56 if cp.has_section('collections'):
57 for prefix, root in cp.items('collections'):
57 for prefix, root in cp.items('collections'):
58 for path in util.walkrepos(root):
58 for path in util.walkrepos(root, followsym = True):
59 repo = os.path.normpath(path)
59 repo = os.path.normpath(path)
60 name = repo
60 name = repo
61 if name.startswith(prefix):
61 if name.startswith(prefix):
@@ -1702,19 +1702,47 b' def ellipsis(text, maxlength=400):'
1702 else:
1702 else:
1703 return "%s..." % (text[:maxlength-3])
1703 return "%s..." % (text[:maxlength-3])
1704
1704
1705 def walkrepos(path):
1705 def walkrepos(path, followsym=False, seen_dirs=None):
1706 '''yield every hg repository under path, recursively.'''
1706 '''yield every hg repository under path, recursively.'''
1707 def errhandler(err):
1707 def errhandler(err):
1708 if err.filename == path:
1708 if err.filename == path:
1709 raise err
1709 raise err
1710 if followsym and hasattr(os.path, 'samestat'):
1711 def _add_dir_if_not_there(dirlst, dirname):
1712 match = False
1713 samestat = os.path.samestat
1714 dirstat = os.stat(dirname)
1715 for lstdirstat in dirlst:
1716 if samestat(dirstat, lstdirstat):
1717 match = True
1718 break
1719 if not match:
1720 dirlst.append(dirstat)
1721 return not match
1722 else:
1723 followsym = false
1710
1724
1711 for root, dirs, files in os.walk(path, onerror=errhandler):
1725 if (seen_dirs is None) and followsym:
1726 seen_dirs = []
1727 _add_dir_if_not_there(seen_dirs, path)
1728 for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
1712 if '.hg' in dirs:
1729 if '.hg' in dirs:
1713 dirs[:] = [] # don't descend further
1730 dirs[:] = [] # don't descend further
1714 yield root # found a repository
1731 yield root # found a repository
1715 qroot = os.path.join(root, '.hg', 'patches')
1732 qroot = os.path.join(root, '.hg', 'patches')
1716 if os.path.isdir(os.path.join(qroot, '.hg')):
1733 if os.path.isdir(os.path.join(qroot, '.hg')):
1717 yield qroot # we have a patch queue repo here
1734 yield qroot # we have a patch queue repo here
1735 elif followsym:
1736 newdirs = []
1737 for d in dirs:
1738 fname = os.path.join(root, d)
1739 if _add_dir_if_not_there(seen_dirs, fname):
1740 if os.path.islink(fname):
1741 for hgname in walkrepos(fname, True, seen_dirs):
1742 yield hgname
1743 else:
1744 newdirs.append(d)
1745 dirs[:] = newdirs
1718
1746
1719 _rcpath = None
1747 _rcpath = None
1720
1748
General Comments 0
You need to be logged in to leave comments. Login now