Changeset View
Changeset View
Standalone View
Standalone View
support/hg/arc-hg.py
Show All 16 Lines | from mercurial import ( | ||||
cmdutil, | cmdutil, | ||||
bookmarks, | bookmarks, | ||||
bundlerepo, | bundlerepo, | ||||
error, | error, | ||||
hg, | hg, | ||||
i18n, | i18n, | ||||
node, | node, | ||||
registrar, | registrar, | ||||
util, | |||||
cspeckmim: Oops this isn't necessary, was doing some testing | |||||
) | ) | ||||
_ = i18n._ | _ = i18n._ | ||||
cmdtable = {} | cmdtable = {} | ||||
command = registrar.command(cmdtable) | command = registrar.command(cmdtable) | ||||
@command( | @command( | ||||
b'arc-amend', | |||||
[ | |||||
(b'l', b'logfile', b'', _(b'read commit message from file'), _(b'FILE')), | |||||
(b'm', b'message', None, _(b'use text as commit message'), _(b'TEXT')), | |||||
], | |||||
_(b'[--logfile FILE] [--message TEXT]')) | |||||
def amend(ui, repo, source=None, **opts): | |||||
# The option keys seem to come in as 'str' type but the cmdutil.amend() code | |||||
# expects them as binary. | |||||
if opts.get('logfile'): | |||||
opts[b'logfile'] = opts.get('logfile') | |||||
if opts.get('message'): | |||||
Done Inline ActionsThis will allow the extension module to load as far back as Mercurial 3.5, possibly earlier. I tested out a basic arc-ls-markers invocation and that seemed to work properly in 3.5 with this change cspeckmim: This will allow the extension module to load as far back as Mercurial 3.5, possibly earlier. I… | |||||
opts[b'message'] = opts.get('message') | |||||
cspeckmimAuthorUnsubmitted Done Inline ActionsI wonder if this should inversely check for b'' keys and insert them as string keys as well, for the Python 2 v 3 situation. cspeckmim: I wonder if this should inversely check for `b''` keys and insert them as string keys as well… | |||||
cmdutil.amend(ui, repo, repo[b'.'], {}, [], opts) | |||||
return 0 | |||||
@command( | |||||
b'arc-ls-markers', | b'arc-ls-markers', | ||||
[(b'', b'output', b'', | [(b'', b'output', b'', | ||||
_(b'file to output refs to'), _(b'FILE')), | _(b'file to output refs to'), _(b'FILE')), | ||||
] + cmdutil.remoteopts, | ] + cmdutil.remoteopts, | ||||
_(b'[--output FILENAME] [SOURCE]')) | _(b'[--output FILENAME] [SOURCE]')) | ||||
def lsmarkers(ui, repo, source=None, **opts): | def lsmarkers(ui, repo, source=None, **opts): | ||||
"""list markers | """list markers | ||||
Show All 25 Lines | def lsmarkers(ui, repo, source=None, **opts): | ||||
json_opts = { | json_opts = { | ||||
'indent': 2, | 'indent': 2, | ||||
'sort_keys': True, | 'sort_keys': True, | ||||
} | } | ||||
output_file = opts.get('output') | output_file = opts.get('output') | ||||
if output_file: | if output_file: | ||||
if os.path.exists(output_file): | if os.path.exists(output_file): | ||||
raise error.Abort(_('File "%s" already exists.' % output_file)) | raise error.Abort(_('File "%s" already exists.' % output_file)) | ||||
with open(output_file, 'w+') as f: | with open(output_file, 'w+') as f: | ||||
Done Inline ActionsComment slightly outdated, we're not removing entries with empty values -- older Mercurial seems to depend on the entries being present despite being empty but newer Mercurial doesn't care cspeckmim: Comment slightly outdated, we're not removing entries with empty values -- older Mercurial… | |||||
json.dump(markers, f, **json_opts) | json.dump(markers, f, **json_opts) | ||||
else: | else: | ||||
json_data = json.dumps(markers, **json_opts) | json_data = json.dumps(markers, **json_opts) | ||||
print(json_data) | print(json_data) | ||||
return 0 | return 0 | ||||
def localmarkers(ui, repo): | def localmarkers(ui, repo): | ||||
markers = [] | markers = [] | ||||
active_node = repo[b'.'].node() | active_node = repo[b'.'].node() | ||||
all_heads = set(repo.heads()) | all_heads = set(repo.heads()) | ||||
current_name = repo.dirstate.branch() | current_name = repo.dirstate.branch() | ||||
branch_list = repo.branchmap().iterbranches() | branch_list = repo.branchmap().iterbranches() | ||||
for branch_name, branch_heads, tip_node, is_closed in branch_list: | for branch_name, branch_heads, tip_node, is_closed in branch_list: | ||||
for head_node in branch_heads: | for head_node in branch_heads: | ||||
is_active = False | is_active = False | ||||
if branch_name == current_name: | if branch_name == current_name: | ||||
if head_node == active_node: | if head_node == active_node: | ||||
is_active = True | is_active = True | ||||
is_tip = (head_node == tip_node) | is_tip = (head_node == tip_node) | ||||
if is_closed: | if is_closed: | ||||
head_closed = True | head_closed = True | ||||
else: | else: | ||||
head_closed = bool(head_node not in all_heads) | head_closed = bool(head_node not in all_heads) | ||||
Done Inline ActionsI took this from here However it ended up squashing in addition to the amending which will cause problems cspeckmim: I took this from here
https://phab.mercurial-scm. | |||||
description = repo[head_node].description() | description = repo[head_node].description() | ||||
markers.append({ | markers.append({ | ||||
'type': 'branch', | 'type': 'branch', | ||||
'name': branch_name, | 'name': branch_name, | ||||
'node': node.hex(head_node), | 'node': node.hex(head_node), | ||||
'isActive': is_active, | 'isActive': is_active, | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |
Oops this isn't necessary, was doing some testing