##// END OF EJS Templates
revset: extract a parsefollowlinespattern helper function...
Denis Laxalde -
r34855:39b094e4 default
parent child Browse files
Show More
@@ -981,16 +981,9 def followlines(repo, subset, x):
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):
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
984 # i18n: "followlines" is a keyword
991 raise error.ParseError(_("followlines expects exactly one file"))
985 msg = _("followlines expects exactly one file")
992 fname = files[0]
986 fname = scmutil.parsefollowlinespattern(repo, rev, pat, msg)
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"))
@@ -567,6 +567,20 def matchfiles(repo, files, badfn=None):
567 '''Return a matcher that will efficiently match exactly these files.'''
567 '''Return a matcher that will efficiently match exactly these files.'''
568 return matchmod.exact(repo.root, repo.getcwd(), files, badfn=badfn)
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 def origpath(ui, repo, filepath):
584 def origpath(ui, repo, filepath):
571 '''customize where .orig files are created
585 '''customize where .orig files are created
572
586
General Comments 0
You need to be logged in to leave comments. Login now