def branches(**map): parity = paritygen(web.stripecount) b = web.repo.branchtags() l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()] for r,n,t in util.sort(l): yield {'parity': parity.next(), 'branch': t, 'node': hex(n), 'date': web.repo[n].date()}
def filelist(**map): for f in util.sort(files): full = files[f] fctx = ctx.filectx(full) yield {"file": full, "parity": parity.next(), "basename": f, "date": fctx.date(), "size": fctx.size(), "permissions": mf.flags(full)}
def dirlist(**map): for d in util.sort(dirs): emptydirs = [] h = dirs[d] while isinstance(h, dict) and len(h) == 1: k,v = h.items()[0] if v: emptydirs.append(k) h = v path = "%s%s" % (abspath, d) yield {"parity": parity.next(), "path": path, "emptydirs": "/".join(emptydirs), "basename": d}
def __init__(self, config, parentui=None): def cleannames(items): return [(util.pconvert(name).strip('/'), path) for name, path in items] self.parentui = parentui or ui.ui(report_untrusted=False, interactive = False) self.motd = None self.style = 'paper' self.stripecount = None self.repos_sorted = ('name', False) self._baseurl = None if isinstance(config, (list, tuple)): self.repos = cleannames(config) self.repos_sorted = ('', False) elif isinstance(config, dict): self.repos = util.sort(cleannames(config.items())) else: if isinstance(config, util.configparser): cp = config else: cp = util.configparser() cp.read(config) self.repos = [] if cp.has_section('web'): if cp.has_option('web', 'motd'): self.motd = cp.get('web', 'motd') if cp.has_option('web', 'style'): self.style = cp.get('web', 'style') if cp.has_option('web', 'stripes'): self.stripecount = int(cp.get('web', 'stripes')) if cp.has_option('web', 'baseurl'): self._baseurl = cp.get('web', 'baseurl') if cp.has_section('paths'): paths = cleannames(cp.items('paths')) for prefix, root in paths: roothead, roottail = os.path.split(root) # "foo = /bar/*" makes every subrepo of /bar/ to be # mounted as foo/subrepo # and "foo = /bar/**" does even recurse inside the # subdirectories, remember to use it without working dir. try: recurse = {'*': False, '**': True}[roottail] except KeyError: self.repos.append((prefix, root)) continue roothead = os.path.normpath(roothead) for path in util.walkrepos(roothead, followsym=True, recurse=recurse): path = os.path.normpath(path) name = util.pconvert(path[len(roothead):]).strip('/') if prefix: name = prefix + '/' + name self.repos.append((name, path)) if cp.has_section('collections'): for prefix, root in cp.items('collections'): for path in util.walkrepos(root, followsym=True): repo = os.path.normpath(path) name = repo if name.startswith(prefix): name = name[len(prefix):] self.repos.append((name.lstrip(os.sep), repo)) self.repos.sort()