54
55
raise NotImplementedError(self.report_results)
57
def scan_branch(branch, needed_refs, to_unlock):
58
def scan_branch(branch, needed_refs, exit_stack):
58
59
"""Scan a branch for refs.
60
61
:param branch: The branch to schedule for checking.
61
62
:param needed_refs: Refs we are accumulating.
62
:param to_unlock: The unlock list accumulating.
63
:param exit_stack: The exit stack accumulating.
64
65
note(gettext("Checking branch at '%s'.") % (branch.base,))
66
to_unlock.append(branch)
66
exit_stack.enter_context(branch.lock_read())
67
67
branch_refs = branch._get_check_refs()
68
68
for ref in branch_refs:
69
69
reflist = needed_refs.setdefault(ref, [])
70
70
reflist.append(branch)
73
def scan_tree(base_tree, tree, needed_refs, to_unlock):
73
def scan_tree(base_tree, tree, needed_refs, exit_stack):
74
74
"""Scan a tree for refs.
76
76
:param base_tree: The original tree check opened, used to detect duplicate
78
78
:param tree: The tree to schedule for checking.
79
79
:param needed_refs: Refs we are accumulating.
80
:param to_unlock: The unlock list accumulating.
80
:param exit_stack: The exit stack accumulating.
82
82
if base_tree is not None and tree.basedir == base_tree.basedir:
84
84
note(gettext("Checking working tree at '%s'.") % (tree.basedir,))
86
to_unlock.append(tree)
85
exit_stack.enter_context(tree.lock_read())
87
86
tree_refs = tree._get_check_refs()
88
87
for ref in tree_refs:
89
88
reflist = needed_refs.setdefault(ref, [])
102
101
except errors.NotBranchError:
103
102
base_tree = branch = repo = None
104
with cleanup.ExitStack() as exit_stack:
108
106
if base_tree is not None:
109
107
# If the tree is a lightweight checkout we won't see it in
110
108
# repo.find_branches - add now.
112
scan_tree(None, base_tree, needed_refs, to_unlock)
110
scan_tree(None, base_tree, needed_refs, exit_stack)
113
111
branch = base_tree.branch
114
112
if branch is not None:
115
113
# We have a branch
130
127
except (errors.NotLocalUrl, errors.NoWorkingTree):
133
scan_tree(base_tree, tree, needed_refs, to_unlock)
130
scan_tree(base_tree, tree, needed_refs, exit_stack)
135
scan_branch(branch, needed_refs, to_unlock)
132
scan_branch(branch, needed_refs, exit_stack)
136
133
if do_branch and not branches:
137
134
note(gettext("No branch found at specified location."))
138
135
if do_tree and base_tree is None and not saw_tree: