mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 14:58:03 +03:00
kill "extdata()" revset/template func
Summary: I don't think we use this, and it includes a "shell:" gateway to invoke arbitrary commands. Reviewed By: quark-zju Differential Revision: D42158009 fbshipit-source-id: 514da6fdf9b1644db98d48fe4a9aaca4c6096515
This commit is contained in:
parent
96b767efde
commit
3d57f7816c
@ -313,7 +313,6 @@ coreconfigitem("experimental", "dynmatcher", default=False)
|
||||
coreconfigitem("experimental", "uncommitondirtywdir", default=True)
|
||||
coreconfigitem("experimental", "xdiff", default=True)
|
||||
coreconfigitem("extensions", ".*", default=None, generic=True)
|
||||
coreconfigitem("extdata", ".*", default=None, generic=True)
|
||||
coreconfigitem("format", "aggressivemergedeltas", default=False)
|
||||
coreconfigitem(
|
||||
"format", "cgdeltabase", default="default" # changegroup.CFG_CGDELTA_DEFAULT
|
||||
|
@ -1091,20 +1091,6 @@ def contentdivergent(repo, subset, x):
|
||||
return subset & contentdivergent
|
||||
|
||||
|
||||
@predicate("extdata(source)", safe=False, weight=100)
|
||||
def extdata(repo, subset, x):
|
||||
"""Changesets in the specified extdata source. (EXPERIMENTAL)"""
|
||||
# i18n: "extdata" is a keyword
|
||||
args = getargsdict(x, "extdata", "source")
|
||||
source = getstring(
|
||||
args.get("source"),
|
||||
# i18n: "extdata" is a keyword
|
||||
_("extdata takes at least 1 string argument"),
|
||||
)
|
||||
data = scmutil.extdatasource(repo, source)
|
||||
return subset & baseset(data, repo=repo)
|
||||
|
||||
|
||||
@predicate("extinct()", safe=True)
|
||||
def extinct(repo, subset, x):
|
||||
"""Obsolete changesets with obsolete descendants only."""
|
||||
|
@ -1205,69 +1205,6 @@ class filecache(object):
|
||||
raise AttributeError(self.name)
|
||||
|
||||
|
||||
def extdatasource(repo, source):
|
||||
"""Gather a map of rev -> value dict from the specified source
|
||||
|
||||
A source spec is treated as a URL, with a special case shell: type
|
||||
for parsing the output from a shell command.
|
||||
|
||||
The data is parsed as a series of newline-separated records where
|
||||
each record is a revision specifier optionally followed by a space
|
||||
and a freeform string value. If the revision is known locally, it
|
||||
is converted to a rev, otherwise the record is skipped.
|
||||
|
||||
Note that both key and value are treated as UTF-8 and converted to
|
||||
the local encoding. This allows uniformity between local and
|
||||
remote data sources.
|
||||
"""
|
||||
|
||||
spec = repo.ui.config("extdata", source)
|
||||
if not spec:
|
||||
raise error.Abort(_("unknown extdata source '%s'") % source)
|
||||
|
||||
data = {}
|
||||
src = proc = None
|
||||
try:
|
||||
if spec.startswith("shell:"):
|
||||
# external commands should be run relative to the repo root
|
||||
cmd = spec[6:]
|
||||
proc = subprocess.Popen(
|
||||
cmd,
|
||||
shell=True,
|
||||
bufsize=-1,
|
||||
close_fds=util.closefds,
|
||||
stdout=subprocess.PIPE,
|
||||
cwd=repo.root,
|
||||
)
|
||||
src = proc.stdout
|
||||
else:
|
||||
# treat as a URL or file
|
||||
src = url.open(repo.ui, spec)
|
||||
for l in src:
|
||||
if b" " in l:
|
||||
k, v = l.strip().split(b" ", 1)
|
||||
else:
|
||||
k, v = l.strip(), b""
|
||||
|
||||
k = k.decode("utf8")
|
||||
try:
|
||||
data[repo[k].rev()] = v.decode("utf8")
|
||||
except (error.LookupError, error.RepoLookupError):
|
||||
pass # we ignore data for nodes that don't exist locally
|
||||
finally:
|
||||
if proc:
|
||||
proc.communicate()
|
||||
if src:
|
||||
src.close()
|
||||
if proc and proc.returncode != 0:
|
||||
raise error.Abort(
|
||||
_("extdata command '%s' failed: %s")
|
||||
% (cmd, util.explainexit(proc.returncode)[0])
|
||||
)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def gdinitconfig(ui):
|
||||
"""helper function to know if a repo should be created as general delta"""
|
||||
# experimental config: format.generaldelta
|
||||
|
@ -737,23 +737,6 @@ def enabled(context, mapping, args):
|
||||
return value
|
||||
|
||||
|
||||
@templatefunc("extdata(source)", argspec="source")
|
||||
def extdata(context, mapping, args):
|
||||
"""Show a text read from the specified extdata source. (EXPERIMENTAL)"""
|
||||
if "source" not in args:
|
||||
# i18n: "extdata" is a keyword
|
||||
raise error.ParseError(_("extdata expects one argument"))
|
||||
|
||||
source = evalstring(context, mapping, args["source"])
|
||||
cache = mapping["cache"].setdefault("extdata", {})
|
||||
ctx = mapping["ctx"]
|
||||
if source in cache:
|
||||
data = cache[source]
|
||||
else:
|
||||
data = cache[source] = scmutil.extdatasource(ctx.repo(), source)
|
||||
return data.get(ctx.rev(), "")
|
||||
|
||||
|
||||
@templatefunc("files(pattern)")
|
||||
def files(context, mapping, args):
|
||||
"""All files of the current changeset matching the pattern. See
|
||||
|
@ -49,7 +49,6 @@ ignorerevnumincompatiblelist = """
|
||||
test-eol-hook.t
|
||||
test-eol-update.t
|
||||
test-export.t
|
||||
test-extdata.t
|
||||
test-fb-ext-copytrace-errormsg.t
|
||||
test-fb-ext-drop.t
|
||||
test-fb-ext-fastannotate-corrupt.t
|
||||
|
@ -1,100 +0,0 @@
|
||||
#chg-compatible
|
||||
|
||||
$ setconfig workingcopy.ruststatus=False
|
||||
$ setconfig devel.segmented-changelog-rev-compat=true
|
||||
$ hg init repo
|
||||
$ cd repo
|
||||
$ for n in 0 1 2 3 4 5 6 7 8 9 10 11; do
|
||||
> echo $n > $n
|
||||
> hg ci -qAm $n
|
||||
> done
|
||||
|
||||
test revset support
|
||||
|
||||
$ readconfig <<'EOF'
|
||||
> [extdata]
|
||||
> filedata = file:extdata.txt
|
||||
> notes = notes.txt
|
||||
> shelldata = shell:cat extdata.txt | grep 2
|
||||
> emptygrep = shell:cat extdata.txt | grep empty
|
||||
> EOF
|
||||
$ cat <<'EOF' > extdata.txt
|
||||
> 2 another comment on 2
|
||||
> 3
|
||||
> EOF
|
||||
$ cat <<'EOF' > notes.txt
|
||||
> f6ed this change is great!
|
||||
> e834 this is buggy :(
|
||||
> 0625 first post
|
||||
> bogusnode gives no error
|
||||
> a ambiguous node gives no error
|
||||
> EOF
|
||||
|
||||
$ hg log -qr "extdata(filedata)"
|
||||
f6ed99a58333
|
||||
9de260b1e88e
|
||||
$ hg log -qr "extdata(shelldata)"
|
||||
f6ed99a58333
|
||||
|
||||
test weight of extdata() revset
|
||||
|
||||
$ hg debugrevspec -p optimized "extdata(filedata) & 3"
|
||||
* optimized:
|
||||
(andsmally
|
||||
(func
|
||||
(symbol 'extdata')
|
||||
(symbol 'filedata'))
|
||||
(symbol '3'))
|
||||
3
|
||||
|
||||
test non-zero exit of shell command
|
||||
|
||||
$ hg log -qr "extdata(emptygrep)"
|
||||
abort: extdata command 'cat extdata.txt | grep empty' failed: exited with status 1
|
||||
[255]
|
||||
|
||||
test bad extdata() revset source
|
||||
|
||||
$ hg log -qr "extdata()"
|
||||
hg: parse error: extdata takes at least 1 string argument
|
||||
[255]
|
||||
$ hg log -qr "extdata(unknown)"
|
||||
abort: unknown extdata source 'unknown'
|
||||
[255]
|
||||
|
||||
test template support:
|
||||
|
||||
$ hg log -r:3 -T "{node|short}{if(extdata('notes'), ' # {extdata('notes')}')}\n"
|
||||
06254b906311 # first post
|
||||
e8342c9a2ed1 # this is buggy :(
|
||||
f6ed99a58333 # this change is great!
|
||||
9de260b1e88e
|
||||
|
||||
test template cache:
|
||||
|
||||
$ hg log -r:3 -T '"{extdata("notes")}" "{extdata("shelldata")}"\n'
|
||||
"first post" ""
|
||||
"this is buggy :(" ""
|
||||
"this change is great!" "another comment on 2"
|
||||
"" ""
|
||||
|
||||
test bad extdata() template source
|
||||
|
||||
$ hg log -T "{extdata()}\n"
|
||||
hg: parse error: extdata expects one argument
|
||||
[255]
|
||||
$ hg log -T "{extdata('unknown')}\n"
|
||||
abort: unknown extdata source 'unknown'
|
||||
[255]
|
||||
|
||||
we don't fix up relative file URLs, but we do run shell commands in repo root
|
||||
|
||||
$ mkdir sub
|
||||
$ cd sub
|
||||
$ hg log -qr "extdata(filedata)"
|
||||
abort: error: $ENOENT$
|
||||
[255]
|
||||
$ hg log -qr "extdata(shelldata)"
|
||||
f6ed99a58333
|
||||
|
||||
$ cd ..
|
Loading…
Reference in New Issue
Block a user