예제 #1
0
def runtest():
    reposet = frozenset(walkrepos('.', followsym=True))
    if sym and (len(reposet) != 3):
        print "reposet = %r" % (reposet, )
        print "Found %d repositories when I should have found 3" % (
            len(reposet), )
    if (not sym) and (len(reposet) != 2):
        print "reposet = %r" % (reposet, )
        print "Found %d repositories when I should have found 2" % (
            len(reposet), )
    sub1set = frozenset(
        (pjoin('.', 'sub1'), pjoin('.', 'circle', 'subdir', 'sub1')))
    if len(sub1set & reposet) != 1:
        print "sub1set = %r" % (sub1set, )
        print "reposet = %r" % (reposet, )
        print "sub1set and reposet should have exactly one path in common."
    sub2set = frozenset((pjoin('.',
                               'subsub1'), pjoin('.', 'subsubdir', 'subsub1')))
    if len(sub2set & reposet) != 1:
        print "sub2set = %r" % (sub2set, )
        print "reposet = %r" % (reposet, )
        print "sub1set and reposet should have exactly one path in common."
    sub3 = pjoin('.', 'circle', 'top1')
    if sym and not (sub3 in reposet):
        print "reposet = %r" % (reposet, )
        print "Symbolic links are supported and %s is not in reposet" % (
            sub3, )
예제 #2
0
def findrepos(paths):
    repos = []
    for prefix, root in cleannames(paths):
        roothead, roottail = os.path.split(root)
        # "foo = /bar/*" makes every subrepo of /bar/ to be
        # mounted as foo/subrepo
        # and "foo = /bar/**" also recurses into the subdirectories,
        # remember to use it without working dir.
        try:
            recurse = {'*': False, '**': True}[roottail]
        except KeyError:
            repos.append((prefix, root))
            continue
        roothead = os.path.normpath(os.path.abspath(roothead))
        paths = util.walkrepos(roothead, followsym=True, recurse=recurse)
        repos.extend(urlrepos(prefix, roothead, paths))
    return repos
예제 #3
0
def findrepos(paths):
    repos = []
    for prefix, root in cleannames(paths):
        roothead, roottail = os.path.split(root)
        # "foo = /bar/*" makes every subrepo of /bar/ to be
        # mounted as foo/subrepo
        # and "foo = /bar/**" also recurses into the subdirectories,
        # remember to use it without working dir.
        try:
            recurse = {'*': False, '**': True}[roottail]
        except KeyError:
            repos.append((prefix, root))
            continue
        roothead = os.path.normpath(os.path.abspath(roothead))
        paths = util.walkrepos(roothead, followsym=True, recurse=recurse)
        repos.extend(urlrepos(prefix, roothead, paths))
    return repos
예제 #4
0
    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 = None
        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 = cleannames(config.items())
            self.repos.sort()
        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'):
                self.repos.extend(cleannames(cp.items('paths')))
            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()
예제 #5
0
    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 = None
        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 = cleannames(config.items())
            self.repos.sort()
        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'):
                self.repos.extend(cleannames(cp.items('paths')))
            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()
예제 #6
0
    def refresh(self):
        if self.lastrefresh + self.refreshinterval > time.time():
            return

        if self.baseui:
            u = self.baseui.copy()
        else:
            u = ui.ui()
            u.setconfig('ui', 'report_untrusted', 'off')
            u.setconfig('ui', 'interactive', 'off')

        if not isinstance(self.conf, (dict, list, tuple)):
            map = {'paths': 'hgweb-paths'}
            if not os.path.exists(self.conf):
                raise util.Abort(_('config file %s not found!') % self.conf)
            u.readconfig(self.conf, remap=map, trust=True)
            paths = u.configitems('hgweb-paths')
        elif isinstance(self.conf, (list, tuple)):
            paths = self.conf
        elif isinstance(self.conf, dict):
            paths = self.conf.items()

        repos = findrepos(paths)
        for prefix, root in u.configitems('collections'):
            prefix = util.pconvert(prefix)
            for path in util.walkrepos(root, followsym=True):
                repo = os.path.normpath(path)
                name = util.pconvert(repo)
                if name.startswith(prefix):
                    name = name[len(prefix):]
                repos.append((name.lstrip('/'), repo))

        self.repos = repos
        self.ui = u
        encoding.encoding = self.ui.config('web', 'encoding',
                                           encoding.encoding)
        self.style = self.ui.config('web', 'style', 'paper')
        self.templatepath = self.ui.config('web', 'templates', None)
        self.stripecount = self.ui.config('web', 'stripes', 1)
        if self.stripecount:
            self.stripecount = int(self.stripecount)
        self._baseurl = self.ui.config('web', 'baseurl')
        self.lastrefresh = time.time()
예제 #7
0
    def refresh(self):
        if self.lastrefresh + self.refreshinterval > time.time():
            return

        if self.baseui:
            u = self.baseui.copy()
        else:
            u = ui.ui()
            u.setconfig('ui', 'report_untrusted', 'off')
            u.setconfig('ui', 'interactive', 'off')

        if not isinstance(self.conf, (dict, list, tuple)):
            map = {'paths': 'hgweb-paths'}
            if not os.path.exists(self.conf):
                raise util.Abort(_('config file %s not found!') % self.conf)
            u.readconfig(self.conf, remap=map, trust=True)
            paths = u.configitems('hgweb-paths')
        elif isinstance(self.conf, (list, tuple)):
            paths = self.conf
        elif isinstance(self.conf, dict):
            paths = self.conf.items()

        repos = findrepos(paths)
        for prefix, root in u.configitems('collections'):
            prefix = util.pconvert(prefix)
            for path in util.walkrepos(root, followsym=True):
                repo = os.path.normpath(path)
                name = util.pconvert(repo)
                if name.startswith(prefix):
                    name = name[len(prefix):]
                repos.append((name.lstrip('/'), repo))

        self.repos = repos
        self.ui = u
        encoding.encoding = self.ui.config('web', 'encoding',
                                           encoding.encoding)
        self.style = self.ui.config('web', 'style', 'paper')
        self.templatepath = self.ui.config('web', 'templates', None)
        self.stripecount = self.ui.config('web', 'stripes', 1)
        if self.stripecount:
            self.stripecount = int(self.stripecount)
        self._baseurl = self.ui.config('web', 'baseurl')
        self.lastrefresh = time.time()
예제 #8
0
def findrepos(paths):
    repos = []
    for prefix, root in cleannames(paths):
        roothead, roottail = os.path.split(root)
        # "foo = /bar/*" makes every subrepo of /bar/ to be
        # mounted as foo/subrepo
        # and "foo = /bar/**" also recurses into the subdirectories,
        # remember to use it without working dir.
        try:
            recurse = {'*': False, '**': True}[roottail]
        except KeyError:
            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
            repos.append((name, path))
    return repos
예제 #9
0
def findrepos(paths):
    repos = []
    for prefix, root in cleannames(paths):
        roothead, roottail = os.path.split(root)
        # "foo = /bar/*" makes every subrepo of /bar/ to be
        # mounted as foo/subrepo
        # and "foo = /bar/**" also recurses into the subdirectories,
        # remember to use it without working dir.
        try:
            recurse = {'*': False, '**': True}[roottail]
        except KeyError:
            repos.append((prefix, root))
            continue
        roothead = os.path.normpath(os.path.abspath(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
            repos.append((name, path))
    return repos
예제 #10
0
def runtest():
    reposet = frozenset(walkrepos('.', followsym=True))
    if sym and (len(reposet) != 3):
        print "reposet = %r" % (reposet,)
        print "Found %d repositories when I should have found 3" % (len(reposet),)
    if (not sym) and (len(reposet) != 2):
        print "reposet = %r" % (reposet,)
        print "Found %d repositories when I should have found 2" % (len(reposet),)
    sub1set = frozenset((pjoin('.', 'sub1'),
                         pjoin('.', 'circle', 'subdir', 'sub1')))
    if len(sub1set & reposet) != 1:
        print "sub1set = %r" % (sub1set,)
        print "reposet = %r" % (reposet,)
        print "sub1set and reposet should have exactly one path in common."
    sub2set = frozenset((pjoin('.', 'subsub1'),
                         pjoin('.', 'subsubdir', 'subsub1')))
    if len(sub2set & reposet) != 1:
        print "sub2set = %r" % (sub2set,)
        print "reposet = %r" % (reposet,)
        print "sub1set and reposet should have exactly one path in common."
    sub3 = pjoin('.', 'circle', 'top1')
    if sym and not (sub3 in reposet):
        print "reposet = %r" % (reposet,)
        print "Symbolic links are supported and %s is not in reposet" % (sub3,)
def walk_repos(ui,rootpath):
    p = util.pconvert(rootpath)
    for path in util.walkrepos(p, followsym=True):
        debug_info(('repo %s\n') % path)
예제 #12
0
    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()
예제 #13
0
def walk_repos(ui, rootpath):
    p = util.pconvert(rootpath)
    for path in util.walkrepos(p, followsym=True):
        debug_info(('repo %s\n') % path)