<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Calibri;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">I think it would also be very cool to introduce file:// protocol to load revsets from files.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-family:Calibri;color:black">From: </span>
</b><span style="font-family:Calibri;color:black">Mercurial-devel <mercurial-devel-bounces@mercurial-scm.org> on behalf of Gregory Szorc <gregory.szorc@gmail.com><br>
<b>Date: </b>Thursday, July 14, 2016 at 7:50 AM<br>
<b>To: </b>Matt Mackall <mpm@selenic.com><br>
<b>Cc: </b>mercurial-devel <mercurial-devel@mercurial-scm.org><br>
<b>Subject: </b>Re: [RFC] external revsets and templates<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">On Wed, Jul 13, 2016 at 11:37 AM, Matt Mackall <<a href="mailto:mpm@selenic.com" target="_blank">mpm@selenic.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">These are features we've been playing with a bit in the new review flow:<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_wiki_AcceptProcess-23Setting-5Fup-5Fthe-5Frevset-5Fhelper&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=qyqfG10KH1WJTuRVunmTbnh956UHjSnZnFqpTOK7SHA&s=6r62jkKn1Z5fVpBtS5P5QVG6WhAxf8w4fh5wMwTFQQU&e=" target="_blank">https://www.mercurial-scm.org/wiki/AcceptProcess#Setting_up_the_revset_helper</a><br>
<br>
These have been extremely useful and I'd like to make them core feature, so I'd<br>
like to further iron out the syntax and feature set before moving forward.<br>
<br>
Currently, external revsets works like this:<br>
<br>
 [extrevset]<br>
 foo = shell:some-shell-command<br>
<br>
Then some-shell-command is expected to return a series of Mercurial identifiers<br>
(hash, rev, tag..), one per line. When "foo" is used in a revset, Mercurial<br>
calls the shell command, looks up each result, and returns a corresponding<br>
revset.<br>
<br>
I think we should also be able to support arguments:<br>
<br>
 [extrevset]<br>
 cvs = shell:/path/to/lookup-cvs-rev $1<br>
<br>
Then we can do:<br>
<br>
 $ hg log -r "cvs(123)"<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Cool idea with lots of potential for quick hacks.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">One item we may want to bikeshed is scaling. We know from existing revsets that lazy evaluation helps.<br>
<br>
Presumably we could lazy read process output so e.g. if we're only interested in 10 items the command doesn't spend a long time printing 1M revisions. I /think/ by keeping the size of the inter-process pipe in check we can cause premature blocking in the invoked
 process to throttle how much work it is doing.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">What about the scenario where we want to examine a limited set? e.g. "-r not public() & externalset()". Should the external process read candidate revisions from stdin and filter so it doesn't do too much work? I /think/ this behavior could
 be optional.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><br>
Also, we should allow data sources that are arbitrary URLs:<br>
<br>
 [extrevset]<br>
 tested = url:<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__build.corp.example.com_hg-2Dtested.dat&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=qyqfG10KH1WJTuRVunmTbnh956UHjSnZnFqpTOK7SHA&s=SokzxzqKUd_-SL2myw7e1_1KOfMExyvjSxg_L09bceI&e=" target="_blank">http://build.corp.example.com/hg-tested.dat</a><br>
 good = url:<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__build.corp.example.com_hg-2Dpassed.dat&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=qyqfG10KH1WJTuRVunmTbnh956UHjSnZnFqpTOK7SHA&s=IGUMi7KlwlZVo-lZZ_4xIR_Nw4p5SyaU3UIe5ERL_-g&e=" target="_blank">http://build.corp.example.com/hg-passed.dat</a><br>
 deployed = url:<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__prod.example.com_hg-2Ddeployed.cgi&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=qyqfG10KH1WJTuRVunmTbnh956UHjSnZnFqpTOK7SHA&s=O7EPdeLDPtw1HbDoNqI7dcqIsOEjYJOkN16rGdLEUBo&e=" target="_blank">http://prod.example.com/hg-deployed.cgi</a><br>
 fulltext = url:<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__hg&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=qyqfG10KH1WJTuRVunmTbnh956UHjSnZnFqpTOK7SHA&s=gucwGJ_QvTKtSIADs4SnGx4k0f7wcqdoYSODKooIP1k&e=" target="_blank">http://hg</a><br>
-<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__fulltext-2Ddb.example.com_query-3Fstring-3D-241&d=CwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=qyqfG10KH1WJTuRVunmTbnh956UHjSnZnFqpTOK7SHA&s=jCU3Y885nzi-kJGxe8_QoukY6wcwSQVUrpDZSylfnHI&e=" target="_blank">fulltext-db.example.com/query?string=$1</a><br>
<br>
..which will allow very easy integration with complex production automation. The<br>
url: piece might be redundant here? We might also allow calling Python, similar<br>
to how we allow it in hooks.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">That's really hot. We probably want to bikeshed HTTP semantics a bit. e.g. how do you differentiate between an empty result and a server error. HTTP status code? If the server streams results via chunked transfer and hits a server error
 mid stream, how do we detect that (HTTP 200 has already been issued). Do we need some kind of light protocol in the content stream? That would be nice. But it does take away the simplicity. I suppose it could be optional for those wishing to opt into stronger
 guarantees. e.g. "//HGREVSETBEGIN\nrev0\nrev1\n//HGREVSETEND."<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><br>
My current implementation has no caching, which is usually fine. My plan is to<br>
cache the non-argument version for the repo object lifetime and leave the<br>
argument version uncached, but the chg use case might need a better plan.<br>
<br>
<br>
External templates are very similar and allow adding data to the display side<br>
(including in hgweb!).<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">As cool as this sounds, the security and latency aspects of this scare me. But since this is something you have to explicitly configure, a server operator can make reasonable judgements, I suppose.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Instead of simply getting a list of revisions, it gets a<br>
list of revision[space]description pairs. For instance, I can currently get a<br>
list of reviewers on draft changesets thusly:<br>
<br>
 [exttemplate]<br>
 reviewers = shell:ssh mercurial-cm accept/reviewed<br>
<br>
..and simply add {reviewers} to my log template. Again, this can be used for<br>
many things, like displaying number of test failures, deployment status,<br>
mappings to other SCMs or review tools.<br>
<br>
Caching here is more important as templates get evaluated once per changeset. My<br>
current hack keeps a global cache, but caching per repo is probably saner.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Passing unbound lists of revisions into HTTP seemingly requires a custom protocol or sending multiple requests.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Also, new process creation on Windows is ~10x slower than POSIX systems. If you spawn hundreds or even dozens of processes on Windows you are going to have a bad time. Process re-use would be really nice. But I worry that requires too much
 of a "protocol" and raises the barrier to entry too much. Perhaps we need separate "namespaces" for processes that talk a protocol versus ones that do single process per item?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><br>
Because the data format for external templates is a superset of the one used by<br>
external revsets, the same source can probably be shared in the cases where it<br>
makes sense.<br>
<br>
Thoughts? <o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This is a really cool idea that will allow people to extend Mercurial's querying and formatting abilities (2 major selling points over e.g. Git) without requiring an extension. That's huge. The existing proposal should work well on most
 repos. Of course, I have to support a very large repo and Windows, so I naturally have scaling concerns. But I suppose if you need the perf you can write an extension.<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>