<div dir="ltr"><div>Hi,</div><div><br></div><div>I&#39;m thinking on how to add the repo object to dispatch.request.</div><div><br></div><div>Some background: lets assume that the command server answers queries of the form &quot;&lt;path&gt;:&lt;args&gt;&quot;, where &lt;path&gt; is an existing path to a repository.</div>
<div>Internally, it will have a mapping of &lt;path&gt;:&lt;cached stuff&gt;, where cached stuff will include the repo/ui objects and possibly other cache worthy things.</div><div>Once a command arrives, the server checks if &lt;path&gt; exists, and if so it uses the cached repo object by placing it in the request object passed to dispatch.</div>
<div><br></div><div>The tricky part is -R might be one of the &lt;args&gt;. We&#39;d like to pull the repo object specified by that, rather than the one by &lt;path&gt;, so looking at &lt;path&gt; won&#39;t always work..</div>
<div>The logic for inferring the path is in dispatch._dispatch, it does this roughly:</div><div><br></div><div>1) get -R/--repo/--repository from the args</div><div>2) find a .hg dir in the cwd, cd&#39;ing up if necessary (this is done even if (1) returned something, to build the local ui)</div>
<div>3) try to build a repo object from the result</div><div>4) if (3) fails, try to guess a path from the args</div><div><br></div><div>Instead of somehow imitating that in the command server, I think a getrepo(path) function on the request object for _dispatch to use could work better.</div>
<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>Also to consider is the working directory. The command server should probably chdir to &lt;path&gt; before calling dispatch so things like relative paths work as expected.</div>
<div>Another thing is the local ui, I&#39;d like to keep that in the cache as well.</div></div><div><br></div><div>Here&#39;s how a query to cmd server might look like:</div><div><br></div><div>query &lt;&quot;/repos/foo&quot;:&quot;-R ../bundle log&quot;&gt; sent to the cmd server -&gt; </div>
<div>chdir &quot;/repos/foo&quot; -&gt;</div><div>check if &quot;/repos/foo&quot; is in the cache (for the ui objects, the repo is not pulled now) -&gt;</div><div>suppose it&#39;s not, call dispatch.dispatch, with the args -&gt;</div>
<div>dispatch creates ui, lui objects, puts them in the request before modifying them (via --config for example) -&gt;</div><div>dispatch infers &quot;/repos/bundle&quot; to be the path to the repository -&gt;</div><div>calls request.getrepo(&quot;/repos/bundle&quot;) -&gt; returns None -&gt;</div>
<div>creates a bundlerepository -&gt;</div><div>puts it in the request, with the inferred path -&gt;</div><div>runs command, dispatch returns -&gt;</div><div>cmd server checks if it already has a repo/ui for the inferred path, since it doesn&#39;t it takes them and puts them in cache</div>
<div><br></div><div>Next call with cache being hit:</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>query &lt;&quot;/repos/foo&quot;:&quot;-R ../bundle log&quot;&gt; sent to the cmd server -&gt; </div>
<div>chdir &quot;/repos/foo&quot; -&gt;</div><div>check if &quot;/repos/foo&quot; is in the cache -&gt;</div><div>it is, call dispatch.dispatch, with the args + ui -&gt;</div><div>dispatch infers &quot;/repos/bundle&quot; to be the path to the repository -&gt;</div>
<div>calls request.getrepo(&quot;/repos/bundle&quot;) -&gt; returns a bundlerepo -&gt;</div><div>runs command, dispatch returns -&gt;</div><div>cmd server checks the cache for the inferred path, doesn&#39;t set anything</div>
</div><div><br></div><div>It&#39;s a bit rough, but that&#39;s what I have in mind atm.</div><div><br></div><div>Opinions are appreciated, thanks.</div></div>