<div dir="ltr"><div>Hi,</div><div><br></div><div>I'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 "<path>:<args>", where <path> is an existing path to a repository.</div>
<div>Internally, it will have a mapping of <path>:<cached stuff>, 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 <path> 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 <args>. We'd like to pull the repo object specified by that, rather than the one by <path>, so looking at <path> won'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'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 <path> before calling dispatch so things like relative paths work as expected.</div>
<div>Another thing is the local ui, I'd like to keep that in the cache as well.</div></div><div><br></div><div>Here's how a query to cmd server might look like:</div><div><br></div><div>query <"/repos/foo":"-R ../bundle log"> sent to the cmd server -> </div>
<div>chdir "/repos/foo" -></div><div>check if "/repos/foo" is in the cache (for the ui objects, the repo is not pulled now) -></div><div>suppose it's not, call dispatch.dispatch, with the args -></div>
<div>dispatch creates ui, lui objects, puts them in the request before modifying them (via --config for example) -></div><div>dispatch infers "/repos/bundle" to be the path to the repository -></div><div>calls request.getrepo("/repos/bundle") -> returns None -></div>
<div>creates a bundlerepository -></div><div>puts it in the request, with the inferred path -></div><div>runs command, dispatch returns -></div><div>cmd server checks if it already has a repo/ui for the inferred path, since it doesn'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 <"/repos/foo":"-R ../bundle log"> sent to the cmd server -> </div>
<div>chdir "/repos/foo" -></div><div>check if "/repos/foo" is in the cache -></div><div>it is, call dispatch.dispatch, with the args + ui -></div><div>dispatch infers "/repos/bundle" to be the path to the repository -></div>
<div>calls request.getrepo("/repos/bundle") -> returns a bundlerepo -></div><div>runs command, dispatch returns -></div><div>cmd server checks the cache for the inferred path, doesn't set anything</div>
</div><div><br></div><div>It's a bit rough, but that's what I have in mind atm.</div><div><br></div><div>Opinions are appreciated, thanks.</div></div>