Changeset View
Changeset View
Standalone View
Standalone View
support/hg/arc-hg.py
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | def lsmarkers(ui, repo, source=None, **opts): | ||||
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() | ||||
saw_current = False | |||||
saw_active = False | |||||
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 = (head_node == active_node) | |||||
is_tip = (head_node == tip_node) | |||||
is_current = (branch_name == current_name) | |||||
if is_current: | is_active = False | ||||
saw_current = True | if branch_name == current_name: | ||||
if head_node == active_node: | |||||
is_active = True | |||||
if is_active: | is_tip = (head_node == tip_node) | ||||
saw_active = True | |||||
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) | ||||
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, | ||||
'isClosed': head_closed, | 'isClosed': head_closed, | ||||
'isTip': is_tip, | 'isTip': is_tip, | ||||
'isCurrent': is_current, | |||||
'description': description, | 'description': description, | ||||
}) | }) | ||||
# If the current branch (selected with "hg branch X") is not reflected in | |||||
# the list of heads we selected, add a virtual head for it so callers get | |||||
# a complete picture of repository marker state. | |||||
if not saw_current: | |||||
markers.append({ | |||||
'type': 'branch', | |||||
'name': current_name, | |||||
'node': None, | |||||
'isActive': False, | |||||
'isClosed': False, | |||||
'isTip': False, | |||||
'isCurrent': True, | |||||
'description': None, | |||||
}) | |||||
bookmarks = repo._bookmarks | bookmarks = repo._bookmarks | ||||
active_bookmark = repo._activebookmark | active_bookmark = repo._activebookmark | ||||
for bookmark_name, bookmark_node in arc_items(bookmarks): | for bookmark_name, bookmark_node in arc_items(bookmarks): | ||||
is_active = (active_bookmark == bookmark_name) | is_active = (active_bookmark == bookmark_name) | ||||
description = repo[bookmark_node].description() | description = repo[bookmark_node].description() | ||||
if is_active: | |||||
saw_active = True | |||||
markers.append({ | markers.append({ | ||||
'type': 'bookmark', | 'type': 'bookmark', | ||||
'name': bookmark_name, | 'name': bookmark_name, | ||||
'node': node.hex(bookmark_node), | 'node': node.hex(bookmark_node), | ||||
'isActive': is_active, | 'isActive': is_active, | ||||
'description': description, | 'description': description, | ||||
}) | }) | ||||
# If the current working copy state is not the head of a branch and there is | # Add virtual markers for the current commit state and current branch state | ||||
# also no active bookmark, add a virtual marker for it so callers can figure | # so callers can figure out exactly where we are. | ||||
# out exactly where we are. | |||||
# Common cases where this matters include: | |||||
# You run "hg update 123" to update to an older revision. Your working | |||||
# copy commit will not be a branch head or a bookmark. | |||||
# You run "hg branch X" to create a new branch, but have not made any commits | |||||
# yet. Your working copy branch will not be reflected in any commits. | |||||
markers.append({ | |||||
'type': 'branch-state', | |||||
'name': current_name, | |||||
'node': None, | |||||
'isActive': True, | |||||
'isClosed': False, | |||||
'isTip': False, | |||||
'description': None, | |||||
}) | |||||
if not saw_active: | |||||
markers.append({ | markers.append({ | ||||
'type': 'commit', | 'type': 'commit-state', | ||||
'name': None, | 'name': None, | ||||
'node': node.hex(active_node), | 'node': node.hex(active_node), | ||||
'isActive': False, | 'isActive': True, | ||||
'isClosed': False, | 'isClosed': False, | ||||
'isTip': False, | 'isTip': False, | ||||
'isCurrent': True, | |||||
'description': repo[b'.'].description(), | 'description': repo[b'.'].description(), | ||||
}) | }) | ||||
return markers | return markers | ||||
def remotemarkers(ui, repo, source, opts): | def remotemarkers(ui, repo, source, opts): | ||||
# Disable status output from fetching a remote. | # Disable status output from fetching a remote. | ||||
ui.quiet = True | ui.quiet = True | ||||
markers = [] | markers = [] | ||||
Show All 30 Lines |