changeset 35458:786289423e97

merge with stable
author Augie Fackler <augie@google.com>
date Tue, 19 Dec 2017 16:27:24 -0500
parents 44fd4cfc6c0a (current diff) 058c725925e3 (diff)
children 02ea370c2baa
files mercurial/cmdutil.py mercurial/debugcommands.py mercurial/hgweb/webutil.py tests/test-diffstat.t tests/test-hgweb-diffs.t
diffstat 5 files changed, 77 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Mon Dec 18 15:18:37 2017 -0800
+++ b/mercurial/cmdutil.py	Tue Dec 19 16:27:24 2017 -0500
@@ -1515,7 +1515,7 @@
                     match.uipath(matchroot), uirelroot))
 
     if stat:
-        diffopts = diffopts.copy(context=0)
+        diffopts = diffopts.copy(context=0, noprefix=False)
         width = 80
         if not ui.plain():
             width = ui.termwidth()
--- a/mercurial/debugcommands.py	Mon Dec 18 15:18:37 2017 -0800
+++ b/mercurial/debugcommands.py	Tue Dec 19 16:27:24 2017 -0500
@@ -2223,10 +2223,12 @@
     url = util.url(source)
     addr = None
 
-    if url.scheme == 'https':
-        addr = (url.host, url.port or 443)
-    elif url.scheme == 'ssh':
-        addr = (url.host, url.port or 22)
+    defaultport = {'https': 443, 'ssh': 22}
+    if url.scheme in defaultport:
+        try:
+            addr = (url.host, int(url.port or defaultport[url.scheme]))
+        except ValueError:
+            raise error.Abort(_("malformed port number in URL"))
     else:
         raise error.Abort(_("only https and ssh connections are supported"))
 
--- a/mercurial/hgweb/webutil.py	Mon Dec 18 15:18:37 2017 -0800
+++ b/mercurial/hgweb/webutil.py	Tue Dec 19 16:27:24 2017 -0500
@@ -547,7 +547,8 @@
 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
--- a/tests/test-diffstat.t	Mon Dec 18 15:18:37 2017 -0800
+++ b/tests/test-diffstat.t	Tue Dec 19 16:27:24 2017 -0500
@@ -69,6 +69,57 @@
    file with spaces |  Bin 
    1 files changed, 0 insertions(+), 0 deletions(-)
 
+Filename without "a/" or "b/" (issue5759):
+
+  $ hg diff --config 'diff.noprefix=1' -c1 --stat --git
+   a |  3 +++
+   1 files changed, 3 insertions(+), 0 deletions(-)
+  $ hg diff --config 'diff.noprefix=1' -c2 --stat --git
+   c |  Bin 
+   d |    0 
+   2 files changed, 0 insertions(+), 0 deletions(-)
+
+  $ hg log --config 'diff.noprefix=1' -r '1:' -p --stat --git
+  changeset:   1:3a95b07bb77f
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     appenda
+  
+   a |  3 +++
+   1 files changed, 3 insertions(+), 0 deletions(-)
+  
+  diff --git a a
+  --- a
+  +++ a
+  @@ -211,3 +211,6 @@
+   a
+   a
+   a
+  +a
+  +a
+  +a
+  
+  changeset:   2:c60a6c753773
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     createb
+  
+   c |  Bin 
+   d |    0 
+   2 files changed, 0 insertions(+), 0 deletions(-)
+  
+  diff --git c c
+  new file mode 100644
+  index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f76dd238ade08917e6712764a16a22005a50573d
+  GIT binary patch
+  literal 1
+  Ic${MZ000310RR91
+  
+  diff --git d d
+  new file mode 100644
+  
+
 diffstat within directories:
 
   $ hg rm -f 'file with spaces'
--- a/tests/test-hgweb-diffs.t	Mon Dec 18 15:18:37 2017 -0800
+++ b/tests/test-hgweb-diffs.t	Tue Dec 19 16:27:24 2017 -0500
@@ -306,6 +306,23 @@
   </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