Patchwork [RFC] revset: completely ignore "null" symbol in new-style query (BC)

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 6, 2015, 3:38 p.m.
Message ID <20150107003853.785aded00cf5ae276bf40838@tcha.org>
Download mbox | patch
Permalink /patch/7327/
State Changes Requested
Headers show

Comments

Yuya Nishihara - Jan. 6, 2015, 3:38 p.m.
On Mon, 05 Jan 2015 15:45:17 -0600, Matt Mackall wrote:
> On Sun, 2015-01-04 at 12:21 +0900, Yuya Nishihara wrote:
> > This depends on my previous patch "revset: drop pre-lazyset optimization for
> > stringset of subset == entire repo."  I want to know if "null" revision is
> > supported in revset.
> 
> We probably do want to support null. It's one of the primary barriers to
> eliminating old-style queries. We also want to eventually support a
> symbol/identifier that means "the working copy".

So maybe we'll need a magic to extend the initial "subset" to null or "the
working copy" symbol.  I'll try something like the following.
Pierre-Yves David - Jan. 8, 2015, 11:51 p.m.
On 01/06/2015 07:38 AM, Yuya Nishihara wrote:
> On Mon, 05 Jan 2015 15:45:17 -0600, Matt Mackall wrote:
>> On Sun, 2015-01-04 at 12:21 +0900, Yuya Nishihara wrote:
>>> This depends on my previous patch "revset: drop pre-lazyset optimization for
>>> stringset of subset == entire repo."  I want to know if "null" revision is
>>> supported in revset.
>>
>> We probably do want to support null. It's one of the primary barriers to
>> eliminating old-style queries. We also want to eventually support a
>> symbol/identifier that means "the working copy".
>
> So maybe we'll need a magic to extend the initial "subset" to null or "the
> working copy" symbol.  I'll try something like the following.
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -252,8 +252,6 @@ def _getrevsource(repo, r):
>
>   def stringset(repo, subset, x):
>       x = repo[x].rev()
> -    if x == -1 and len(subset) == len(repo):
> -        return baseset([-1])
>       if x in subset:
>           return baseset([x])
>       return baseset()
> @@ -3070,5 +3068,8 @@ class fullreposet(_spanset):
>               other.sort(reverse)
>           return other
>
> +    def __contains__(self, rev):
> +        return rev == -1 or super(fullreposet, self).__contains__(rev)
> +
>   # tell hggettext to extract docstrings from these functions:
>   i18nfunctions = symbols.values()

This looks a reasonable approach to me (and a good incentive to use 
fullreposet)
Yuya Nishihara - Jan. 9, 2015, 2:25 p.m.
On Thu, 08 Jan 2015 15:51:48 -0800, Pierre-Yves David wrote:
> On 01/06/2015 07:38 AM, Yuya Nishihara wrote:
> > On Mon, 05 Jan 2015 15:45:17 -0600, Matt Mackall wrote:
> >> On Sun, 2015-01-04 at 12:21 +0900, Yuya Nishihara wrote:
> >>> This depends on my previous patch "revset: drop pre-lazyset optimization for
> >>> stringset of subset == entire repo."  I want to know if "null" revision is
> >>> supported in revset.
> >>
> >> We probably do want to support null. It's one of the primary barriers to
> >> eliminating old-style queries. We also want to eventually support a
> >> symbol/identifier that means "the working copy".
> >
> > So maybe we'll need a magic to extend the initial "subset" to null or "the
> > working copy" symbol.  I'll try something like the following.
> >
> > diff --git a/mercurial/revset.py b/mercurial/revset.py
> > --- a/mercurial/revset.py
> > +++ b/mercurial/revset.py
> > @@ -252,8 +252,6 @@ def _getrevsource(repo, r):
> >
> >   def stringset(repo, subset, x):
> >       x = repo[x].rev()
> > -    if x == -1 and len(subset) == len(repo):
> > -        return baseset([-1])
> >       if x in subset:
> >           return baseset([x])
> >       return baseset()
> > @@ -3070,5 +3068,8 @@ class fullreposet(_spanset):
> >               other.sort(reverse)
> >           return other
> >
> > +    def __contains__(self, rev):
> > +        return rev == -1 or super(fullreposet, self).__contains__(rev)
> > +
> >   # tell hggettext to extract docstrings from these functions:
> >   i18nfunctions = symbols.values()
> 
> This looks a reasonable approach to me (and a good incentive to use 
> fullreposet)

Thanks. I think I can send the patches this weekend. I have to fix several
issues that are caused by the appearance of "-1" revision.

Regards,

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -252,8 +252,6 @@  def _getrevsource(repo, r):
 
 def stringset(repo, subset, x):
     x = repo[x].rev()
-    if x == -1 and len(subset) == len(repo):
-        return baseset([-1])
     if x in subset:
         return baseset([x])
     return baseset()
@@ -3070,5 +3068,8 @@  class fullreposet(_spanset):
             other.sort(reverse)
         return other
 
+    def __contains__(self, rev):
+        return rev == -1 or super(fullreposet, self).__contains__(rev)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()