diff --git a/mercurial/revset.py b/mercurial/revset.py
index f3cef19befb10fc88adbdfa0f86c704814809373_bWVyY3VyaWFsL3JldnNldC5weQ==..b61ad01c4e7334e369b0fa6f20983c6bb25c035a_bWVyY3VyaWFsL3JldnNldC5weQ== 100644
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -717,8 +717,6 @@
 
     # i18n: "filelog" is a keyword
     pat = getstring(x, _("filelog requires a pattern"))
-    m = matchmod.match(repo.root, repo.getcwd(), [pat], default='relpath',
-                       ctx=repo[None])
     s = set()
 
     if not matchmod.patkind(pat):
@@ -722,8 +720,8 @@
     s = set()
 
     if not matchmod.patkind(pat):
-        f = m.files()[0]
+        f = pathutil.canonpath(repo.root, repo.getcwd(), pat)
         fl = repo.file(f)
         for fr in fl:
             s.add(fl.linkrev(fr))
     else:
@@ -726,7 +724,8 @@
         fl = repo.file(f)
         for fr in fl:
             s.add(fl.linkrev(fr))
     else:
+        m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[None])
         for f in repo[None]:
             if m(f):
                 fl = repo.file(f)
diff --git a/tests/test-revset.t b/tests/test-revset.t
index f3cef19befb10fc88adbdfa0f86c704814809373_dGVzdHMvdGVzdC1yZXZzZXQudA==..b61ad01c4e7334e369b0fa6f20983c6bb25c035a_dGVzdHMvdGVzdC1yZXZzZXQudA== 100644
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -292,6 +292,12 @@
   $ log 'file("b*")'
   1
   4
+  $ log 'filelog("b")'
+  1
+  4
+  $ log 'filelog("../repo/b")'
+  1
+  4
   $ log 'follow()'
   0
   1