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
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
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
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()
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
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()
def check_write_copied_rconfig(): c0 = newrconfig({'foo.bar': 'x'}) c1 = wconfig.config(c0) assert_equals('[foo]\nbar = x', written(c1).rstrip())
def newwconfig(vals={}): return wconfig.config(newrconfig(vals))