comparison mercurial/revset.py @ 41561:59638c6fcb70

revset: extract a helper to parse integer range It's getting common. As a first step, this patch adds getintrange() and makes followlines() use it. I wanted to unify the error messages to make the function interface simple, but I failed to phrase it briefly.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 27 Jan 2019 13:18:53 +0900
parents 0bd56c291359
children 1c04894e8fe1
comparison
equal deleted inserted replaced
41560:66399f2e92aa 41561:59638c6fcb70
42 getstring = revsetlang.getstring 42 getstring = revsetlang.getstring
43 getinteger = revsetlang.getinteger 43 getinteger = revsetlang.getinteger
44 getboolean = revsetlang.getboolean 44 getboolean = revsetlang.getboolean
45 getlist = revsetlang.getlist 45 getlist = revsetlang.getlist
46 getrange = revsetlang.getrange 46 getrange = revsetlang.getrange
47 getintrange = revsetlang.getintrange
47 getargs = revsetlang.getargs 48 getargs = revsetlang.getargs
48 getargsdict = revsetlang.getargsdict 49 getargsdict = revsetlang.getargsdict
49 50
50 baseset = smartset.baseset 51 baseset = smartset.baseset
51 generatorset = smartset.generatorset 52 generatorset = smartset.generatorset
1065 1066
1066 pat = getstring(args['file'], _("followlines requires a pattern")) 1067 pat = getstring(args['file'], _("followlines requires a pattern"))
1067 # i18n: "followlines" is a keyword 1068 # i18n: "followlines" is a keyword
1068 msg = _("followlines expects exactly one file") 1069 msg = _("followlines expects exactly one file")
1069 fname = scmutil.parsefollowlinespattern(repo, rev, pat, msg) 1070 fname = scmutil.parsefollowlinespattern(repo, rev, pat, msg)
1070 # i18n: "followlines" is a keyword 1071 fromline, toline = util.processlinerange(
1071 lr = getrange(args['lines'][0], _("followlines expects a line range")) 1072 *getintrange(args['lines'][0],
1072 fromline, toline = [getinteger(a, _("line range bounds must be integers")) 1073 # i18n: "followlines" is a keyword
1073 for a in lr] 1074 _("followlines expects a line range"),
1074 fromline, toline = util.processlinerange(fromline, toline) 1075 _("line range bounds must be integers")))
1075 1076
1076 fctx = repo[rev].filectx(fname) 1077 fctx = repo[rev].filectx(fname)
1077 descend = False 1078 descend = False
1078 if 'descend' in args: 1079 if 'descend' in args:
1079 descend = getboolean(args['descend'], 1080 descend = getboolean(args['descend'],