comparison mercurial/revset.py @ 34854:39b094e4ae2c

revset: extract a parsefollowlinespattern helper function We'll need the same logic in forthcoming changeset to handle --line-range option in 'hg log' command. The function lives in scmutil.py (rather than util.py) as it uses match and pathutil modules.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Wed, 04 Oct 2017 15:27:43 +0200
parents 2c3b8fa3211b
children 0d27685b4a2f
comparison
equal deleted inserted replaced
34853:962f7df21a73 34854:39b094e4ae2c
979 # i18n: "followlines" is a keyword 979 # i18n: "followlines" is a keyword
980 _("followlines expects exactly one revision")) 980 _("followlines expects exactly one revision"))
981 rev = revs.last() 981 rev = revs.last()
982 982
983 pat = getstring(args['file'], _("followlines requires a pattern")) 983 pat = getstring(args['file'], _("followlines requires a pattern"))
984 if not matchmod.patkind(pat): 984 # i18n: "followlines" is a keyword
985 fname = pathutil.canonpath(repo.root, repo.getcwd(), pat) 985 msg = _("followlines expects exactly one file")
986 else: 986 fname = scmutil.parsefollowlinespattern(repo, rev, pat, msg)
987 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[rev])
988 files = [f for f in repo[rev] if m(f)]
989 if len(files) != 1:
990 # i18n: "followlines" is a keyword
991 raise error.ParseError(_("followlines expects exactly one file"))
992 fname = files[0]
993
994 # i18n: "followlines" is a keyword 987 # i18n: "followlines" is a keyword
995 lr = getrange(args['lines'][0], _("followlines expects a line range")) 988 lr = getrange(args['lines'][0], _("followlines expects a line range"))
996 fromline, toline = [getinteger(a, _("line range bounds must be integers")) 989 fromline, toline = [getinteger(a, _("line range bounds must be integers"))
997 for a in lr] 990 for a in lr]
998 fromline, toline = util.processlinerange(fromline, toline) 991 fromline, toline = util.processlinerange(fromline, toline)