def _load_codereview_impl(self, codereview=None, **kwargs):
    if codereview:
        assert (codereview in _CODEREVIEW_IMPLEMENTATIONS)
        cls = _CODEREVIEW_IMPLEMENTATIONS[codereview]
        self._codereview = codereview
        self._codereview_impl = cls(self, **kwargs)
        return
    assert (not self.issue)
    self.lookedup_issue = True
    for (codereview, cls) in _CODEREVIEW_IMPLEMENTATIONS.iteritems():
        setting = cls.IssueSetting(self.GetBranch())
        issue = RunGit(['config', setting], error_ok=True).strip()
        if issue:
            self._codereview = codereview
            self._codereview_impl = cls(self, **kwargs)
            self.issue = int(issue)
            return
    return self._load_codereview_impl(codereview=('gerrit' if settings.GetIsGerrit() else 'rietveld'), **kwargs)
def _load_codereview_impl(self, codereview=None, **kwargs):
    if codereview:
        assert (codereview in _CODEREVIEW_IMPLEMENTATIONS)
        cls = _CODEREVIEW_IMPLEMENTATIONS[codereview]
        self._codereview = codereview
        self._codereview_impl = cls(self, **kwargs)
        return
    assert (not self.issue)
    self.lookedup_issue = True
    for (codereview, cls) in _CODEREVIEW_IMPLEMENTATIONS.iteritems():
        setting = cls.IssueSetting(self.GetBranch())
        issue = RunGit(['config', setting], error_ok=True).strip()
        if issue:
            self._codereview = codereview
            self._codereview_impl = cls(self, **kwargs)
            self.issue = int(issue)
            return
    return self._load_codereview_impl(codereview=('gerrit' if settings.GetIsGerrit() else 'rietveld'), **kwargs)