Patchwork [02,of,22,V2-Series-D] hgweb: move revnavgen into an object

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 14, 2013, 10:31 p.m.
Message ID <11802567-CEBE-44B8-9142-4AE7B959782C@ens-lyon.org>
Download mbox | patch
Permalink /patch/623/
State Superseded
Commit bfaee31a83d209c96f3c8b99b05daaef4da61b50
Headers show

Comments

Pierre-Yves David - Jan. 14, 2013, 10:31 p.m.
On 14 janv. 2013, at 22:23, Kevin Bullock wrote:

> On Jan 14, 2013, at 2:35 PM, Pierre-Yves David wrote:
> 
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@logilab.fr>
>> # Date 1358180901 -3600
>> # Node ID f3a21139337faae5dd711516b21e7678c1c703ce
>> # Parent  869fbec5fd438ce182c7ba5ca2a9a79d9f3fce99
>> hgweb: move revnavgen into an object
> 
> I *think* this is okay, but it's making my eyes cross. I'm thinking the diff would be slightly less bogacious if you introduce the class as an empty class first. (Not sure if it would make it _much_ better, but I think it's worth a try.)

I think this series is already over split.

The -w option of diff to ignore white space change already help a lots: Here is the output below

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -240,11 +240,11 @@  def changelog(web, req, tmpl, shortlog=F
     start = max(0, pos - revcount + 1)
     end = min(count, start + revcount)
     pos = end - 1
     parity = paritygen(web.stripecount, offset=start - end)
 
-    changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx)
+    changenav = webutil.revnav().gen(pos, revcount, count, web.repo.changectx)
 
     return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
                 node=ctx.hex(), rev=pos, changesets=count,
                 entries=lambda **x: changelist(latestonly=False, **x),
                 latestentry=lambda **x: changelist(latestonly=True, **x),
@@ -770,11 +770,11 @@  def filelog(web, req, tmpl):
                       "branches": webutil.nodebranchdict(repo, iterfctx)})
         for e in reversed(l):
             yield e
 
     nodefunc = lambda x: fctx.filectx(fileid=x)
-    nav = webutil.revnavgen(end - 1, revcount, count, nodefunc)
+    nav = webutil.revnav().gen(end - 1, revcount, count, nodefunc)
     return tmpl("filelog", file=f, node=fctx.hex(), nav=nav,
                 entries=lambda **x: entries(latestonly=False, **x),
                 latestentry=lambda **x: entries(latestonly=True, **x),
                 revcount=revcount, morevars=morevars, lessvars=lessvars)
 
@@ -850,11 +850,11 @@  def graph(web, req, tmpl):
     end = min(count, start + revcount)
     pos = end - 1
 
     uprev = min(max(0, count - 1), rev + revcount)
     downrev = max(0, rev - revcount)
-    changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx)
+    changenav = webutil.revnav().gen(pos, revcount, count, web.repo.changectx)
 
     dag = graphmod.dagwalker(web.repo, range(start, end)[::-1])
     tree = list(graphmod.colored(dag, web.repo))
 
     def getcolumns(tree):
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -22,11 +22,13 @@  def up(p):
     up = os.path.dirname(p)
     if up == "/":
         return "/"
     return up + "/"
 
-def revnavgen(pos, pagelen, limit, nodefunc):
+class revnav(object):
+
+    def gen(self, pos, pagelen, limit, nodefunc):
     """computes label and revision id for navigation link
 
     :pos: is the revision relative to which we generate navigation.
     :pagelen: the size of each navigation page
     :limit: how far shall we link