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