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

login
register
mail settings
Submitter Jan Halla
Date April 16, 2016, 6:35 p.m.
Message ID <20160416183502.GA5305@tlapka.roztoky.net>
Download mbox | patch
Permalink /patch/14684/
State Not Applicable
Headers show

Comments

Jan Halla - April 16, 2016, 6:35 p.m.
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

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -805,12 +805,16 @@  class queue(object):
 
     def patch(self, repo, patchfile):
         '''Apply patchfile  to the working directory.
         patchfile: name of patch file'''
         files = set()
+        if not repo.ui.plain() and repo.ui.configbool('diff', 'noprefix', False):
+            strip = 0
+        else:
+            strip = 1
         try:
-            fuzz = patchmod.patch(self.ui, repo, patchfile, strip=1,
+            fuzz = patchmod.patch(self.ui, repo, patchfile, strip=strip,
                                   files=files, eolmode=None)
             return (True, list(files), fuzz)
         except Exception as inst:
             self.ui.note(str(inst) + '\n')
             if not self.ui.verbose: