Patchwork [1,of,2,STABLE] hgweb: disable diff.noprefix option for diffstat

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 17, 2017, 11:50 a.m.
Message ID <5a2aea363d40e2a20031.1513511433@mimosa>
Download mbox | patch
Permalink /patch/26329/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 17, 2017, 11:50 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1513502895 -32400
#      Sun Dec 17 18:28:15 2017 +0900
# Branch stable
# Node ID 5a2aea363d40e2a200317d366e61a390e39fd9fa
# Parent  88572b7e50fd5f0e86329943795f6a3e38a2ec31
hgweb: disable diff.noprefix option for diffstat

Copied from cf1e15f91c90.
Gregory Szorc - Dec. 17, 2017, 6:58 p.m.
On Sun, Dec 17, 2017 at 3:50 AM, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1513502895 -32400
> #      Sun Dec 17 18:28:15 2017 +0900
> # Branch stable
> # Node ID 5a2aea363d40e2a200317d366e61a390e39fd9fa
> # Parent  88572b7e50fd5f0e86329943795f6a3e38a2ec31
> hgweb: disable diff.noprefix option for diffstat
>

Queued for stable.


>
> Copied from cf1e15f91c90.
>
> diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
> --- a/mercurial/hgweb/webutil.py
> +++ b/mercurial/hgweb/webutil.py
> @@ -545,7 +545,8 @@ def compare(tmpl, context, leftlines, ri
>  def diffstatgen(ctx, basectx):
>      '''Generator function that provides the diffstat data.'''
>
> -    stats = patch.diffstatdata(util.iterlines(ctx.diff(basectx)))
> +    stats = patch.diffstatdata(
> +        util.iterlines(ctx.diff(basectx, noprefix=False)))
>      maxname, maxtotal, addtotal, removetotal, binary =
> patch.diffstatsum(stats)
>      while True:
>          yield stats, maxname, maxtotal, addtotal, removetotal, binary
> diff --git a/tests/test-hgweb-diffs.t b/tests/test-hgweb-diffs.t
> --- a/tests/test-hgweb-diffs.t
> +++ b/tests/test-hgweb-diffs.t
> @@ -306,6 +306,23 @@ diff removed file
>    </html>
>
>
> +set up hgweb with git diffs + noprefix
> +
> +  $ killdaemons.py
> +  $ hg serve --config 'diff.git=1' --config 'diff.noprefix=1' -p $HGPORT
> -d \
> +  > --pid-file=hg.pid -A access.log -E errors.log
> +  $ cat hg.pid >> $DAEMON_PIDS
> +
> +patch header and diffstat
> +
> +  $ get-with-headers.py localhost:$HGPORT 'rev/0' \
> +  > | egrep 'files changed|---|\+\+\+'
> +       2 files changed, 2 insertions(+), 0 deletions(-)
> +  <span id="l1.2" class="minusline">--- /dev/null</span><a
> href="#l1.2"></a>
> +  <span id="l1.3" class="plusline">+++ a</span><a href="#l1.3"></a>
> +  <span id="l2.2" class="minusline">--- /dev/null</span><a
> href="#l2.2"></a>
> +  <span id="l2.3" class="plusline">+++ b</span><a href="#l2.3"></a>
> +
>  set up hgweb with git diffs
>
>    $ killdaemons.py
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -545,7 +545,8 @@  def compare(tmpl, context, leftlines, ri
 def diffstatgen(ctx, basectx):
     '''Generator function that provides the diffstat data.'''
 
-    stats = patch.diffstatdata(util.iterlines(ctx.diff(basectx)))
+    stats = patch.diffstatdata(
+        util.iterlines(ctx.diff(basectx, noprefix=False)))
     maxname, maxtotal, addtotal, removetotal, binary = patch.diffstatsum(stats)
     while True:
         yield stats, maxname, maxtotal, addtotal, removetotal, binary
diff --git a/tests/test-hgweb-diffs.t b/tests/test-hgweb-diffs.t
--- a/tests/test-hgweb-diffs.t
+++ b/tests/test-hgweb-diffs.t
@@ -306,6 +306,23 @@  diff removed file
   </html>
   
 
+set up hgweb with git diffs + noprefix
+
+  $ killdaemons.py
+  $ hg serve --config 'diff.git=1' --config 'diff.noprefix=1' -p $HGPORT -d \
+  > --pid-file=hg.pid -A access.log -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+
+patch header and diffstat
+
+  $ get-with-headers.py localhost:$HGPORT 'rev/0' \
+  > | egrep 'files changed|---|\+\+\+'
+       2 files changed, 2 insertions(+), 0 deletions(-)
+  <span id="l1.2" class="minusline">--- /dev/null</span><a href="#l1.2"></a>
+  <span id="l1.3" class="plusline">+++ a</span><a href="#l1.3"></a>
+  <span id="l2.2" class="minusline">--- /dev/null</span><a href="#l2.2"></a>
+  <span id="l2.3" class="plusline">+++ b</span><a href="#l2.3"></a>
+
 set up hgweb with git diffs
 
   $ killdaemons.py