On Sat, 25 Feb 2017 10:05:58 +0100, Denis Laxalde wrote: > # HG changeset patch > # User Denis Laxalde <denis.laxa...@logilab.fr> > # Date 1487957948 -3600 > # Fri Feb 24 18:39:08 2017 +0100 > # Node ID 17c6195ce42f3cbb47cee53aeb4e6a4e5074878a > # Parent abb92b3d370e116b29eba4d2e3154e9691c8edbb > # Available At https://hg.logilab.org/users/dlaxalde/hg > # hg pull https://hg.logilab.org/users/dlaxalde/hg -r > 17c6195ce42f > # EXP-Topic linerange-log/hgweb-filelog > revset: factor out linerange processing into a utility function
> diff --git a/mercurial/util.py b/mercurial/util.py > --- a/mercurial/util.py > +++ b/mercurial/util.py > @@ -2122,6 +2122,27 @@ def unitcountfn(*unittable): > > return go > > +def processlinerange(fromline, toline): > + """Check that linerange <fromline>:<toline> makes sense and return a > + 0-based range. > + > + >>> processlinerange(10, 20) > + (9, 20) > + >>> processlinerange(2, 1) > + Traceback (most recent call last): > + ... > + ValueError: line range must be positive > + >>> processlinerange(0, 5) > + Traceback (most recent call last): > + ... > + ValueError: fromline must be strictly positive > + """ > + if toline - fromline < 0: > + raise ValueError(_("line range must be positive")) > + if fromline < 1: > + raise ValueError(_("fromline must be strictly positive")) > + return fromline - 1, toline Just a nit. Can we just raise ParseError? Carrying non-ascii bytes over Python's standard exception might get surprising in future since the message should be unicode on Python 3. _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel