Patchwork [Bug,5207] New: mq: qpush doesn't honor diff.noprefix

login
register
mail settings
Submitter Matt Mackall
Date April 16, 2016, 8:52 p.m.
Message ID <1460839947.9603.179.camel@selenic.com>
Download mbox | patch
Permalink /patch/14691/
State Not Applicable
Headers show

Comments

Matt Mackall - April 16, 2016, 8:52 p.m.
On Sat, 2016-04-16 at 20:35 +0200, Jan Halla wrote:
> On Sat, Apr 16, 2016 at 06:06:15PM +0000, mercurial-bugs@selenic.com wrote:
> > 
> > https://bz.mercurial-scm.org/show_bug.cgi?id=5207
> > 
> >             Bug ID: 5207
> >            Summary: mq: qpush doesn't honor diff.noprefix
> >            Product: Mercurial
> >            Version: 3.7.3
> >           Hardware: PC
> >                 OS: Linux
> >             Status: UNCONFIRMED
> >           Severity: bug
> >           Priority: wish
> >          Component: mq
> >           Assignee: bugzilla@selenic.com
> >           Reporter: hallik@roztoky.net
> >                 CC: mercurial-devel@selenic.com
> > 
> > When diff.noprefix is True qnew and qrefresh create patches without [a,b]/
> > prefix (which is correct) but qpush can't apply these patches. Example:
> > 
> > $> hg init
> > $> mkdir -p r/s
> > $> echo original > r/s/t.txt
> > $> hg commit -A -m orig
> > adding r/s/t.txt
> > $> echo change > r/s/t.txt 
> > $> hg --config diff.noprefix=True qnew p1.diff
> > $> cat .hg/patches/p1.diff 
> > # HG changeset patch
> > # Parent  36ef0c04be112b0212bd38af1e641a5c5be00206
> > 
> > diff --git r/s/t.txt r/s/t.txt
> > --- r/s/t.txt
> > +++ r/s/t.txt
> > @@ -1,1 +1,1 @@
> > -original
> > +change
> > $> hg qpop 
> > popping p1.diff
> > patch queue now empty
> > $> hg qpush
> > applying p1.diff
> > unable to find 's/t.txt' for patching
> > 1 out of 1 hunks FAILED -- saving rejects to file s/t.txt.rej
> > patch failed, unable to continue (try -v)
> > patch failed, rejects left in working directory
> > errors during apply, please fix and qrefresh p1.diff
> > 
> May be a patch for this bug:
> 
> # HG changeset patch
> # User Jan Halla <hallik@roztoky.net>
> # Date 1460831316 -7200
> #      Sat Apr 16 20:28:36 2016 +0200
> # Node ID 0248cf2a6e53ec054e247bdb0794e25bc1084b5a
> # Parent  d9539959167df7cb3acd08c4ab53d8e8a7f027cb
> mq: strip parameter of patch function honor diff.noprefix configuration
> (issue5207)
> 
> Set strip to 0 when not plain mode and diff.noprefix is true

This is ok, but the ideal fix we've previously discussed is to autodetect when
the a/ and b/ prefixes aren't present in the patch import code. Your version
will break if you change diff.noprefix in the middle of the stack.

It's also probably a mistake for mq to honor the noprefix setting at all until
we've fixed the import side. So for now we should probably do:


-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff -r 9d3e280864fb hgext/mq.py
--- a/hgext/mq.py	Sat Apr 16 15:14:25 2016 -0500
+++ b/hgext/mq.py	Sat Apr 16 15:25:26 2016 -0500
@@ -488,6 +488,8 @@ 
 
     def diffopts(self, opts=None, patchfn=None):
         diffopts = patchmod.diffopts(self.ui, opts)
+        # we're not prepared to import patches with no prefix
+        diffopts.noprefix = False
         if self.gitmode == 'auto':
             diffopts.upgrade = True
         elif self.gitmode == 'keep':