# HG changeset patch # User Gregory Szorc # Date 1530731569 25200 # Node ID f2f9bacf058742456de1066e90933cbc55ca251c # Parent f83600efa1ca13be584abe5707eaa1bde46adb5c manifest: define and implement rev() on manifestlog Various code is accessing repo.manifestlog._revlog - a private attribute. This bypasses our interface and makes it difficult to implement non-revlog manifest storage. This commit adds a rev() method to the manifestlog interface and class and teaches callers to use it. Ideally this method wouldn't exist, as very few consumers should need to resolve the revision number of a manifest. Again, the primary goal of interface work is to establish and use interfaces first and to improve them later. Differential Revision: https://phab.mercurial-scm.org/D3882 diff -r f83600efa1ca -r f2f9bacf0587 mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py Mon Jul 02 11:14:13 2018 -0700 +++ b/mercurial/logcmdutil.py Wed Jul 04 12:12:49 2018 -0700 @@ -228,7 +228,7 @@ if self.ui.debugflag and rev is not None: mnode = ctx.manifestnode() - mrev = self.repo.manifestlog._revlog.rev(mnode) + mrev = self.repo.manifestlog.rev(mnode) self.ui.write(columns['manifest'] % scmutil.formatrevnode(self.ui, mrev, mnode), label='ui.debug log.manifest') diff -r f83600efa1ca -r f2f9bacf0587 mercurial/manifest.py --- a/mercurial/manifest.py Mon Jul 02 11:14:13 2018 -0700 +++ b/mercurial/manifest.py Wed Jul 04 12:12:49 2018 -0700 @@ -1348,6 +1348,9 @@ self._dirmancache.clear() self._revlog.clearcaches() + def rev(self, node): + return self._revlog.rev(node) + @interfaceutil.implementer(repository.imanifestrevisionwritable) class memmanifestctx(object): def __init__(self, manifestlog): diff -r f83600efa1ca -r f2f9bacf0587 mercurial/repository.py --- a/mercurial/repository.py Mon Jul 02 11:14:13 2018 -0700 +++ b/mercurial/repository.py Wed Jul 04 12:12:49 2018 -0700 @@ -922,6 +922,12 @@ def clearcaches(): """Clear caches associated with this collection.""" + def rev(node): + """Obtain the revision number for a binary node. + + Raises ``error.LookupError`` if the node is not known. + """ + class completelocalrepository(interfaceutil.Interface): """Monolithic interface for local repositories. diff -r f83600efa1ca -r f2f9bacf0587 mercurial/templatekw.py --- a/mercurial/templatekw.py Mon Jul 02 11:14:13 2018 -0700 +++ b/mercurial/templatekw.py Wed Jul 04 12:12:49 2018 -0700 @@ -465,7 +465,7 @@ if mnode is None: # just avoid crash, we might want to use the 'ff...' hash in future return - mrev = repo.manifestlog._revlog.rev(mnode) + mrev = repo.manifestlog.rev(mnode) mhex = hex(mnode) mapping = context.overlaymap(mapping, {'rev': mrev, 'node': mhex}) f = context.process('manifest', mapping)