示例#1
0
def _readconfig(ui, repopath, webconfpath):
    """Create new ui and webconf object and read appropriate files"""
    lui = ui.copy()
    if webconfpath:
        lui.readconfig(webconfpath)
        # TODO: handle file not found
        c = wconfig.readfile(webconfpath)
        c.path = os.path.abspath(webconfpath)
        return lui, c
    elif repopath:  # imitate webconf for single repo
        lui.readconfig(os.path.join(repopath, '.hg', 'hgrc'), repopath)
        c = wconfig.config()
        try:
            if not os.path.exists(os.path.join(repopath, '.hgsub')):
                # no _asconfigliststr(repopath) for now, because ServeDialog
                # cannot parse it as a list in single-repo mode.
                c.set('paths', '/', repopath)
            else:
                # since hg 8cbb59124e67, path entry is parsed as a list
                base = hglib.shortreponame(lui) or os.path.basename(repopath)
                c.set('paths', base,
                      _asconfigliststr(os.path.join(repopath, '**')))
        except (EnvironmentError, error.Abort, error.RepoError):
            c.set('paths', '/', repopath)
        return lui, c
    else:
        return lui, None
示例#2
0
def _newwebconf(repopath, webconfpath):
    """create config obj for hgweb"""
    if webconfpath:
        # TODO: handle file not found
        c = wconfig.readfile(webconfpath)
        c.path = os.path.abspath(webconfpath)
        return c
    elif repopath:  # imitate webconf for single repo
        c = wconfig.config()
        try:
            repo = thgrepo.repository(None, repopath)
            roots = [root for root in recursiveRepoSearch(repo)]
            if len(roots) == 1:
                # no _asconfigliststr(repopath) for now, because ServeDialog
                # cannot parse it as a list in single-repo mode.
                c.set("paths", "/", repopath)
            else:
                # since hg 8cbb59124e67, path entry is parsed as a list
                base = hglib.fromunicode(repo.shortname)
                c.set("paths", base, _asconfigliststr(repopath))
                for root in roots[1:]:
                    c.set("paths", base + root[len(repopath) :], _asconfigliststr(root))
        except (EnvironmentError, error.Abort, error.RepoError):
            c.set("paths", "/", repopath)
        return c
示例#3
0
def _newwebconf(repopath, webconfpath):
    """create config obj for hgweb"""
    if webconfpath:
        # TODO: handle file not found
        c = wconfig.readfile(webconfpath)
        c.path = os.path.abspath(webconfpath)
        return c
    elif repopath:  # imitate webconf for single repo
        c = wconfig.config()
        try:
            repo = thgrepo.repository(None, repopath)
            roots = [root for root in recursiveRepoSearch(repo)]
            if len(roots) == 1:
                # no _asconfigliststr(repopath) for now, because ServeDialog
                # cannot parse it as a list in single-repo mode.
                c.set('paths', '/', repopath)
            else:
                # since hg 8cbb59124e67, path entry is parsed as a list
                base = hglib.fromunicode(repo.shortname)
                c.set('paths', base, _asconfigliststr(repopath))
                for root in roots[1:]:
                    c.set('paths', base + root[len(repopath):],
                          _asconfigliststr(root))
        except (EnvironmentError, error.Abort, error.RepoError):
            c.set('paths', '/', repopath)
        return c
示例#4
0
    def __init__(self, parent=None, webconf=None):
        super(WebconfForm, self).__init__(parent, acceptDrops=True)
        self._qui = Ui_WebconfForm()
        self._qui.setupUi(self)
        self._initicons()
        self._qui.path_edit.currentIndexChanged.connect(self._updateview)
        self._qui.path_edit.currentIndexChanged.connect(self._updateform)
        self._qui.add_button.clicked.connect(self._addpathmap)

        self.setwebconf(webconf or wconfig.config())
        self._updateform()
示例#5
0
def _newwebconf(repopath, webconfpath):
    """create config obj for hgweb"""
    if webconfpath:
        # TODO: handle file not found
        c = wconfig.readfile(webconfpath)
        c.path = os.path.abspath(webconfpath)
        return c
    elif repopath:  # imitate webconf for single repo
        c = wconfig.config()
        try:
            repo = thgrepo.repository(None, repopath)
            roots = [root for root in recursiveRepoSearch(repo)]
            if len(roots) == 1:
                c.set('paths', '/', repopath)
            else:
                base = hglib.fromunicode(repo.shortname)
                c.set('paths', base, repopath)
                for root in roots[1:]:
                    c.set('paths', base + root[len(repopath):], root)
        except (EnvironmentError, error.Abort, error.RepoError):
            c.set('paths', '/', repopath)
        return c
示例#6
0
def _newwebconf(repopath, webconfpath):
    """create config obj for hgweb"""
    if webconfpath:
        # TODO: handle file not found
        c = wconfig.readfile(webconfpath)
        c.path = os.path.abspath(webconfpath)
        return c
    elif repopath:  # imitate webconf for single repo
        c = wconfig.config()
        try:
            # TODO: not nice to instantiate repo just for repo.shortname
            repo = thgrepo.repository(None, repopath)
            if not os.path.exists(os.path.join(repopath, '.hgsub')):
                # no _asconfigliststr(repopath) for now, because ServeDialog
                # cannot parse it as a list in single-repo mode.
                c.set('paths', '/', repopath)
            else:
                # since hg 8cbb59124e67, path entry is parsed as a list
                base = hglib.fromunicode(repo.shortname)
                c.set('paths', base,
                      _asconfigliststr(os.path.join(repopath, '**')))
        except (EnvironmentError, error.Abort, error.RepoError):
            c.set('paths', '/', repopath)
        return c
 def setUp(self):
     if not hasattr(wconfig.config(), 'write'):
         raise SkipTest
     self.hg = helpers.HgClient(helpers.mktmpdir(__name__))
     self.hg.init()
示例#8
0
def check_write_copied_rconfig():
    c0 = newrconfig({'foo.bar': 'x'})
    c1 = wconfig.config(c0)
    assert_equals('[foo]\nbar = x', written(c1).rstrip())
示例#9
0
def newwconfig(vals={}):
    return wconfig.config(newrconfig(vals))
 def setUp(self):
     if not hasattr(wconfig.config(), 'write'):
         raise SkipTest
     self.hg = helpers.HgClient(helpers.mktmpdir(__name__))
     self.hg.init()
示例#11
0
def check_write_copied_rconfig():
    c0 = newrconfig({'foo.bar': 'x'})
    c1 = wconfig.config(c0)
    assert_equals('[foo]\nbar = x', written(c1).rstrip())
示例#12
0
def newwconfig(vals={}):
    return wconfig.config(newrconfig(vals))