May be given a single identifier, a sequence of identifiers, or the
special symbols "head" or "base". The result is a tuple of one
- or more identifiers.
+ or more identifiers, or an empty tuple in the case of "base".
+
+ In the cases where 'head', 'heads' is requested and the
+ revision map is empty, returns an empty tuple.
Supports partial identifiers, where the given identifier
is matched against all identifiers that start with the given
else:
return self._real_heads, branch_label
elif id_ == 'head':
- return (self.get_current_head(branch_label), ), branch_label
+ current_head = self.get_current_head(branch_label)
+ if current_head:
+ return (current_head, ), branch_label
+ else:
+ return (), branch_label
elif id_ == 'base' or id_ is None:
return (), branch_label
else:
isinstance(lower, compat.string_types) and lower.endswith('@base')
uppers = self.get_revisions(upper)
+ if not uppers and not requested_lowers:
+ raise StopIteration()
+
upper_ancestors = set(self._get_ancestor_nodes(uppers, check=True))
if limit_to_lower_branch:
)
+class EmptyMapTest(DownIterateTest):
+ # see issue #258
+
+ def setUp(self):
+ self.map = RevisionMap(
+ lambda: []
+ )
+
+ def test_iterate(self):
+ self._assert_iteration(
+ "head", "base",
+ []
+ )
+
+
class LabeledBranchTest(DownIterateTest):
def test_dupe_branch_collection(self):
fn = lambda: [
self.map._iterate_revisions('d2cb2', 'b1')
)
- def test_wrong_direction_to_base(self):
+ def test_wrong_direction_to_base_as_none(self):
+ # this needs to raise and not just return empty iteration
+ # as added by #258
assert_raises_message(
RevisionError,
r"Revision d1cb1 is not an ancestor of revision base",
self.map._iterate_revisions(None, 'd1cb1')
)
+ def test_wrong_direction_to_base_as_empty(self):
+ # this needs to raise and not just return empty iteration
+ # as added by #258
assert_raises_message(
RevisionError,
r"Revision d1cb1 is not an ancestor of revision base",