| 49 |
49 |
</rhmanifest>
|
| 50 |
50 |
"""
|
| 51 |
51 |
import re, time, html, urllib
|
| 52 |
|
from mercurial import cmdutil, commands, node, error, hg, registrar
|
|
52 |
from mercurial import commands, node, error, hg, registrar
|
| 53 |
53 |
cmdtable = {}
|
| 54 |
|
command = registrar.command(cmdtable) if hasattr(registrar, 'command') else cmdutil.command(cmdtable)
|
|
54 |
command = registrar.command(cmdtable)
|
| 55 |
55 |
_x = lambda s: html.escape(s.decode('utf-8')).encode('utf-8')
|
| 56 |
56 |
_u = lambda s: html.escape(urllib.parse.quote(s)).encode('utf-8')
|
| ... | ... | |
| 63 |
63 |
def _changectx(repo, rev):
|
| 64 |
64 |
if isinstance(rev, bytes):
|
| 65 |
65 |
rev = repo.lookup(rev)
|
| 66 |
|
if hasattr(repo, 'changectx'):
|
| 67 |
|
return repo.changectx(rev)
|
| 68 |
|
else:
|
| 69 |
|
return repo[rev]
|
|
66 |
return repo[rev]
|
| 70 |
67 |
def _tip(ui, repo):
|
| 71 |
68 |
# see mercurial/commands.py:tip
|
| 72 |
|
def tiprev():
|
| 73 |
|
try:
|
| 74 |
|
return len(repo) - 1
|
| 75 |
|
except TypeError: # Mercurial < 1.1
|
| 76 |
|
return repo.changelog.count() - 1
|
| 77 |
|
tipctx = _changectx(repo, tiprev())
|
|
69 |
tipctx = _changectx(repo, len(repo) - 1)
|
| 78 |
70 |
ui.write(b'<tip revision="%d" node="%s"/>\n'
|
| 79 |
71 |
% (tipctx.rev(), _x(node.hex(tipctx.node()))))
|
| ... | ... | |
| 96 |
88 |
def _branches(ui, repo):
|
| 97 |
89 |
# see mercurial/commands.py:branches
|
| 98 |
90 |
def iterbranches():
|
| 99 |
|
if getattr(repo, 'branchtags', None) is not None:
|
| 100 |
|
# Mercurial < 2.9
|
| 101 |
|
for t, n in repo.branchtags().iteritems():
|
| 102 |
|
yield t, n, repo.changelog.rev(n)
|
| 103 |
|
else:
|
| 104 |
|
for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
|
| 105 |
|
yield tag, tip, repo.changelog.rev(tip)
|
|
91 |
for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
|
|
92 |
yield tag, tip, repo.changelog.rev(tip)
|
| 106 |
93 |
def branchheads(branch):
|
| 107 |
|
try:
|
| 108 |
|
return repo.branchheads(branch, closed=False)
|
| 109 |
|
except TypeError: # Mercurial < 1.2
|
| 110 |
|
return repo.branchheads(branch)
|
|
94 |
return repo.branchheads(branch, closed=False)
|
| 111 |
95 |
def lookup(rev, n):
|
| 112 |
96 |
try:
|
| 113 |
97 |
return repo.lookup(str(rev).encode('utf-8'))
|