Continuing the transition away from tuples.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/dagutil.py (20 lines) |
Status | Author | Revision | |
---|---|---|---|
Accepted | indygreg | ||
Accepted | indygreg | ||
Accepted | indygreg | ||
Accepted | indygreg | ||
Accepted | indygreg | ||
Accepted | indygreg | ||
Accepted | indygreg | ||
Accepted | indygreg | ||
Accepted | indygreg | ||
Accepted | indygreg | ||
Needs Revision | indygreg | ||
Needs Revision | indygreg | ||
Needs Revision | indygreg | ||
Accepted | indygreg | ||
Needs Revision | indygreg | ||
Closed | indygreg |
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 _externalize(self, ix): | def _externalize(self, ix): | ||||
return self._revlog.index[ix][7] | return self._revlog.index[ix].node | ||||
def _externalizeall(self, ixs): | def _externalizeall(self, ixs): | ||||
idx = self._revlog.index | idx = self._revlog.index | ||||
return [idx[i][7] for i in ixs] | return [idx[i].node for i in ixs] | ||||
def _internalize(self, id): | def _internalize(self, id): | ||||
ix = self._revlog.rev(id) | ix = self._revlog.rev(id) | ||||
if ix == nullrev: | if ix == nullrev: | ||||
raise LookupError(id, self._revlog.indexfile, _('nullid')) | raise LookupError(id, self._revlog.indexfile, _('nullid')) | ||||
return ix | return ix | ||||
def _internalizeall(self, ids, filterunknown): | def _internalizeall(self, ids, filterunknown): | ||||
rl = self._revlog | rl = self._revlog | ||||
def _getheads(self): | def _getheads(self): | ||||
return [r for r in self._revlog.headrevs() if r != nullrev] | return [r for r in self._revlog.headrevs() if r != nullrev] | ||||
def parents(self, ix): | def parents(self, ix): | ||||
rlog = self._revlog | rlog = self._revlog | ||||
idx = rlog.index | idx = rlog.index | ||||
revdata = idx[ix] | revdata = idx[ix] | ||||
prev = revdata[5] | prev = revdata.p1rev | ||||
if prev != nullrev: | if prev != nullrev: | ||||
prev2 = revdata[6] | prev2 = revdata.p2rev | ||||
if prev2 == nullrev: | if prev2 == nullrev: | ||||
return [prev] | return [prev] | ||||
return [prev, prev2] | return [prev, prev2] | ||||
prev2 = revdata[6] | prev2 = revdata.p2rev | ||||
if prev2 != nullrev: | if prev2 != nullrev: | ||||
return [prev2] | return [prev2] | ||||
return [] | return [] | ||||
def inverse(self): | def inverse(self): | ||||
if self._inverse is None: | if self._inverse is None: | ||||
self._inverse = inverserevlogdag(self) | self._inverse = inverserevlogdag(self) | ||||
return self._inverse | return self._inverse | ||||
def ancestorset(self, starts, stops=None): | def ancestorset(self, starts, stops=None): | ||||
rlog = self._revlog | rlog = self._revlog | ||||
idx = rlog.index | idx = rlog.index | ||||
if stops: | if stops: | ||||
stops = set(stops) | stops = set(stops) | ||||
else: | else: | ||||
stops = set() | stops = set() | ||||
seen = set() | seen = set() | ||||
pending = list(starts) | pending = list(starts) | ||||
while pending: | while pending: | ||||
rev = pending.pop() | rev = pending.pop() | ||||
if rev not in seen and rev not in stops: | if rev not in seen and rev not in stops: | ||||
seen.add(rev) | seen.add(rev) | ||||
revdata = idx[rev] | revdata = idx[rev] | ||||
for i in [5, 6]: | |||||
prev = revdata[i] | for prev in (revdata.p1rev, revdata.p2rev): | ||||
if prev != nullrev: | if prev != nullrev: | ||||
pending.append(prev) | pending.append(prev) | ||||
return seen | return seen | ||||
def headsetofconnecteds(self, ixs): | def headsetofconnecteds(self, ixs): | ||||
if not ixs: | if not ixs: | ||||
return set() | return set() | ||||
rlog = self._revlog | rlog = self._revlog | ||||
idx = rlog.index | idx = rlog.index | ||||
headrevs = set(ixs) | headrevs = set(ixs) | ||||
for rev in ixs: | for rev in ixs: | ||||
revdata = idx[rev] | revdata = idx[rev] | ||||
for i in [5, 6]: | for prev in (revdata.p1rev, revdata.p2rev): | ||||
prev = revdata[i] | |||||
if prev != nullrev: | if prev != nullrev: | ||||
headrevs.discard(prev) | headrevs.discard(prev) | ||||
assert headrevs | assert headrevs | ||||
return headrevs | return headrevs | ||||
def linearize(self, ixs): | def linearize(self, ixs): | ||||
'''linearize and topologically sort a list of revisions | '''linearize and topologically sort a list of revisions | ||||
def _walkto(self, walkto): | def _walkto(self, walkto): | ||||
rev = self._walkfrom | rev = self._walkfrom | ||||
cs = self._children | cs = self._children | ||||
roots = self._roots | roots = self._roots | ||||
idx = self._revlog.index | idx = self._revlog.index | ||||
while rev >= walkto: | while rev >= walkto: | ||||
data = idx[rev] | data = idx[rev] | ||||
isroot = True | isroot = True | ||||
for prev in [data[5], data[6]]: # parent revs | for prev in [data.p1rev, data.p2rev]: # parent revs | ||||
if prev != nullrev: | if prev != nullrev: | ||||
cs.setdefault(prev, []).append(rev) | cs.setdefault(prev, []).append(rev) | ||||
isroot = False | isroot = False | ||||
if isroot: | if isroot: | ||||
roots.append(rev) | roots.append(rev) | ||||
rev -= 1 | rev -= 1 | ||||
self._walkfrom = rev | self._walkfrom = rev | ||||