changeset 12916:cfedc529e4a1

patch: remove unused applydiff() sourcefile argument
author Patrick Mezard <pmezard@gmail.com>
date Wed, 03 Nov 2010 21:11:07 +0100
parents df1b65f8b4d4
children a419cb2395d5
files mercurial/patch.py
diffstat 1 files changed, 11 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Wed Nov 03 21:11:05 2010 +0100
+++ b/mercurial/patch.py	Wed Nov 03 21:11:07 2010 +0100
@@ -974,7 +974,7 @@
     fp.seek(pos)
     return gitpatches
 
-def iterhunks(ui, fp, sourcefile=None):
+def iterhunks(ui, fp):
     """Read a patch and yield the following events:
     - ("file", afile, bfile, firsthunk): select a new target file.
     - ("hunk", hunk): a new hunk is ready to be applied, follows a
@@ -1006,7 +1006,7 @@
                 current_hunk.fix_newline()
             yield 'hunk', current_hunk
             current_hunk = None
-        if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or
+        if (state == BFILE and ((not context and x[0] == '@') or
             ((context is not False) and x.startswith('***************')))):
             if context is None and x.startswith('***************'):
                 context = True
@@ -1080,7 +1080,7 @@
             raise PatchError(_("malformed patch %s %s") % (afile,
                              current_hunk.desc))
 
-def applydiff(ui, fp, changed, strip=1, sourcefile=None, eolmode='strict'):
+def applydiff(ui, fp, changed, strip=1, eolmode='strict'):
     """Reads a patch from fp and tries to apply it.
 
     The dict 'changed' is filled in with all of the filenames changed
@@ -1094,13 +1094,10 @@
     Callers probably want to call 'cmdutil.updatedir' after this to
     apply certain categories of changes not done by this function.
     """
-    return _applydiff(
-        ui, fp, patchfile, copyfile,
-        changed, strip=strip, sourcefile=sourcefile, eolmode=eolmode)
+    return _applydiff(ui, fp, patchfile, copyfile, changed, strip=strip,
+                      eolmode=eolmode)
 
-
-def _applydiff(ui, fp, patcher, copyfn, changed, strip=1,
-               sourcefile=None, eolmode='strict'):
+def _applydiff(ui, fp, patcher, copyfn, changed, strip=1, eolmode='strict'):
     rejects = 0
     err = 0
     current_file = None
@@ -1115,7 +1112,7 @@
         current_file.write_rej()
         return len(current_file.rej)
 
-    for state, values in iterhunks(ui, fp, sourcefile):
+    for state, values in iterhunks(ui, fp):
         if state == 'hunk':
             if not current_file:
                 continue
@@ -1128,14 +1125,10 @@
             rejects += closefile()
             afile, bfile, first_hunk = values
             try:
-                if sourcefile:
-                    current_file = patcher(ui, sourcefile, opener,
-                                           eolmode=eolmode)
-                else:
-                    current_file, missing = selectfile(afile, bfile,
-                                                       first_hunk, strip)
-                    current_file = patcher(ui, current_file, opener,
-                                           missing=missing, eolmode=eolmode)
+                current_file, missing = selectfile(afile, bfile,
+                                                   first_hunk, strip)
+                current_file = patcher(ui, current_file, opener,
+                                       missing=missing, eolmode=eolmode)
             except PatchError, err:
                 ui.warn(str(err) + '\n')
                 current_file = None