Show More
@@ -981,16 +981,9 b' def followlines(repo, subset, x):' | |||
|
981 | 981 | rev = revs.last() |
|
982 | 982 | |
|
983 | 983 | pat = getstring(args['file'], _("followlines requires a pattern")) |
|
984 | if not matchmod.patkind(pat): | |
|
985 | fname = pathutil.canonpath(repo.root, repo.getcwd(), pat) | |
|
986 | else: | |
|
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 | ||
|
984 | # i18n: "followlines" is a keyword | |
|
985 | msg = _("followlines expects exactly one file") | |
|
986 | fname = scmutil.parsefollowlinespattern(repo, rev, pat, msg) | |
|
994 | 987 | # i18n: "followlines" is a keyword |
|
995 | 988 | lr = getrange(args['lines'][0], _("followlines expects a line range")) |
|
996 | 989 | fromline, toline = [getinteger(a, _("line range bounds must be integers")) |
@@ -567,6 +567,20 b' def matchfiles(repo, files, badfn=None):' | |||
|
567 | 567 | '''Return a matcher that will efficiently match exactly these files.''' |
|
568 | 568 | return matchmod.exact(repo.root, repo.getcwd(), files, badfn=badfn) |
|
569 | 569 | |
|
570 | def parsefollowlinespattern(repo, rev, pat, msg): | |
|
571 | """Return a file name from `pat` pattern suitable for usage in followlines | |
|
572 | logic. | |
|
573 | """ | |
|
574 | if not matchmod.patkind(pat): | |
|
575 | return pathutil.canonpath(repo.root, repo.getcwd(), pat) | |
|
576 | else: | |
|
577 | ctx = repo[rev] | |
|
578 | m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=ctx) | |
|
579 | files = [f for f in ctx if m(f)] | |
|
580 | if len(files) != 1: | |
|
581 | raise error.ParseError(msg) | |
|
582 | return files[0] | |
|
583 | ||
|
570 | 584 | def origpath(ui, repo, filepath): |
|
571 | 585 | '''customize where .orig files are created |
|
572 | 586 |
General Comments 0
You need to be logged in to leave comments.
Login now