Patchwork [13,of,20] hgweb: remove first entry from the list for ajax log

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 9, 2013, 6:57 p.m.
Message ID <015d43fca74b12c5c79c.1376074658@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2119/
State Changes Requested
Headers show

Comments

Alexander Plavin - Aug. 9, 2013, 6:57 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1376074124 -14400
#      Fri Aug 09 22:48:44 2013 +0400
# Node ID 015d43fca74b12c5c79ca14683d375dc9675fdd2
# Parent  d29091e49e209d58302e2835a3cdf63b6df7f8f2
hgweb: remove first entry from the list for ajax log

This is needed because ajax requests next page starting with the last revision
from the previous one.
Laurens Holst - Aug. 10, 2013, 1:10 p.m.
Op 09-08-13 20:57, Alexander Plavin schreef:
> # HG changeset patch
> # User Alexander Plavin <alexander@plav.in>
> # Date 1376074124 -14400
> #      Fri Aug 09 22:48:44 2013 +0400
> # Node ID 015d43fca74b12c5c79ca14683d375dc9675fdd2
> # Parent  d29091e49e209d58302e2835a3cdf63b6df7f8f2
> hgweb: remove first entry from the list for ajax log
>
> This is needed because ajax requests next page starting with the last revision
> from the previous one.

Bit icky. Can’t you instead fix the request to start with the next revision?

If a requests asks for something it should get precisely that, not that 
+ 1...

>
> diff -r d29091e49e20 -r 015d43fca74b mercurial/hgweb/webcommands.py
> --- a/mercurial/hgweb/webcommands.py	Fri Aug 09 19:13:34 2013 +0400
> +++ b/mercurial/hgweb/webcommands.py	Fri Aug 09 22:48:44 2013 +0400
> @@ -320,6 +320,7 @@
>       template = shortlog and 'shortlog' or 'changelog'
>       if 'ajax' in req.form:
>           template += 'ajax'
> +        entries = entries[1:]
>   
>       return tmpl(template, changenav=changenav,
>                   node=ctx.hex(), rev=pos, changesets=count,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Alexander Plavin - Aug. 12, 2013, 6:57 p.m.
10.08.2013, 17:10, "Laurens Holst" <laurens.nospam@grauw.nl>:
> Op 09-08-13 20:57, Alexander Plavin schreef:
>
>>  # HG changeset patch
>>  # User Alexander Plavin <alexander@plav.in>
>>  # Date 1376074124 -14400
>>  #      Fri Aug 09 22:48:44 2013 +0400
>>  # Node ID 015d43fca74b12c5c79ca14683d375dc9675fdd2
>>  # Parent  d29091e49e209d58302e2835a3cdf63b6df7f8f2
>>  hgweb: remove first entry from the list for ajax log
>>
>>  This is needed because ajax requests next page starting with the last revision
>>  from the previous one.
>
> Bit icky. Can’t you instead fix the request to start with the next revision?

I'll think about this, may be it's better to use just revision number at the ajax query instead of the hash - then it will be easier to advance it by one.

>
> If a requests asks for something it should get precisely that, not that
> + 1...
>
>>  diff -r d29091e49e20 -r 015d43fca74b mercurial/hgweb/webcommands.py
>>  --- a/mercurial/hgweb/webcommands.py Fri Aug 09 19:13:34 2013 +0400
>>  +++ b/mercurial/hgweb/webcommands.py Fri Aug 09 22:48:44 2013 +0400
>>  @@ -320,6 +320,7 @@
>>        template = shortlog and 'shortlog' or 'changelog'
>>        if 'ajax' in req.form:
>>            template += 'ajax'
>>  +        entries = entries[1:]
>>
>>        return tmpl(template, changenav=changenav,
>>                    node=ctx.hex(), rev=pos, changesets=count,
>>  _______________________________________________
>>  Mercurial-devel mailing list
>>  Mercurial-devel@selenic.com
>>  http://selenic.com/mailman/listinfo/mercurial-devel
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Laurens Holst - Aug. 15, 2013, 6:13 p.m.
Op 12-8-2013 20:57, Alexander Plavin schreef:
>
> 10.08.2013, 17:10, "Laurens Holst" <laurens.nospam@grauw.nl>:
>> Op 09-08-13 20:57, Alexander Plavin schreef:
>>
>>>   # HG changeset patch
>>>   # User Alexander Plavin <alexander@plav.in>
>>>   # Date 1376074124 -14400
>>>   #      Fri Aug 09 22:48:44 2013 +0400
>>>   # Node ID 015d43fca74b12c5c79ca14683d375dc9675fdd2
>>>   # Parent  d29091e49e209d58302e2835a3cdf63b6df7f8f2
>>>   hgweb: remove first entry from the list for ajax log
>>>
>>>   This is needed because ajax requests next page starting with the last revision
>>>   from the previous one.
>> Bit icky. Can’t you instead fix the request to start with the next revision?
> I'll think about this, may be it's better to use just revision number at the ajax query instead of the hash - then it will be easier to advance it by one.

If you do that, you should make sure this works with hidden revisions 
(and doesn’t reveal its changeset hash), as well as if the next revision 
number is on another branch.

You could also put the next revision hash in the generated page and pick 
it up from there.

~Laurens
Alexander Plavin - Aug. 15, 2013, 6:37 p.m.
15.08.2013, 22:13, "Laurens Holst" <laurens.nospam@grauw.nl>:
> Op 12-8-2013 20:57, Alexander Plavin schreef:
>
>>  10.08.2013, 17:10, "Laurens Holst" <laurens.nospam@grauw.nl>:
>>>  Op 09-08-13 20:57, Alexander Plavin schreef:
>>>>    # HG changeset patch
>>>>    # User Alexander Plavin <alexander@plav.in>
>>>>    # Date 1376074124 -14400
>>>>    #      Fri Aug 09 22:48:44 2013 +0400
>>>>    # Node ID 015d43fca74b12c5c79ca14683d375dc9675fdd2
>>>>    # Parent  d29091e49e209d58302e2835a3cdf63b6df7f8f2
>>>>    hgweb: remove first entry from the list for ajax log
>>>>
>>>>    This is needed because ajax requests next page starting with the last revision
>>>>    from the previous one.
>>>  Bit icky. Can’t you instead fix the request to start with the next revision?
>>  I'll think about this, may be it's better to use just revision number at the ajax query instead of the hash - then it will be easier to advance it by one.
>
> If you do that, you should make sure this works with hidden revisions
> (and doesn’t reveal its changeset hash), as well as if the next revision
> number is on another branch.

I don't see how it can reveal something, as no new data will be available (in comparison with current state). However, I've checked and it's not possible to just specify n-1 as the requested revision, because if it doesn't exist (stripped, hidden) the request will fail.

>
> You could also put the next revision hash in the generated page and pick
> it up from there.

Yes, it's a possible solution (and I explored it a bit), and it's similar in code like this patch: we would have to generate a list with length+1, and strip the last one from it. As for me, this seems the best choice from those I thought of.

>
> ~Laurens

Patch

diff -r d29091e49e20 -r 015d43fca74b mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Fri Aug 09 19:13:34 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Fri Aug 09 22:48:44 2013 +0400
@@ -320,6 +320,7 @@ 
     template = shortlog and 'shortlog' or 'changelog'
     if 'ajax' in req.form:
         template += 'ajax'
+        entries = entries[1:]
 
     return tmpl(template, changenav=changenav,
                 node=ctx.hex(), rev=pos, changesets=count,