Created
November 5, 2018 17:49
-
-
Save tomprince/b34424801f7daa5edc80d90028e8c09d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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