[PATCH 2 of 2] cat: use the topmost repo when expanding node based format strings for output

Matt Mackall mpm at selenic.com
Wed Apr 16 18:45:30 CDT 2014


On Wed, 2014-04-16 at 00:45 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1395456880 14400
> # Node ID c84cafbba40646fd586f6540599963ef3f9046f5
> # Parent  3c598f1d1b79671030d3e6a550dd8727f3429eb9
> cat: use the topmost repo when expanding node based format strings for output
> 
> Expanding these variables based on the top level repo makes the subrepo seem
> more integrated with the parent, and is probably less surprising to a user that
> executes this command from the top level repo.
> 
> This solution isn't very satisfying because it requires passing two contexts
> around, and it isn't reusable in other places that may need info about the top
> level context that includes the repo.  The alternate attempt I made was to store
> the parent context in the subrepo class when it is initialized.  The svn and git
> subrepos already do this.  That didn't work because the chain that can be
> followed up to the root of hgsubrepo is based on localrepository objects, not
> subrepo instances.  But at least this allows for proper behavior until something
> better can be figured out.

Yes, this is a bit painful. We've got a way to work back to the root
repository object (subrepo._parentrepo), but we don't have a way to pass
the relevant hash around. One hack would be to pass it in opts.

Or we could extend ctx so that when we create a subrepo context, we can
find the parent context. This might be all-around cleaner. I think we
should revision this post-3.0.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list