[PATCH 4 of 9] localrepo: add findbyrevnum for convenience
Yuya Nishihara
yuya at tcha.org
Sun Mar 29 23:45:45 CDT 2015
On Mon, 30 Mar 2015 03:34:26 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1427653752 -32400
> # Mon Mar 30 03:29:12 2015 +0900
> # Node ID efa05b47238ba2a0bca69cd40b8e2e1aed3a2cf2
> # Parent 5f035c783b0443fabc15e773af176c7ef092c1de
> localrepo: add findbyrevnum for convenience
>
> This allows to use "context.findbyrevnum()" easily, without additional
> importing "context".
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1900,6 +1900,21 @@ class localrepository(object):
> fp.close()
> return self.pathto(fp.name[len(self.root) + 1:])
>
> + def findbyrevnum(self, revnum, abort=False):
> + """Find the revision by revision number in this repository
> +
> + ``revnum`` should be ``int``. All negative values other than
> + ``-1`` (as null revision) are treated as invalid revision number.
> +
> + This returns ``(node, revnum)`` tuple, if the revision
> + corresponded to the specified ``revnum`` is found. If that
> + revision is hidden one, this raises FilteredRepoLookupError.
> +
> + Other wise, this returns ``None`` (or raises RepoLookupError if
> + ``abort``).
> + """
> + return context.findbyrevnum(self, revnum, abort=abort)
I think findbyrevnum() can be moved to scmutil to avoid adding new methods
to localrepository.
More information about the Mercurial-devel
mailing list