comparison mercurial/scmutil.py @ 33330:ba43e5ee9c6d

scmutil: make cleanupnodes handle filtered node In some valid usecases, the "mapping" received by scmutil.cleanupnodes have filtered nodes. Use unfiltered repo to access them correctly. The added test case will fail with the old cleanupnodes code. This is important to migrate histedit to use the cleanupnodes API.
author Jun Wu <quark@fb.com>
date Mon, 26 Jun 2017 15:08:37 -0700
parents 53b3a1968aa6
children 4bae3c117b57
comparison
equal deleted inserted replaced
33329:e714159860fd 33330:ba43e5ee9c6d
617 # without a successor, skip that obssolete request since it's 617 # without a successor, skip that obssolete request since it's
618 # unnecessary. That's the "if s or not isobs(n)" check below. 618 # unnecessary. That's the "if s or not isobs(n)" check below.
619 # Also sort the node in topology order, that might be useful for 619 # Also sort the node in topology order, that might be useful for
620 # some obsstore logic. 620 # some obsstore logic.
621 # NOTE: the filtering and sorting might belong to createmarkers. 621 # NOTE: the filtering and sorting might belong to createmarkers.
622 isobs = repo.obsstore.successors.__contains__ 622 # Unfiltered repo is needed since nodes in mapping might be hidden.
623 sortfunc = lambda ns: repo.changelog.rev(ns[0]) 623 unfi = repo.unfiltered()
624 rels = [(repo[n], (repo[m] for m in s)) 624 isobs = unfi.obsstore.successors.__contains__
625 torev = unfi.changelog.rev
626 sortfunc = lambda ns: torev(ns[0])
627 rels = [(unfi[n], (unfi[m] for m in s))
625 for n, s in sorted(mapping.items(), key=sortfunc) 628 for n, s in sorted(mapping.items(), key=sortfunc)
626 if s or not isobs(n)] 629 if s or not isobs(n)]
627 obsolete.createmarkers(repo, rels, operation=operation) 630 obsolete.createmarkers(repo, rels, operation=operation)
628 else: 631 else:
629 from . import repair # avoid import cycle 632 from . import repair # avoid import cycle