merge with stable
authorAugie Fackler <augie@google.com>
Tue, 12 Sep 2017 11:18:35 -0400
changeset 34120 07f09995e857
parent 34119 d4a5193332b3 (current diff)
parent 34090 987a85c42b08 (diff)
child 34121 ae95853c250a
merge with stable
hgext/mq.py
mercurial/debugcommands.py
--- a/hgext/mq.py	Fri Jun 30 03:39:32 2017 +0200
+++ b/hgext/mq.py	Tue Sep 12 11:18:35 2017 -0400
@@ -504,8 +504,11 @@
         self.guardsdirty = False
         self.activeguards = None
 
-    def diffopts(self, opts=None, patchfn=None):
-        diffopts = patchmod.diffopts(self.ui, opts)
+    def diffopts(self, opts=None, patchfn=None, plain=False):
+        """Return diff options tweaked for this mq use, possibly upgrading to
+        git format, and possibly plain and without lossy options."""
+        diffopts = patchmod.difffeatureopts(self.ui, opts,
+            git=True, whitespace=not plain, formatchanging=not plain)
         if self.gitmode == 'auto':
             diffopts.upgrade = True
         elif self.gitmode == 'keep':
@@ -1178,7 +1181,7 @@
         date = opts.get('date')
         if date:
             date = util.parsedate(date)
-        diffopts = self.diffopts({'git': opts.get('git')})
+        diffopts = self.diffopts({'git': opts.get('git')}, plain=True)
         if opts.get('checkname', True):
             self.checkpatchname(patchfn)
         inclsubs = checksubstate(repo)
@@ -1643,7 +1646,8 @@
                 substatestate = repo.dirstate['.hgsubstate']
 
             ph = patchheader(self.join(patchfn), self.plainmode)
-            diffopts = self.diffopts({'git': opts.get('git')}, patchfn)
+            diffopts = self.diffopts({'git': opts.get('git')}, patchfn,
+                                     plain=True)
             if newuser:
                 ph.setuser(newuser)
             if newdate:
--- a/mercurial/debugcommands.py	Fri Jun 30 03:39:32 2017 +0200
+++ b/mercurial/debugcommands.py	Tue Sep 12 11:18:35 2017 -0400
@@ -2085,10 +2085,10 @@
                             'Windows'))
 
     if not source:
+        if not repo:
+            raise error.Abort(_("there is no Mercurial repository here, and no "
+                                "server specified"))
         source = "default"
-    elif not repo:
-        raise error.Abort(_("there is no Mercurial repository here, and no "
-                            "server specified"))
 
     source, branches = hg.parseurl(ui.expandpath(source))
     url = util.url(source)
--- a/tests/test-mq-git.t	Fri Jun 30 03:39:32 2017 +0200
+++ b/tests/test-mq-git.t	Tue Sep 12 11:18:35 2017 -0400
@@ -208,5 +208,62 @@
   @@ -0,0 +1,1 @@
   +a
 
+Test how [diff] configuration influence and cause invalid or lossy patches:
+
+  $ cat <<EOF >> .hg/hgrc
+  > [mq]
+  > git = AUTO
+  > [diff]
+  > nobinary = True
+  > noprefix = True
+  > showfunc = True
+  > ignorews = True
+  > ignorewsamount = True
+  > ignoreblanklines = True
+  > unified = 1
+  > EOF
+
+  $ echo ' a' > a
+  $ hg qnew prepare -d '0 0'
+  $ echo '  a' > a
+  $ printf '\0' > b
+  $ echo >> c
+  $ hg qnew diff -d '0 0'
+
+  $ cat .hg/patches/prepare
+  # HG changeset patch
+  # Date 0 0
+  # Parent  cf0bfe72686a47d8d7d7b4529a3adb8b0b449a9f
+  
+  diff -r cf0bfe72686a -r fb9c4422b0f3 a
+  --- a/a
+  +++ b/a
+  @@ -1,1 +1,1 @@
+  -a
+  + a
+  $ cat .hg/patches/diff
+  # HG changeset patch
+  # Date 0 0
+  # Parent  fb9c4422b0f37dd576522dd9a3f99b825c177efe
+  
+  diff --git a/a b/a
+  --- a/a
+  +++ b/a
+  @@ -1,1 +1,1 @@
+  - a
+  +  a
+  diff --git a/b b/b
+  index 78981922613b2afb6025042ff6bd878ac1994e85..f76dd238ade08917e6712764a16a22005a50573d
+  GIT binary patch
+  literal 1
+  Ic${MZ000310RR91
+  
+  diff --git a/c b/c
+  --- a/c
+  +++ b/c
+  @@ -1,1 +1,2 @@
+   a
+  +
+
   $ cd ..