[PATCH 2 of 7 V4] hgweb: add a "patch" query parameter to filelog command
Augie Fackler
raf at durin42.com
Fri Mar 24 18:34:37 EDT 2017
Can you take a look at this?
--- /home/augie/hg/tests/test-websub.t
+++ /home/augie/hg/tests/test-websub.t.err
@@ -28,9 +28,29 @@
log
$ get-with-headers.py localhost:$HGPORT "rev/tip" | grep bts
- <div class="description"><a
href="http://bts.example.org/issue123">Issue123</a>: fixed the <i
class="x">bug</i>!</div>
+ [1]
errors
$ cat errors.log
+ $LOCALIP - - [24/Mar/2017 22:32:42] Exception happened during
processing request '/rev/tip':
+ Traceback (most recent call last):
+ File "/tmp/hgtests.jp66xI/install/lib/python/mercurial/hgweb/server.py",
line 100, in do_POST
+ self.do_write()
+ File "/tmp/hgtests.jp66xI/install/lib/python/mercurial/hgweb/server.py",
line 93, in do_write
+ self.do_hgweb()
+ File "/tmp/hgtests.jp66xI/install/lib/python/mercurial/hgweb/server.py",
line 161, in do_hgweb
+ for chunk in self.server.application(env, self._start_response):
+ File "/tmp/hgtests.jp66xI/install/lib/python/mercurial/hgweb/hgweb_mod.py",
line 315, in run_wsgi
+ for r in self._runwsgi(req, repo):
+ File "/tmp/hgtests.jp66xI/install/lib/python/mercurial/util.py",
line 867, in increasingchunks
+ for chunk in source:
+ File "/tmp/hgtests.jp66xI/install/lib/python/mercurial/templater.py",
line 1035, in _flatten
+ for j in _flatten(i):
+ File "/tmp/hgtests.jp66xI/install/lib/python/mercurial/templater.py",
line 1027, in _flatten
+ for i in thing:
+ File "/tmp/hgtests.jp66xI/install/lib/python/mercurial/hgweb/webutil.py",
line 435, in diffs
+ repo = web.repo
+ NameError: global name 'web' is not defined
+
On Fri, Mar 24, 2017 at 1:08 PM, Augie Fackler <raf at durin42.com> wrote:
> On Fri, Mar 24, 2017 at 08:57:35AM +0100, Denis Laxalde wrote:
>> # HG changeset patch
>> # User Denis Laxalde <denis.laxalde at logilab.fr>
>> # Date 1489398073 -3600
>> # Mon Mar 13 10:41:13 2017 +0100
>> # Node ID bc1ca69d5b73f43fb2c93c4f075c909eaf32e531
>> # Parent e62a136ee79973157cded80c7f578dc60b7f6a68
>> # Available At http://hg.logilab.org/users/dlaxalde/hg
>> # hg pull http://hg.logilab.org/users/dlaxalde/hg -r bc1ca69d5b73
>> # EXP-Topic linerange-log/hgweb-filelog
>> hgweb: add a "patch" query parameter to filelog command
>
> Took these first two, looking at the rest.
>
>>
>> Add support for a "patch" query parameter in filelog web command similar to
>> --patch option of `hg log` to display the diff of each changeset in the table
>> of revisions. The diff text is displayed in a dedicated row of the table that
>> follows the existing one for each entry and spans over all columns. Only
>> update "paper" template in this patch.
>>
>> diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
>> --- a/mercurial/hgweb/webcommands.py
>> +++ b/mercurial/hgweb/webcommands.py
>> @@ -973,6 +973,10 @@ def filelog(web, req, tmpl):
>> morevars = copy.copy(tmpl.defaults['sessionvars'])
>> morevars['revcount'] = revcount * 2
>>
>> + patch = 'patch' in req.form
>> + if patch:
>> + lessvars['patch'] = morevars['patch'] = req.form['patch'][0]
>> +
>> count = fctx.filerev() + 1
>> start = max(0, count - revcount) # first rev on this page
>> end = min(count, start + revcount) # last rev on this page
>> @@ -981,12 +985,27 @@ def filelog(web, req, tmpl):
>> repo = web.repo
>> revs = fctx.filelog().revs(start, end - 1)
>> entries = []
>> +
>> + diffstyle = web.config('web', 'style', 'paper')
>> + if 'style' in req.form:
>> + diffstyle = req.form['style'][0]
>> +
>> + def diff(fctx):
>> + ctx = fctx.changectx()
>> + basectx = ctx.p1()
>> + path = fctx.path()
>> + return webutil.diffs(web, tmpl, ctx, basectx, [path], diffstyle)
>> +
>> for i in revs:
>> iterfctx = fctx.filectx(i)
>> + diffs = None
>> + if patch:
>> + diffs = diff(iterfctx)
>> entries.append(dict(
>> parity=next(parity),
>> filerev=i,
>> file=f,
>> + diff=diffs,
>> rename=webutil.renamelink(iterfctx),
>> **webutil.commonentry(repo, iterfctx)))
>> entries.reverse()
>> @@ -1000,6 +1019,7 @@ def filelog(web, req, tmpl):
>> nav=nav,
>> symrev=webutil.symrevorshortnode(req, fctx),
>> entries=entries,
>> + patch=patch,
>> latestentry=latestentry,
>> revcount=revcount,
>> morevars=morevars,
>> diff --git a/mercurial/templates/paper/filelogentry.tmpl b/mercurial/templates/paper/filelogentry.tmpl
>> --- a/mercurial/templates/paper/filelogentry.tmpl
>> +++ b/mercurial/templates/paper/filelogentry.tmpl
>> @@ -6,3 +6,4 @@
>> {inbranch%changelogbranchname}{branches%changelogbranchhead}{tags%changelogtag}{bookmarks%changelogtag}{rename%filelogrename}
>> </td>
>> </tr>
>> + {if(patch, '<tr><td colspan="3">{diff}</td></tr>')}
>> diff --git a/tests/test-hgweb-filelog.t b/tests/test-hgweb-filelog.t
>> --- a/tests/test-hgweb-filelog.t
>> +++ b/tests/test-hgweb-filelog.t
>> @@ -221,6 +221,7 @@ tip - two revisions
>> <span class="branchname">a-branch</span>
>> </td>
>> </tr>
>> +
>> <tr>
>> <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td>
>> <td class="author">test</td>
>> @@ -229,6 +230,7 @@ tip - two revisions
>> <span class="tag">a-tag</span> <span class="tag">a-bookmark</span>
>> </td>
>> </tr>
>> +
>>
>> </tbody>
>> </table>
>> @@ -340,6 +342,7 @@ second version - two revisions
>> <span class="branchname">a-branch</span>
>> </td>
>> </tr>
>> +
>> <tr>
>> <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td>
>> <td class="author">test</td>
>> @@ -348,6 +351,7 @@ second version - two revisions
>> <span class="tag">a-tag</span> <span class="tag">a-bookmark</span>
>> </td>
>> </tr>
>> +
>>
>> </tbody>
>> </table>
>> @@ -459,6 +463,7 @@ first deleted - one revision
>> <span class="tag">a-tag</span> <span class="tag">a-bookmark</span>
>> </td>
>> </tr>
>> +
>>
>> </tbody>
>> </table>
>> @@ -570,6 +575,7 @@ first version - one revision
>> <span class="tag">a-tag</span> <span class="tag">a-bookmark</span>
>> </td>
>> </tr>
>> +
>>
>> </tbody>
>> </table>
>> @@ -762,6 +768,135 @@ should show base link, use spartan becau
>> </html>
>>
>>
>> +filelog with patch
>> +
>> + $ (get-with-headers.py localhost:$HGPORT 'log/4/a?patch=1')
>> + 200 Script output follows
>> +
>> + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
>> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
>> + <head>
>> + <link rel="icon" href="/static/hgicon.png" type="image/png" />
>> + <meta name="robots" content="index, nofollow" />
>> + <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
>> + <script type="text/javascript" src="/static/mercurial.js"></script>
>> +
>> + <title>test: a history</title>
>> + <link rel="alternate" type="application/atom+xml"
>> + href="/atom-log/tip/a" title="Atom feed for test:a" />
>> + <link rel="alternate" type="application/rss+xml"
>> + href="/rss-log/tip/a" title="RSS feed for test:a" />
>> + </head>
>> + <body>
>> +
>> + <div class="container">
>> + <div class="menu">
>> + <div class="logo">
>> + <a href="https://mercurial-scm.org/">
>> + <img src="/static/hglogo.png" alt="mercurial" /></a>
>> + </div>
>> + <ul>
>> + <li><a href="/shortlog/4">log</a></li>
>> + <li><a href="/graph/4">graph</a></li>
>> + <li><a href="/tags">tags</a></li>
>> + <li><a href="/bookmarks">bookmarks</a></li>
>> + <li><a href="/branches">branches</a></li>
>> + </ul>
>> + <ul>
>> + <li><a href="/rev/4">changeset</a></li>
>> + <li><a href="/file/4">browse</a></li>
>> + </ul>
>> + <ul>
>> + <li><a href="/file/4/a">file</a></li>
>> + <li><a href="/diff/4/a">diff</a></li>
>> + <li><a href="/comparison/4/a">comparison</a></li>
>> + <li><a href="/annotate/4/a">annotate</a></li>
>> + <li class="active">file log</li>
>> + <li><a href="/raw-file/4/a">raw</a></li>
>> + </ul>
>> + <ul>
>> + <li><a href="/help">help</a></li>
>> + </ul>
>> + <div class="atom-logo">
>> + <a href="/atom-log/tip/a" title="subscribe to atom feed">
>> + <img class="atom-logo" src="/static/feed-icon-14x14.png" alt="atom feed" />
>> + </a>
>> + </div>
>> + </div>
>> +
>> + <div class="main">
>> + <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
>> + <h3>
>> + log a @ 4:<a href="/rev/3f41bc784e7e">3f41bc784e7e</a>
>> + <span class="branchname">a-branch</span>
>> + </h3>
>> +
>> + <form class="search" action="/log">
>> +
>> + <p><input name="rev" id="search1" type="text" size="30" /></p>
>> + <div id="hint">Find changesets by keywords (author, files, the commit message), revision
>> + number or hash, or <a href="/help/revsets">revset expression</a>.</div>
>> + </form>
>> +
>> + <div class="navigate">
>> + <a href="/log/4/a?patch=1&revcount=30">less</a>
>> + <a href="/log/4/a?patch=1&revcount=120">more</a>
>> + | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
>> +
>> + <table class="bigtable">
>> + <thead>
>> + <tr>
>> + <th class="age">age</th>
>> + <th class="author">author</th>
>> + <th class="description">description</th>
>> + </tr>
>> + </thead>
>> + <tbody class="stripes2">
>> + <tr>
>> + <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td>
>> + <td class="author">test</td>
>> + <td class="description">
>> + <a href="/rev/3f41bc784e7e">second a</a>
>> + <span class="branchname">a-branch</span>
>> + </td>
>> + </tr>
>> + <tr><td colspan="3"><div class="bottomline inc-lineno"><pre class="sourcelines wrap">
>> + <span id="l1.1" class="minusline">--- /dev/null Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.1"></a>
>> + <span id="l1.2" class="plusline">+++ b/a Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.2"></a>
>> + <span id="l1.3" class="atline">@@ -0,0 +1,1 @@</span><a href="#l1.3"></a>
>> + <span id="l1.4" class="plusline">+b</span><a href="#l1.4"></a></pre></div></td></tr>
>> + <tr>
>> + <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td>
>> + <td class="author">test</td>
>> + <td class="description">
>> + <a href="/rev/5ed941583260">first a</a>
>> + <span class="tag">a-tag</span> <span class="tag">a-bookmark</span>
>> + </td>
>> + </tr>
>> + <tr><td colspan="3"><div class="bottomline inc-lineno"><pre class="sourcelines wrap">
>> + <span id="l1.1" class="minusline">--- /dev/null Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.1"></a>
>> + <span id="l1.2" class="plusline">+++ b/a Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.2"></a>
>> + <span id="l1.3" class="atline">@@ -0,0 +1,1 @@</span><a href="#l1.3"></a>
>> + <span id="l1.4" class="plusline">+a</span><a href="#l1.4"></a></pre></div></td></tr>
>> +
>> + </tbody>
>> + </table>
>> +
>> + <div class="navigate">
>> + <a href="/log/4/a?patch=1&revcount=30">less</a>
>> + <a href="/log/4/a?patch=1&revcount=120">more</a>
>> + | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a>
>> + </div>
>> +
>> + </div>
>> + </div>
>> +
>> +
>> +
>> + </body>
>> + </html>
>> +
>> +
>> rss log
>>
>> $ (get-with-headers.py localhost:$HGPORT 'rss-log/tip/a')
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list