Re: [PATCH 2 of 6 stable] mq: create non-lossy patches, also with [diff] nobinary=True

2017-06-18 Thread Mads Kiilerich

On 06/18/2017 09:03 AM, Yuya Nishihara wrote:

The direction seems good, but can't we use patchmod.difffeatureopts() ?


Right, thanks. Didn't know about that one.

/Mads

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 6 stable] mq: create non-lossy patches, also with [diff] nobinary=True

2017-06-18 Thread Yuya Nishihara
On Sat, 17 Jun 2017 23:06:18 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich 
> # Date 1497727704 -7200
> #  Sat Jun 17 21:28:24 2017 +0200
> # Branch stable
> # Node ID 2dae66ed58c0e2440a344ab8de645436a4c1f1a6
> # Parent  1968bc846c16d0cf59a573daf879bb842daaf7f1
> mq: create non-lossy patches, also with [diff] nobinary=True
> 
> Users with custom diff configuration most certainly didn't intend it to make 
> mq
> drop changes.
> 
> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -503,7 +503,7 @@ class queue(object):
>  self.guardsdirty = False
>  self.activeguards = None
>  
> -def diffopts(self, opts=None, patchfn=None):
> +def diffopts(self, opts=None, patchfn=None, stable=False):
>  diffopts = patchmod.diffopts(self.ui, opts)
>  if self.gitmode == 'auto':
>  diffopts.upgrade = True
> @@ -516,6 +516,11 @@ class queue(object):
> ' got %s') % self.gitmode)
>  if patchfn:
>  diffopts = self.patchopts(diffopts, patchfn)
> +if stable:
> +# disable custom diff configuration - we need a stable format
> +diffopts.nobinary = False
> +# note: diff options showfunc and unified might influence diffs
> +# but don't do any harm

The direction seems good, but can't we use patchmod.difffeatureopts() ?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 6 stable] mq: create non-lossy patches, also with [diff] nobinary=True

2017-06-17 Thread Mads Kiilerich
# HG changeset patch
# User Mads Kiilerich 
# Date 1497727704 -7200
#  Sat Jun 17 21:28:24 2017 +0200
# Branch stable
# Node ID 2dae66ed58c0e2440a344ab8de645436a4c1f1a6
# Parent  1968bc846c16d0cf59a573daf879bb842daaf7f1
mq: create non-lossy patches, also with [diff] nobinary=True

Users with custom diff configuration most certainly didn't intend it to make mq
drop changes.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -503,7 +503,7 @@ class queue(object):
 self.guardsdirty = False
 self.activeguards = None
 
-def diffopts(self, opts=None, patchfn=None):
+def diffopts(self, opts=None, patchfn=None, stable=False):
 diffopts = patchmod.diffopts(self.ui, opts)
 if self.gitmode == 'auto':
 diffopts.upgrade = True
@@ -516,6 +516,11 @@ class queue(object):
' got %s') % self.gitmode)
 if patchfn:
 diffopts = self.patchopts(diffopts, patchfn)
+if stable:
+# disable custom diff configuration - we need a stable format
+diffopts.nobinary = False
+# note: diff options showfunc and unified might influence diffs
+# but don't do any harm
 return diffopts
 
 def patchopts(self, diffopts, *patches):
@@ -1178,7 +1183,7 @@ class queue(object):
 date = opts.get('date')
 if date:
 date = util.parsedate(date)
-diffopts = self.diffopts({'git': opts.get('git')})
+diffopts = self.diffopts({'git': opts.get('git')}, stable=True)
 if opts.get('checkname', True):
 self.checkpatchname(patchfn)
 inclsubs = checksubstate(repo)
@@ -1644,7 +1649,8 @@ class queue(object):
 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,
+ stable=True)
 if newuser:
 ph.setuser(newuser)
 if newdate:
diff --git a/tests/test-mq-git.t b/tests/test-mq-git.t
--- a/tests/test-mq-git.t
+++ b/tests/test-mq-git.t
@@ -241,7 +241,11 @@ Test how [diff] configuration influence 
   # Parent  fb9c4422b0f37dd576522dd9a3f99b825c177efe
   
   diff --git b b
-  Binary file b has changed
+  index 
78981922613b2afb6025042ff6bd878ac1994e85..f76dd238ade08917e6712764a16a22005a50573d
+  GIT binary patch
+  literal 1
+  Ic${MZ000310RR91
+  
 
   $ cd ..
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel