Project

General

Profile

Defect #28725 » fix-28725.diff

updated patch by Frédéric Fondement (#28725#note-5) - Go MAEDA, 2018-05-24 23:49

View differences:

lib/redmine/scm/adapters/mercurial/redminehelper.py (working copy)
54 54
_x = cgi.escape
55 55
_u = lambda s: cgi.escape(urllib.quote(s))
56
def _changectx(repo, rev):
57
    if hasattr(repo, 'changectx'):
58
        return repo.changectx(rev)
59
    else:
60
        return repo[rev]
61

  
56 62
def _tip(ui, repo):
57 63
    # see mercurial/commands.py:tip
58 64
    def tiprev():
......
61 67
            return len(repo) - 1
62 68
        except TypeError:  # Mercurial < 1.1
63 69
            return repo.changelog.count() - 1
64
    tipctx = repo.changectx(tiprev())
70
    tipctx = _changectx(repo, tiprev())
65 71
    ui.write('<tip revision="%d" node="%s"/>\n'
66 72
             % (tipctx.rev(), _x(node.hex(tipctx.node()))))
......
94 100
            return repo.branchheads(branch, closed=False)
95 101
        except TypeError:  # Mercurial < 1.2
96 102
            return repo.branchheads(branch)
103
    def lookup(rev, n):
104
        try:
105
            return repo.lookup(rev)
106
        except RuntimeError:
107
            return n
97 108
    for t, n, r in sorted(iterbranches(), key=lambda e: e[2], reverse=True):
98
        if repo.lookup(r) in branchheads(t):
109
        if lookup(r, n) in branchheads(t):
99 110
            ui.write('<branch revision="%d" node="%s" name="%s"/>\n'
100 111
                     % (r, _x(node.hex(n)), _x(t)))
101 112
def _manifest(ui, repo, path, rev):
102
    ctx = repo.changectx(rev)
113
    ctx = _changectx(repo, rev)
103 114
    ui.write('<manifest revision="%d" path="%s">\n'
104 115
             % (ctx.rev(), _u(path)))
......
155 166
    """diff repository (or selected files)"""
156 167
    change = opts.pop('change', None)
157 168
    if change:  # add -c option for Mercurial<1.1
158
        base = repo.changectx(change).parents()[0].rev()
169
        base = _changectx(repo, change).parents()[0].rev()
159 170
        opts['rev'] = [str(base), change]
160 171
    opts['nodates'] = True
161 172
    return commands.diff(ui, repo, *map(urllib.unquote_plus, pats), **opts)
    (1-1/1)