Submitter | Sean Farley |
---|---|
Date | Nov. 6, 2014, 10:56 p.m. |
Message ID | <752f70bee3b0542ca36b.1415314596@1.0.0.127.in-addr.arpa> |
Download | mbox | patch |
Permalink | /patch/6621/ |
State | Superseded |
Commit | 537a2669a1136bff0ced6a9a07b4c5c1a3ae295e |
Headers | show |
Comments
On Thu Nov 06 2014 at 2:57:01 PM Sean Farley <sean.michael.farley@gmail.com> wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # Date 1415314518 28800 > # Thu Nov 06 14:55:18 2014 -0800 > # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 > # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e > revset: use '%' as an operator for 'only' > > With this patch, we can make it much easier to specify 'only(A,B)' -> > A%B. Similarly, 'only(A)' -> A%. > That would let me send patches with 'hg email -r .%@'. Should the first argument default to '.' so it's just '%@'? It seems like only() would be one of the most commonly used revset operations, so I think it deserves its own operator. I'm not sold on '%', though. Something that looks more like '-' would be nice, but I don't know what that would be (I'm tempted to suggest '\\' [1], but that would require shell escaping). [1] http://hackage.haskell.org/package/base-4.7.0.1/docs/Data-List.html#g:20
Martin von Zweigbergk writes: > On Thu Nov 06 2014 at 2:57:01 PM Sean Farley <sean.michael.farley@gmail.com> > wrote: > >> # HG changeset patch >> # User Sean Farley <sean.michael.farley@gmail.com> >> # Date 1415314518 28800 >> # Thu Nov 06 14:55:18 2014 -0800 >> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >> revset: use '%' as an operator for 'only' >> >> With this patch, we can make it much easier to specify 'only(A,B)' -> >> A%B. Similarly, 'only(A)' -> A%. >> > > That would let me send patches with 'hg email -r .%@'. Should the first > argument default to '.' so it's just '%@'? That's not a bad idea. I'll try implementing that. > It seems like only() would be one of the most commonly used revset > operations, so I think it deserves its own operator. I'm not sold on '%', > though. Something that looks more like '-' would be nice, but I don't know > what that would be (I'm tempted to suggest '\\' [1], but that would require > shell escaping). Yeah, I thought of '\' as well (since it could mean 'set difference') but went with '%' due to shell escaping. I could be swayed either way. We could try '/' but that would need the same treatment of '-' for those characters used in a name (e.g. bookmarks named 'feature-x' or smf/feature'). Not a show stopper, but just pointing it out.
On 11/06/2014 10:56 PM, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # Date 1415314518 28800 > # Thu Nov 06 14:55:18 2014 -0800 > # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 > # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e > revset: use '%' as an operator for 'only' Could we get an RevsetOperatorPLan page (or extension of an existing page). To list all the current and wished operators? I think we need a global approach for choising syntax element.
Pierre-Yves David writes: > On 11/06/2014 10:56 PM, Sean Farley wrote: >> # HG changeset patch >> # User Sean Farley <sean.michael.farley@gmail.com> >> # Date 1415314518 28800 >> # Thu Nov 06 14:55:18 2014 -0800 >> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >> revset: use '%' as an operator for 'only' > > Could we get an RevsetOperatorPLan page (or extension of an existing > page). To list all the current and wished operators? Sure, go ahead and start one ;-) If you want me to start it, you'll have to wait a little while :-/ > I think we need a global approach for choising syntax element. Sure, agreed.
On 11/07/2014 05:40 PM, Sean Farley wrote: > > Pierre-Yves David writes: > >> On 11/06/2014 10:56 PM, Sean Farley wrote: >>> # HG changeset patch >>> # User Sean Farley <sean.michael.farley@gmail.com> >>> # Date 1415314518 28800 >>> # Thu Nov 06 14:55:18 2014 -0800 >>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >>> revset: use '%' as an operator for 'only' >> >> Could we get an RevsetOperatorPLan page (or extension of an existing >> page). To list all the current and wished operators? > > Sure, go ahead and start one ;-) If you want me to start it, you'll have > to wait a little while :-/ To clarify. I do not think we should accept this patch until we have a full plan defined. I'm ok with waiting a little while for more operator.
Pierre-Yves David writes: > On 11/07/2014 05:40 PM, Sean Farley wrote: >> >> Pierre-Yves David writes: >> >>> On 11/06/2014 10:56 PM, Sean Farley wrote: >>>> # HG changeset patch >>>> # User Sean Farley <sean.michael.farley@gmail.com> >>>> # Date 1415314518 28800 >>>> # Thu Nov 06 14:55:18 2014 -0800 >>>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >>>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >>>> revset: use '%' as an operator for 'only' >>> >>> Could we get an RevsetOperatorPLan page (or extension of an existing >>> page). To list all the current and wished operators? >> >> Sure, go ahead and start one ;-) If you want me to start it, you'll have >> to wait a little while :-/ > > To clarify. I do not think we should accept this patch until we have a > full plan defined. > > I'm ok with waiting a little while for more operator. http://mercurial.selenic.com/wiki/RevsetOperatorPlan
On 11/07/2014 06:15 PM, Sean Farley wrote: > > Pierre-Yves David writes: > >> On 11/07/2014 05:40 PM, Sean Farley wrote: >>> >>> Pierre-Yves David writes: >>> >>>> On 11/06/2014 10:56 PM, Sean Farley wrote: >>>>> # HG changeset patch >>>>> # User Sean Farley <sean.michael.farley@gmail.com> >>>>> # Date 1415314518 28800 >>>>> # Thu Nov 06 14:55:18 2014 -0800 >>>>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >>>>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >>>>> revset: use '%' as an operator for 'only' >>>> >>>> Could we get an RevsetOperatorPLan page (or extension of an existing >>>> page). To list all the current and wished operators? >>> >>> Sure, go ahead and start one ;-) If you want me to start it, you'll have >>> to wait a little while :-/ >> >> To clarify. I do not think we should accept this patch until we have a >> full plan defined. >> >> I'm ok with waiting a little while for more operator. > > http://mercurial.selenic.com/wiki/RevsetOperatorPlan Can I trick you into listing all the existing operator, then all the one we consider (like successors, etc). Because actual expendend proposal? >
Pierre-Yves David writes: > On 11/07/2014 06:15 PM, Sean Farley wrote: >> >> Pierre-Yves David writes: >> >>> On 11/07/2014 05:40 PM, Sean Farley wrote: >>>> >>>> Pierre-Yves David writes: >>>> >>>>> On 11/06/2014 10:56 PM, Sean Farley wrote: >>>>>> # HG changeset patch >>>>>> # User Sean Farley <sean.michael.farley@gmail.com> >>>>>> # Date 1415314518 28800 >>>>>> # Thu Nov 06 14:55:18 2014 -0800 >>>>>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >>>>>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >>>>>> revset: use '%' as an operator for 'only' >>>>> >>>>> Could we get an RevsetOperatorPLan page (or extension of an existing >>>>> page). To list all the current and wished operators? >>>> >>>> Sure, go ahead and start one ;-) If you want me to start it, you'll have >>>> to wait a little while :-/ >>> >>> To clarify. I do not think we should accept this patch until we have a >>> full plan defined. >>> >>> I'm ok with waiting a little while for more operator. >> >> http://mercurial.selenic.com/wiki/RevsetOperatorPlan > > Can I trick you into listing all the existing operator, then all the one > we consider (like successors, etc). Because actual expendend proposal? Sure.
Sean Farley writes: > Pierre-Yves David writes: > >> On 11/07/2014 06:15 PM, Sean Farley wrote: >>> >>> Pierre-Yves David writes: >>> >>>> On 11/07/2014 05:40 PM, Sean Farley wrote: >>>>> >>>>> Pierre-Yves David writes: >>>>> >>>>>> On 11/06/2014 10:56 PM, Sean Farley wrote: >>>>>>> # HG changeset patch >>>>>>> # User Sean Farley <sean.michael.farley@gmail.com> >>>>>>> # Date 1415314518 28800 >>>>>>> # Thu Nov 06 14:55:18 2014 -0800 >>>>>>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >>>>>>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >>>>>>> revset: use '%' as an operator for 'only' >>>>>> >>>>>> Could we get an RevsetOperatorPLan page (or extension of an existing >>>>>> page). To list all the current and wished operators? >>>>> >>>>> Sure, go ahead and start one ;-) If you want me to start it, you'll have >>>>> to wait a little while :-/ >>>> >>>> To clarify. I do not think we should accept this patch until we have a >>>> full plan defined. >>>> >>>> I'm ok with waiting a little while for more operator. >>> >>> http://mercurial.selenic.com/wiki/RevsetOperatorPlan >> >> Can I trick you into listing all the existing operator, then all the one >> we consider (like successors, etc). Because actual expendend proposal? > > Sure. Updated.
On Thu, 2014-11-06 at 22:40 -0800, Sean Farley wrote: > Martin von Zweigbergk writes: > > > On Thu Nov 06 2014 at 2:57:01 PM Sean Farley <sean.michael.farley@gmail.com> > > wrote: > > > >> # HG changeset patch > >> # User Sean Farley <sean.michael.farley@gmail.com> > >> # Date 1415314518 28800 > >> # Thu Nov 06 14:55:18 2014 -0800 > >> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 > >> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e > >> revset: use '%' as an operator for 'only' > >> > >> With this patch, we can make it much easier to specify 'only(A,B)' -> > >> A%B. Similarly, 'only(A)' -> A%. > >> > > > > That would let me send patches with 'hg email -r .%@'. Should the first > > argument default to '.' so it's just '%@'? > > That's not a bad idea. I'll try implementing that. I think in most cases '.%' would suffice, right? "Everything on . that's not descended from another head". To get in trouble, you'd need a topology like this: o-o-o-o <-@ \ a-c <- foo \ b <- . .% = only a .%@ = a and b > We could try '/' but that would need the same treatment of '-' for those > characters used in a name (e.g. bookmarks named 'feature-x' or > smf/feature'). Not a show stopper, but just pointing it out. Yeah, that's annoying.
On Fri, 2014-11-07 at 11:06 -0800, Sean Farley wrote: > Sean Farley writes: > > > Pierre-Yves David writes: > > > >> On 11/07/2014 06:15 PM, Sean Farley wrote: > >>> > >>> Pierre-Yves David writes: > >>> > >>>> On 11/07/2014 05:40 PM, Sean Farley wrote: > >>>>> > >>>>> Pierre-Yves David writes: > >>>>> > >>>>>> On 11/06/2014 10:56 PM, Sean Farley wrote: > >>>>>>> # HG changeset patch > >>>>>>> # User Sean Farley <sean.michael.farley@gmail.com> > >>>>>>> # Date 1415314518 28800 > >>>>>>> # Thu Nov 06 14:55:18 2014 -0800 > >>>>>>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 > >>>>>>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e > >>>>>>> revset: use '%' as an operator for 'only' > >>>>>> > >>>>>> Could we get an RevsetOperatorPLan page (or extension of an existing > >>>>>> page). To list all the current and wished operators? > >>>>> > >>>>> Sure, go ahead and start one ;-) If you want me to start it, you'll have > >>>>> to wait a little while :-/ > >>>> > >>>> To clarify. I do not think we should accept this patch until we have a > >>>> full plan defined. > >>>> > >>>> I'm ok with waiting a little while for more operator. > >>> > >>> http://mercurial.selenic.com/wiki/RevsetOperatorPlan > >> > >> Can I trick you into listing all the existing operator, then all the one > >> we consider (like successors, etc). Because actual expendend proposal? > > > > Sure. > > Updated. So.. % has some special meaning to cmd.exe and Powershell. Much like Unix $, it may be replaced in some quoted strings. As judged by the support requests we get, no living Windows users know what "shell quoting" is and/or what the actual rules are, so this is a bit of a problem. We need to make sure we're not likely to fall afoul of any replacement rules in any vaguely probable scenario.
Matt Mackall writes: > On Fri, 2014-11-07 at 11:06 -0800, Sean Farley wrote: >> Sean Farley writes: >> >> > Pierre-Yves David writes: >> > >> >> On 11/07/2014 06:15 PM, Sean Farley wrote: >> >>> >> >>> Pierre-Yves David writes: >> >>> >> >>>> On 11/07/2014 05:40 PM, Sean Farley wrote: >> >>>>> >> >>>>> Pierre-Yves David writes: >> >>>>> >> >>>>>> On 11/06/2014 10:56 PM, Sean Farley wrote: >> >>>>>>> # HG changeset patch >> >>>>>>> # User Sean Farley <sean.michael.farley@gmail.com> >> >>>>>>> # Date 1415314518 28800 >> >>>>>>> # Thu Nov 06 14:55:18 2014 -0800 >> >>>>>>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >> >>>>>>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >> >>>>>>> revset: use '%' as an operator for 'only' >> >>>>>> >> >>>>>> Could we get an RevsetOperatorPLan page (or extension of an existing >> >>>>>> page). To list all the current and wished operators? >> >>>>> >> >>>>> Sure, go ahead and start one ;-) If you want me to start it, you'll have >> >>>>> to wait a little while :-/ >> >>>> >> >>>> To clarify. I do not think we should accept this patch until we have a >> >>>> full plan defined. >> >>>> >> >>>> I'm ok with waiting a little while for more operator. >> >>> >> >>> http://mercurial.selenic.com/wiki/RevsetOperatorPlan >> >> >> >> Can I trick you into listing all the existing operator, then all the one >> >> we consider (like successors, etc). Because actual expendend proposal? >> > >> > Sure. >> >> Updated. > > So.. % has some special meaning to cmd.exe and Powershell. Much like > Unix $, it may be replaced in some quoted strings. > > As judged by the support requests we get, no living Windows users know > what "shell quoting" is and/or what the actual rules are, so this is a > bit of a problem. We need to make sure we're not likely to fall afoul of > any replacement rules in any vaguely probable scenario. Oh, Windows. I can test out some of the quoting now that I have a windows dev box.
On 11/07/2014 06:40 AM, Sean Farley wrote: > > Martin von Zweigbergk writes: > >> On Thu Nov 06 2014 at 2:57:01 PM Sean Farley <sean.michael.farley@gmail.com> >> wrote: >> >>> # HG changeset patch >>> # User Sean Farley <sean.michael.farley@gmail.com> >>> # Date 1415314518 28800 >>> # Thu Nov 06 14:55:18 2014 -0800 >>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >>> revset: use '%' as an operator for 'only' >>> >>> With this patch, we can make it much easier to specify 'only(A,B)' -> >>> A%B. Similarly, 'only(A)' -> A%. >>> >> >> That would let me send patches with 'hg email -r .%@'. Should the first >> argument default to '.' so it's just '%@'? > > That's not a bad idea. I'll try implementing that. Meh, "." is a very char to type, I'm not convinced it is worth adding a special case. The ^ and ~ operator does not default to . either.
On 11/11/2014 01:06 AM, Matt Mackall wrote: > On Thu, 2014-11-06 at 22:40 -0800, Sean Farley wrote: >> Martin von Zweigbergk writes: >> >>> On Thu Nov 06 2014 at 2:57:01 PM Sean Farley <sean.michael.farley@gmail.com> >>> wrote: >>> >>>> # HG changeset patch >>>> # User Sean Farley <sean.michael.farley@gmail.com> >>>> # Date 1415314518 28800 >>>> # Thu Nov 06 14:55:18 2014 -0800 >>>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >>>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >>>> revset: use '%' as an operator for 'only' >>>> >>>> With this patch, we can make it much easier to specify 'only(A,B)' -> >>>> A%B. Similarly, 'only(A)' -> A%. >>>> >>> >>> That would let me send patches with 'hg email -r .%@'. Should the first >>> argument default to '.' so it's just '%@'? >> >> That's not a bad idea. I'll try implementing that. > > I think in most cases '.%' would suffice, right? "Everything on . that's > not descended from another head". To get in trouble, you'd need a > topology like this: > > o-o-o-o <-@ > \ > a-c <- foo > \ > b <- . > > .% = only a > .%@ = a and b > >> We could try '/' but that would need the same treatment of '-' for those >> characters used in a name (e.g. bookmarks named 'feature-x' or >> smf/feature'). Not a show stopper, but just pointing it out. > > Yeah, that's annoying. We could try double char operator, like "//" (used for integer division in python). They are unlikely to happen in name. (not saying we should, just saying we could)
On Tue Nov 11 2014 at 3:55:19 AM Pierre-Yves David < pierre-yves.david@ens-lyon.org> wrote: > > > On 11/07/2014 06:40 AM, Sean Farley wrote: > > > > Martin von Zweigbergk writes: > > > >> On Thu Nov 06 2014 at 2:57:01 PM Sean Farley < > sean.michael.farley@gmail.com> > >> wrote: > >> > >>> # HG changeset patch > >>> # User Sean Farley <sean.michael.farley@gmail.com> > >>> # Date 1415314518 28800 > >>> # Thu Nov 06 14:55:18 2014 -0800 > >>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 > >>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e > >>> revset: use '%' as an operator for 'only' > >>> > >>> With this patch, we can make it much easier to specify 'only(A,B)' -> > >>> A%B. Similarly, 'only(A)' -> A%. > >>> > >> > >> That would let me send patches with 'hg email -r .%@'. Should the first > >> argument default to '.' so it's just '%@'? > > > > That's not a bad idea. I'll try implementing that. > > Meh, "." is a very char to type, I'm not convinced it is worth adding a > special case. The ^ and ~ operator does not default to . either. > OK, I agree. It might complicate parsing and readability (of the expression) for little benefit.
On Mon Nov 10 2014 at 5:06:36 PM Matt Mackall <mpm@selenic.com> wrote: > On Thu, 2014-11-06 at 22:40 -0800, Sean Farley wrote: > > Martin von Zweigbergk writes: > > > > > On Thu Nov 06 2014 at 2:57:01 PM Sean Farley < > sean.michael.farley@gmail.com> > > > wrote: > > > > > >> # HG changeset patch > > >> # User Sean Farley <sean.michael.farley@gmail.com> > > >> # Date 1415314518 28800 > > >> # Thu Nov 06 14:55:18 2014 -0800 > > >> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 > > >> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e > > >> revset: use '%' as an operator for 'only' > > >> > > >> With this patch, we can make it much easier to specify 'only(A,B)' -> > > >> A%B. Similarly, 'only(A)' -> A%. > > >> > > > > > > That would let me send patches with 'hg email -r .%@'. Should the first > > > argument default to '.' so it's just '%@'? > > > > That's not a bad idea. I'll try implementing that. > > I think in most cases '.%' would suffice, right? "Everything on . that's > not descended from another head". To get in trouble, you'd need a > topology like this: > > o-o-o-o <-@ > \ > a-c <- foo > \ > b <- . > > .% = only a > .%@ = a and b > I actually do end up in this scenario quite frequently. Usually it's because I realize that 'c' was not the right way of doing foo and I try something else out. I may then histedit 'a' and 'b' a bit until I'm happy and I decide that foo should point to the new version of 'b'. It's usually for histedit and log that I use 'only(.,@)'. So at least in my case, it's more likely that the first argument is '.' than the second one being the implicit 'any'. Anyway, as I said to Pierre-Yves, I think it's fine that the first argument is mandatory.
Sean Farley writes: > Matt Mackall writes: > >> On Fri, 2014-11-07 at 11:06 -0800, Sean Farley wrote: >>> Sean Farley writes: >>> >>> > Pierre-Yves David writes: >>> > >>> >> On 11/07/2014 06:15 PM, Sean Farley wrote: >>> >>> >>> >>> Pierre-Yves David writes: >>> >>> >>> >>>> On 11/07/2014 05:40 PM, Sean Farley wrote: >>> >>>>> >>> >>>>> Pierre-Yves David writes: >>> >>>>> >>> >>>>>> On 11/06/2014 10:56 PM, Sean Farley wrote: >>> >>>>>>> # HG changeset patch >>> >>>>>>> # User Sean Farley <sean.michael.farley@gmail.com> >>> >>>>>>> # Date 1415314518 28800 >>> >>>>>>> # Thu Nov 06 14:55:18 2014 -0800 >>> >>>>>>> # Node ID 752f70bee3b0542ca36b1fecbb70c954d6017061 >>> >>>>>>> # Parent 2d54aa5397cdb1c697673ba10b7618d5ac25c69e >>> >>>>>>> revset: use '%' as an operator for 'only' >>> >>>>>> >>> >>>>>> Could we get an RevsetOperatorPLan page (or extension of an existing >>> >>>>>> page). To list all the current and wished operators? >>> >>>>> >>> >>>>> Sure, go ahead and start one ;-) If you want me to start it, you'll have >>> >>>>> to wait a little while :-/ >>> >>>> >>> >>>> To clarify. I do not think we should accept this patch until we have a >>> >>>> full plan defined. >>> >>>> >>> >>>> I'm ok with waiting a little while for more operator. >>> >>> >>> >>> http://mercurial.selenic.com/wiki/RevsetOperatorPlan >>> >> >>> >> Can I trick you into listing all the existing operator, then all the one >>> >> we consider (like successors, etc). Because actual expendend proposal? >>> > >>> > Sure. >>> >>> Updated. >> >> So.. % has some special meaning to cmd.exe and Powershell. Much like >> Unix $, it may be replaced in some quoted strings. >> >> As judged by the support requests we get, no living Windows users know >> what "shell quoting" is and/or what the actual rules are, so this is a >> bit of a problem. We need to make sure we're not likely to fall afoul of >> any replacement rules in any vaguely probable scenario. > > Oh, Windows. I can test out some of the quoting now that I have a > windows dev box. On Windows (using non-=bash shells), %var% is only expanded when 'var' exists and is surrounded by '%'. For example, %home% (case insensitive) is automatically defined, so we get this: $ echo .%home .%home $ echo .%home% .C:\Users\sfarley $ echo .%foo .%foo $ echo .%foo% .%foo%
Patch
diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -114,10 +114,11 @@ elements = { ":": (15, ("rangepre", 15), ("range", 15), ("rangepost", 15)), "not": (10, ("not", 10)), "!": (10, ("not", 10)), "and": (5, None, ("and", 5)), "&": (5, None, ("and", 5)), + "%": (5, None, ("only", 5), ("onlypost", 5)), "or": (4, None, ("or", 4)), "|": (4, None, ("or", 4)), "+": (4, None, ("or", 4)), ",": (2, None, ("list", 2)), ")": (0, None, None), @@ -147,11 +148,11 @@ def tokenize(program, lookup=None): yield ('::', None, pos) pos += 1 # skip ahead elif c == '.' and program[pos:pos + 2] == '..': # look ahead carefully yield ('..', None, pos) pos += 1 # skip ahead - elif c in "():,-|&+!~^": # handle simple operators + elif c in "():,-|&+!~^%": # handle simple operators yield (c, None, pos) elif (c in '"\'' or c == 'r' and program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings if c == 'r': pos += 1 @@ -383,17 +384,21 @@ def author(repo, subset, x): # i18n: "author" is a keyword n = encoding.lower(getstring(x, _("author requires a string"))) kind, pattern, matcher = _substringmatcher(n) return subset.filter(lambda x: matcher(encoding.lower(repo[x].user()))) -def only(repo, subset, x): +def only(repo, subset, x, y=None): """``only(set, [set])`` Changesets that are ancestors of the first set that are not ancestors of any other head in the repo. If a second set is specified, the result is ancestors of the first set that are not ancestors of the second set (i.e. ::<set1> - ::<set2>). """ + # if y is not none then we need to combine the operators into a list + if y is not None: + x = ('list', x, y) + cl = repo.changelog # i18n: "only" is a keyword args = getargs(x, 1, 2, _('only takes one or two arguments')) include = getset(repo, spanset(repo), args[0]) if len(args) == 1: @@ -1834,10 +1839,12 @@ methods = { "list": listset, "func": func, "ancestor": ancestorspec, "parent": parentspec, "parentpost": p1, + "only": only, + "onlypost": only, } def optimize(x, small): if x is None: return 0, x @@ -1860,11 +1867,11 @@ def optimize(x, small): elif op == 'negate': return optimize(('string', '-' + getstring(x[1], _("can't negate that"))), small) elif op in 'string symbol negate': return smallbonus, x # single revisions are small - elif op == 'and': + elif op in 'and only': wa, ta = optimize(x[1], True) wb, tb = optimize(x[2], True) # (::x and not ::y)/(not ::y and ::x) have a fast path def isonly(revs, bases): diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -436,10 +436,36 @@ Test empty set input 2 4 8 9 +Test '%' operator + + $ log '9%' + 8 + 9 + $ log '9%5' + 2 + 4 + 8 + 9 + $ log '(7 + 9)%(5 + 2)' + 4 + 6 + 7 + 8 + 9 + +Test the order of operations + + $ log '7 + 9%5 + 2' + 7 + 2 + 4 + 8 + 9 + Test explicit numeric revision $ log 'rev(-1)' $ log 'rev(0)' 0 $ log 'rev(9)'