Skip to content

Instantly share code, notes, and snippets.

@tomprince
Created November 5, 2018 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomprince/b34424801f7daa5edc80d90028e8c09d to your computer and use it in GitHub Desktop.
Save tomprince/b34424801f7daa5edc80d90028e8c09d to your computer and use it in GitHub Desktop.
from mercurial import (
registrar,
revset,
)
revsetpredicate = registrar.revsetpredicate()
@revsetpredicate('fromfile()')
def revset_fromfile(repo, subset, x):
arg = revset.getargs(x, 1, 1, 'fromfile requires one argument')
filename = revset.getstring(arg[0], 'fromfile requires a string argument')
with open(filename, 'r') as fp:
lines = [
line for line in fp.readlines()
if not line.strip().startswith("#")
]
m = revset.matchany(repo.ui, lines)
return subset & m(repo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment