From patchwork Fri Mar 24 22:34:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,7,V4] hgweb: add a "patch" query parameter to filelog command From: Augie Fackler X-Patchwork-Id: 19648 Message-Id: To: Denis Laxalde Cc: mercurial-devel Date: Fri, 24 Mar 2017 18:34:37 -0400 Can you take a look at this? + 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 wrote: > On Fri, Mar 24, 2017 at 08:57:35AM +0100, Denis Laxalde wrote: >> # HG changeset patch >> # User Denis Laxalde >> # 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} >> >> >> + {if(patch, '{diff}')} >> 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 >> a-branch >> >> >> + >> >> Thu, 01 Jan 1970 00:00:00 +0000 >> test >> @@ -229,6 +230,7 @@ tip - two revisions >> a-tag a-bookmark >> >> >> + >> >> >> >> @@ -340,6 +342,7 @@ second version - two revisions >> a-branch >> >> >> + >> >> Thu, 01 Jan 1970 00:00:00 +0000 >> test >> @@ -348,6 +351,7 @@ second version - two revisions >> a-tag a-bookmark >> >> >> + >> >> >> >> @@ -459,6 +463,7 @@ first deleted - one revision >> a-tag a-bookmark >> >> >> + >> >> >> >> @@ -570,6 +575,7 @@ first version - one revision >> a-tag a-bookmark >> >> >> + >> >> >> >> @@ -762,6 +768,135 @@ should show base link, use spartan becau >> >> >> >> +filelog with patch >> + >> + $ (get-with-headers.py localhost:$HGPORT 'log/4/a?patch=1') >> + 200 Script output follows >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + test: a history >> + > + href="/atom-log/tip/a" title="Atom feed for test:a" /> >> + > + href="/rss-log/tip/a" title="RSS feed for test:a" /> >> + >> + >> + >> +
>> + >> + >> +
>> + >> +

>> + log a @ 4:3f41bc784e7e >> + a-branch >> +

>> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> +
ageauthordescription
Thu, 01 Jan 1970 00:00:00 +0000test >> + second a >> + a-branch >> +
>> +  --- /dev/null    Thu Jan 01 00:00:00 1970 +0000
>> +  +++ b/a   Thu Jan 01 00:00:00 1970 +0000
>> +  @@ -0,0 +1,1 @@
>> +  +b
Thu, 01 Jan 1970 00:00:00 +0000test >> + first a >> + a-tag a-bookmark >> +
>> +  --- /dev/null    Thu Jan 01 00:00:00 1970 +0000
>> +  +++ b/a   Thu Jan 01 00:00:00 1970 +0000
>> +  @@ -0,0 +1,1 @@
>> +  +a
>> + >> + >> + >> +
>> +
>> + >> + >> + >> + >> + >> + >> + >> rss log >> >> $ (get-with-headers.py localhost:$HGPORT 'rss-log/tip/a') >> _______________________________________________ >> Mercurial-devel mailing list >> Mercurial-devel@mercurial-scm.org >> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel --- /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 -
Issue123: fixed the bug!
+ [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