Patchwork [6,of,6] patch.applydiff: accept a prefix parameter

login
register
mail settings
Submitter Siddharth Agarwal
Date March 7, 2015, 8:44 a.m.
Message ID <8f72509cd5be9c0e9195.1425717888@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/7922/
State Accepted
Headers show

Comments

Siddharth Agarwal - March 7, 2015, 8:44 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1425709489 28800
#      Fri Mar 06 22:24:49 2015 -0800
# Node ID 8f72509cd5be9c0e91954a415de4022b082720c9
# Parent  54900e624fe9e04ab32e5edc6d5c7a8729a18132
patch.applydiff: accept a prefix parameter

This is preparation for upcoming patches that will add support for applying a
patch within a subdirectory.
Augie Fackler - March 7, 2015, 5:28 p.m.
On Sat, Mar 07, 2015 at 12:44:48AM -0800, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1425709489 28800
> #      Fri Mar 06 22:24:49 2015 -0800
> # Node ID 8f72509cd5be9c0e91954a415de4022b082720c9
> # Parent  54900e624fe9e04ab32e5edc6d5c7a8729a18132
> patch.applydiff: accept a prefix parameter

These look good and useful, queued.

>
> This is preparation for upcoming patches that will add support for applying a
> patch within a subdirectory.
>
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -1353,7 +1353,7 @@
>              raise PatchError(_('unexpected delta opcode 0'))
>      return out
>
> -def applydiff(ui, fp, backend, store, strip=1, eolmode='strict'):
> +def applydiff(ui, fp, backend, store, strip=1, prefix='', eolmode='strict'):
>      """Reads a patch from fp and tries to apply it.
>
>      Returns 0 for a clean patch, -1 if any rejects were found and 1 if
> @@ -1364,7 +1364,7 @@
>      patching then normalized according to 'eolmode'.
>      """
>      return _applydiff(ui, fp, patchfile, backend, store, strip=strip,
> -                      eolmode=eolmode)
> +                      prefix=prefix, eolmode=eolmode)
>
>  def _applydiff(ui, fp, patcher, backend, store, strip=1, prefix='',
>                 eolmode='strict'):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1353,7 +1353,7 @@ 
             raise PatchError(_('unexpected delta opcode 0'))
     return out
 
-def applydiff(ui, fp, backend, store, strip=1, eolmode='strict'):
+def applydiff(ui, fp, backend, store, strip=1, prefix='', eolmode='strict'):
     """Reads a patch from fp and tries to apply it.
 
     Returns 0 for a clean patch, -1 if any rejects were found and 1 if
@@ -1364,7 +1364,7 @@ 
     patching then normalized according to 'eolmode'.
     """
     return _applydiff(ui, fp, patchfile, backend, store, strip=strip,
-                      eolmode=eolmode)
+                      prefix=prefix, eolmode=eolmode)
 
 def _applydiff(ui, fp, patcher, backend, store, strip=1, prefix='',
                eolmode='strict'):