The previous commit removed the last consumer.
.. api:: removed internalize() and internalizeall() from dagutil
Use .rev(node) on storage objects to convert nodes to revisions.
hg-reviewers |
The previous commit removed the last consumer.
.. api:: removed internalize() and internalizeall() from dagutil
Use .rev(node) on storage objects to convert nodes to revisions.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/dagutil.py (28 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Aug 16 2018, 3:51 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | D4330 dagutil: remove module | |
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg |
# dagutil.py - dag utilities for mercurial | # dagutil.py - dag utilities for mercurial | ||||
# | # | ||||
# Copyright 2010 Benoit Boissinot <bboissin@gmail.com> | # Copyright 2010 Benoit Boissinot <bboissin@gmail.com> | ||||
# and Peter Arrenbrecht <peter@arrenbrecht.ch> | # and Peter Arrenbrecht <peter@arrenbrecht.ch> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
from .i18n import _ | |||||
from .node import nullrev | from .node import nullrev | ||||
class basedag(object): | class basedag(object): | ||||
'''generic interface for DAGs | '''generic interface for DAGs | ||||
terms: | terms: | ||||
"ix" (short for index) identifies a nodes internally, | "ix" (short for index) identifies a nodes internally, | ||||
"id" identifies one externally. | "id" identifies one externally. | ||||
''' | ''' | ||||
subset of connected list of ixs so that no node has a descendant in it | subset of connected list of ixs so that no node has a descendant in it | ||||
By "connected list" we mean that if an ancestor and a descendant are in | By "connected list" we mean that if an ancestor and a descendant are in | ||||
the list, then so is at least one path connecting them. | the list, then so is at least one path connecting them. | ||||
''' | ''' | ||||
raise NotImplementedError | raise NotImplementedError | ||||
def internalize(self, id): | |||||
'''return a node ix''' | |||||
return self._internalize(id) | |||||
def internalizeall(self, ids, filterunknown=False): | |||||
'''return a list of (or set if given a set) of node ixs''' | |||||
ixs = self._internalizeall(ids, filterunknown) | |||||
if isinstance(ids, set): | |||||
return set(ixs) | |||||
return list(ixs) | |||||
class genericdag(basedag): | class genericdag(basedag): | ||||
'''generic implementations for DAGs''' | '''generic implementations for DAGs''' | ||||
def ancestorset(self, starts, stops=None): | def ancestorset(self, starts, stops=None): | ||||
if stops: | if stops: | ||||
stops = set(stops) | stops = set(stops) | ||||
else: | else: | ||||
stops = set() | stops = set() | ||||
def nodeset(self): | def nodeset(self): | ||||
return self._nodeset | return self._nodeset | ||||
def heads(self): | def heads(self): | ||||
if self._heads is None: | if self._heads is None: | ||||
self._heads = self._getheads() | self._heads = self._getheads() | ||||
return self._heads | return self._heads | ||||
def _internalize(self, id): | |||||
ix = self._revlog.rev(id) | |||||
if ix == nullrev: | |||||
raise LookupError(id, self._revlog.indexfile, _('nullid')) | |||||
return ix | |||||
def _internalizeall(self, ids, filterunknown): | |||||
rl = self._revlog | |||||
if filterunknown: | |||||
return [r for r in map(rl.nodemap.get, ids) | |||||
if (r is not None | |||||
and r != nullrev | |||||
and r not in rl.filteredrevs)] | |||||
return [self._internalize(i) for i in ids] | |||||
class revlogdag(revlogbaseddag): | class revlogdag(revlogbaseddag): | ||||
'''dag interface to a revlog''' | '''dag interface to a revlog''' | ||||
def __init__(self, revlog, localsubset=None): | def __init__(self, revlog, localsubset=None): | ||||
revlogbaseddag.__init__(self, revlog, set(revlog)) | revlogbaseddag.__init__(self, revlog, set(revlog)) | ||||
self._heads = localsubset | self._heads = localsubset | ||||
def _getheads(self): | def _getheads(self): |