Submitter | Sean Farley |
---|---|
Date | July 9, 2013, 9:54 p.m. |
Message ID | <bf0f87c072f524b8e054.1373406873@laptop.local> |
Download | mbox | patch |
Permalink | /patch/1810/ |
State | Changes Requested |
Headers | show |
Comments
On Tue, 2013-07-09 at 16:54 -0500, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # Date 1373322965 18000 > # Mon Jul 08 17:36:05 2013 -0500 > # Node ID bf0f87c072f524b8e054de72af143a0dfc2fcffb > # Parent 2bda9c94e65cff8c6968d82cfc07ec6049b194c0 > context: add a method to convert node to ctx > > I had a hard time deciding where to place this function. Perhaps it could go > into scmutil or util? > > This adds a method as a common place for testing if an object is a context > object, and if it isn't, then to find the corresponding context object in the > repo. How about simply letting the context constructor.. accept contexts? It already accepts everything else.
mpm@selenic.com writes: > On Tue, 2013-07-09 at 16:54 -0500, Sean Farley wrote: >> # HG changeset patch >> # User Sean Farley <sean.michael.farley@gmail.com> >> # Date 1373322965 18000 >> # Mon Jul 08 17:36:05 2013 -0500 >> # Node ID bf0f87c072f524b8e054de72af143a0dfc2fcffb >> # Parent 2bda9c94e65cff8c6968d82cfc07ec6049b194c0 >> context: add a method to convert node to ctx >> >> I had a hard time deciding where to place this function. Perhaps it could go >> into scmutil or util? >> >> This adds a method as a common place for testing if an object is a context >> object, and if it isn't, then to find the corresponding context object in the >> repo. > > How about simply letting the context constructor.. accept contexts? It > already accepts everything else. Heh, fair enough. I'll change it in the next version.
Patch
diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -14,10 +14,15 @@ import obsolete as obsmod import repoview propertycache = util.propertycache +def nodeorctx(repo, node): + if isinstance(node, changectx): + return node + return repo[node] + class changectx(object): """A changecontext object makes access to data related to a particular changeset convenient.""" def __init__(self, repo, changeid=''): """changeid is a revision number, node, or tag"""