Edgewall Software

Ticket #8731: 8731-simpler-api-r8676.patch

File 8731-simpler-api-r8676.patch, 2.9 KB (added by rblank, 3 years ago)

Fix for simpler API in [8677].

  • tracext/hg/backend.py

    diff --git a/tracext/hg/backend.py b/tracext/hg/backend.py
    a b  
    217217        else: 
    218218            yield ("hg", 8) 
    219219 
    220     def get_repository(self, type, dir, repo_options): 
     220    def get_repository(self, type, dir, params): 
    221221        """Return a `MercurialRepository`""" 
    222222        if not self._version: 
    223223            try: 
     
    236236        options = {} 
    237237        for key, val in self.config.options(type): 
    238238            options[key] = val 
    239         if isinstance(repo_options, basestring): # 0.11 compat 
    240             repo_options = {'username': repo_options} 
    241         options.update(repo_options) 
     239        options.update(params) 
    242240        if not self.ui: 
    243241            self._setup_ui(options.get('hgrc')) 
    244         repos = MercurialRepository(repo_options['name'], repo_options['id'], 
    245                                     dir, self.log, self.ui, options) 
     242        repos = MercurialRepository(dir, options, self.log, self.ui) 
    246243        repos.version_info = self._version_info 
    247244        return repos 
    248245 
     
    324321    additional changeset properties. 
    325322    """ 
    326323 
    327     def __init__(self, reponame, id, path, log, ui, options): 
     324    def __init__(self, path, params, log, ui): 
    328325        self.ui = ui 
    329         self.options = options 
    330         self.reponame = None 
    331326        # TODO: per repository ui and options? 
    332327        if isinstance(path, unicode): 
    333328            str_path = path.encode('utf-8') 
     
    340335        except RepoError, e: 
    341336            self.path = None 
    342337        self._show_rev = True 
    343         if 'show_rev' in options and not options['show_rev'] in TRUE: 
     338        if 'show_rev' in params and not params['show_rev'] in TRUE: 
    344339            self._show_rev = False 
    345         self._node_fmt = 'node_format' in options \ 
    346                          and options['node_format']   # will default to 'short' 
     340        self._node_fmt = 'node_format' in params \ 
     341                         and params['node_format']  # will default to 'short' 
    347342        if self.path is None: 
    348343            raise TracError(_("%(path)s does not appear to contain a Mercurial" 
    349344                              " repository.", path=path)) 
    350         Repository.__init__(self, reponame, id, 'hg:%s' % path, None, log) 
     345        Repository.__init__(self, 'hg:%s' % path, params, None, log) 
    351346 
    352347    def hg_time(self, timeinfo): 
    353348        # [hg b47f96a178a3] introduced an API change: 
     
    449444                pass 
    450445 
    451446    def get_path_url(self, path, rev): 
    452         url = self.options.get('url') 
     447        url = self.params.get('url') 
    453448        if url and (not path or path == '/'): 
    454449            if not rev: 
    455450                return url 
     
    809804    def get_content_type(self): 
    810805        if self.isdir: 
    811806            return None 
    812         if 'mq' in self.repos.options: 
     807        if 'mq' in self.repos.params: 
    813808            if self.path not in ('.hgignore', 'series'): 
    814809                return 'text/x-diff' 
    815810        return ''