Submitter | Denis Laxalde |
---|---|
Date | March 25, 2017, 9:20 a.m. |
Message ID | <a7b9bc1af8b81c332cf3.1490433657@marimba> |
Download | mbox | patch |
Permalink | /patch/19657/ |
State | Accepted |
Headers | show |
Comments
On Sat, 25 Mar 2017 10:20:57 +0100, Denis Laxalde wrote: > # HG changeset patch > # User Denis Laxalde <denis.laxalde@logilab.fr> > # Date 1489398073 -3600 > # Mon Mar 13 10:41:13 2017 +0100 > # Node ID a7b9bc1af8b81c332cf34960f581359e6942ca17 > # Parent ffd1a15d456342caba744f5049b97862fcb697c7 > # Available At https://hg.logilab.org/users/dlaxalde/hg > # hg pull https://hg.logilab.org/users/dlaxalde/hg -r a7b9bc1af8b8 > # EXP-Topic linerange-log/hgweb-filelog > hgweb: add a "patch" query parameter to filelog command > @@ -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) Got an exception at hidden revision '5cb3b7d1f50f' which had been rebased (in my local repo.) Perhaps linkrev wouldn't be adjusted because we walk revision numbers, not a history of filelog. Traceback (most recent call last): File "mercurial/hgweb/server.py", line 100, in do_POST self.do_write() File "mercurial/hgweb/server.py", line 93, in do_write self.do_hgweb() File "mercurial/hgweb/server.py", line 161, in do_hgweb for chunk in self.server.application(env, self._start_response): File "mercurial/hgweb/hgweb_mod.py", line 315, in run_wsgi for r in self._runwsgi(req, repo): File "mercurial/util.py", line 867, in increasingchunks for chunk in source: File "mercurial/templater.py", line 1035, in _flatten for j in _flatten(i): File "mercurial/templater.py", line 1035, in _flatten for j in _flatten(i): File "mercurial/templater.py", line 1035, in _flatten for j in _flatten(i): File "mercurial/templater.py", line 1035, in _flatten for j in _flatten(i): File "mercurial/templater.py", line 1035, in _flatten for j in _flatten(i): File "mercurial/templater.py", line 1027, in _flatten for i in thing: File "mercurial/hgweb/webutil.py", line 467, in diffs diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts) File "mercurial/patch.py", line 2283, in diffhunks ctx1 = repo[node1] File "mercurial/localrepo.py", line 579, in __getitem__ return context.changectx(self, changeid) File "mercurial/context.py", line 526, in __init__ _("unknown revision '%s'") % changeid) RepoLookupError: unknown revision '5cb3b7d1f50f9857cc5316d3211789158deab238' > + <span id="l1.1" class="minusline">--- /dev/null Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.1"></a> We'll need a prefix to make 'id' unique.
Yuya Nishihara a écrit : > On Sat, 25 Mar 2017 10:20:57 +0100, Denis Laxalde wrote: >> # HG changeset patch >> # User Denis Laxalde <denis.laxalde@logilab.fr> >> # Date 1489398073 -3600 >> # Mon Mar 13 10:41:13 2017 +0100 >> # Node ID a7b9bc1af8b81c332cf34960f581359e6942ca17 >> # Parent ffd1a15d456342caba744f5049b97862fcb697c7 >> # Available At https://hg.logilab.org/users/dlaxalde/hg >> # hg pull https://hg.logilab.org/users/dlaxalde/hg -r a7b9bc1af8b8 >> # EXP-Topic linerange-log/hgweb-filelog >> hgweb: add a "patch" query parameter to filelog command > >> @@ -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) > > Got an exception at hidden revision '5cb3b7d1f50f' which had been rebased (in > my local repo.) Perhaps linkrev wouldn't be adjusted because we walk revision > numbers, not a history of filelog. > Maybe hidden revisions shouldn't be listed at all? I mean, without the "patch" query parameter, you don't get a crash on the /log/<rev>/<file> view, but a 404 when following a link pointing to a hidden revision in the table, so these log entries are arguably not very useful. > >> + <span id="l1.1" class="minusline">--- /dev/null Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.1"></a> > > We'll need a prefix to make 'id' unique. > That's true. Will work on a follow-up.
On Thu, 30 Mar 2017 17:10:28 +0200, Denis Laxalde wrote: > Yuya Nishihara a écrit : > > On Sat, 25 Mar 2017 10:20:57 +0100, Denis Laxalde wrote: > >> # HG changeset patch > >> # User Denis Laxalde <denis.laxalde@logilab.fr> > >> # Date 1489398073 -3600 > >> # Mon Mar 13 10:41:13 2017 +0100 > >> # Node ID a7b9bc1af8b81c332cf34960f581359e6942ca17 > >> # Parent ffd1a15d456342caba744f5049b97862fcb697c7 > >> # Available At https://hg.logilab.org/users/dlaxalde/hg > >> # hg pull https://hg.logilab.org/users/dlaxalde/hg -r a7b9bc1af8b8 > >> # EXP-Topic linerange-log/hgweb-filelog > >> hgweb: add a "patch" query parameter to filelog command > > > >> @@ -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) > > > > Got an exception at hidden revision '5cb3b7d1f50f' which had been rebased (in > > my local repo.) Perhaps linkrev wouldn't be adjusted because we walk revision > > numbers, not a history of filelog. > > > > Maybe hidden revisions shouldn't be listed at all? I mean, without the > "patch" query parameter, you don't get a crash on the /log/<rev>/<file> > view, > but a 404 when following a link pointing to a hidden revision in the > table, so these log entries are arguably not very useful. Hidden revisions aren't listed. I suspect fctx.changectx() would return a hidden changectx because fctx wasn't traversed from a visible parent and bypassed linkrev adjustment.
On Fri, 31 Mar 2017 00:37:22 +0900, Yuya Nishihara wrote: > On Thu, 30 Mar 2017 17:10:28 +0200, Denis Laxalde wrote: > > Yuya Nishihara a écrit : > > > On Sat, 25 Mar 2017 10:20:57 +0100, Denis Laxalde wrote: > > >> # HG changeset patch > > >> # User Denis Laxalde <denis.laxalde@logilab.fr> > > >> # Date 1489398073 -3600 > > >> # Mon Mar 13 10:41:13 2017 +0100 > > >> # Node ID a7b9bc1af8b81c332cf34960f581359e6942ca17 > > >> # Parent ffd1a15d456342caba744f5049b97862fcb697c7 > > >> # Available At https://hg.logilab.org/users/dlaxalde/hg > > >> # hg pull https://hg.logilab.org/users/dlaxalde/hg -r a7b9bc1af8b8 > > >> # EXP-Topic linerange-log/hgweb-filelog > > >> hgweb: add a "patch" query parameter to filelog command > > > > > >> @@ -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) > > > > > > Got an exception at hidden revision '5cb3b7d1f50f' which had been rebased (in > > > my local repo.) Perhaps linkrev wouldn't be adjusted because we walk revision > > > numbers, not a history of filelog. > > > > > > > Maybe hidden revisions shouldn't be listed at all? I mean, without the > > "patch" query parameter, you don't get a crash on the /log/<rev>/<file> > > view, > > but a 404 when following a link pointing to a hidden revision in the > > table, so these log entries are arguably not very useful. > > Hidden revisions aren't listed. I was wrong. Hidden revisions are listed. Maybe we'll need the logic which "hg log FILE" uses.
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')