[PATCH RFC] commands, context: allow to annotate working-copy revision

Yuya Nishihara yuya at tcha.org
Wed Feb 9 10:03:58 CST 2011


Matt Mackall wrote:
> On Mon, 2011-02-07 at 23:54 +0100, Benoit Boissinot wrote:
> > On Sun, Feb 6, 2011 at 12:11 PM, Yuya Nishihara <yuya at tcha.org> wrote:
> > > # HG changeset patch
> > > # User Yuya Nishihara <yuya at tcha.org>
> > > # Date 1296990265 -32400
> > > # Node ID 511aa87eeb262131bfd08655bab6fa94218750eb
> > > # Parent  69e69b131458023d21ec40aa48fc5299e43ce69b
> > > commands, context: allow to annotate working-copy revision
> > >
> > > It changes 'hg annotate' command to annotate working-copy revision by default.
> > > wctx rev and nodeid are displayed as blank in annotation result.
> > 
> > I don't really like returning None, for wctx.rev(), in your case it
> > doesn't simplify anything since you still need to test for None
> > everywhere.
> > Can't you explicitly test for ctx is an instance of wctx?

Indeed, `ctx.rev() is None` things don't look nice.
Do you mean something like isinstance(ctx, workingctx) or
isinstance(fctx, workingfilectx) ?

> > > Things I'm not sure:
> > > - It might not be appropriate to change the default behavior of annotate
> > >  command. But there's no way to specify working-copy revision explicitly.
> > > - Is empty string good to denote working-copy rev and nodeid in annotation
> > >  result?
> > 
> > We can't change the default behaviour like that.
> 
> Indeed.
> 
> >  I don't remember but
> > didn't we introduce something to denote the working copy rev with
> > revsets? That way you could use it with -r.
> 
> There've been a couple proposals for that, but nothing's been
> implemented. I originally favored '+' as an alias, but revsets ate that.
> 
> And yes, we need to come up with a rev() semantic for the working
> revision that doesn't break/complicate everything.

Found the discussion at:
http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/31306

What about adding 'workingdir()' revset?
It may be too long to type, but obvious:

--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -247,6 +247,12 @@ def parents(repo, subset, x):
         ps.update(cl.parentrevs(r))
     return [r for r in subset if r in ps]
 
+def workingdir(repo, subset, x):
+    """``workingdir()``
+    Working directory.
+    """
+    return [None]
+
 def maxrev(repo, subset, x):
     """``max(set)``
     Changeset with highest revision number in set.
@@ -701,6 +707,7 @@ symbols = {
     "tag": tag,
     "tagged": tagged,
     "user": user,
+    "workingdir": workingdir,
 }
 
 methods = {

Regards,
Yuya


More information about the Mercurial-devel mailing list