Anonymous avatar Anonymous committed a37defc

shelve: fix api changes and remove custom internalpatch

Comments (0)

Files changed (1)

tortoisehg/util/hgshelve.py

 
 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
 
-def internalpatch(patchobj, ui, strip, cwd, files={}):
-    """use builtin patch to apply <patchobj> to the working directory.
-    returns whether patch was applied with fuzz factor.
-
-    Adapted from patch.internalpatch() to support reverse patching.
-    """
-    try:
-        fp = file(patchobj, 'rb')
-    except TypeError:
-        fp = patchobj
-    if cwd:
-        curdir = os.getcwd()
-        os.chdir(cwd)
-    eolmode = ui.config('patch', 'eol', 'strict')
-    try:
-        eol = {'strict': None,
-               'auto': None,
-               'crlf': '\r\n',
-               'lf': '\n'}[eolmode.lower()]
-    except KeyError:
-        raise error.Abort(_('Unsupported line endings type: %s') % eolmode)
-    try:
-        if hasattr(patch, 'eolmodes'): # hg-1.5 hack
-            ret = patch.applydiff(ui, fp, files, strip=strip, eolmode=eolmode)
-        else:
-            ret = patch.applydiff(ui, fp, files, strip=strip, eol=eol)
-    finally:
-        if cwd:
-            os.chdir(curdir)
-    if ret < 0:
-        raise patch.PatchError
-    return ret > 0
-
 def scanpatch(fp):
     lr = patch.linereader(fp)
 
                 if dopatch:
                     ui.debug(_('applying patch\n'))
                     ui.debug(fp.getvalue())
-                    patch.internalpatch(fp, ui, 1, repo.root, eolmode=None)
+                    patch.internalpatch(ui, repo, fp, 1, eolmode=None)
                 del fp
 
                 # 3c. apply filtered patch to clean repo (shelve)
             try:
                 try:
                     fp.seek(0)
-                    pfiles = {}
-                    internalpatch(fp, ui, 1, repo.root, files=pfiles)
-                    hglib.updatedir(ui, repo, pfiles)
+                    pfiles = set()
+                    patch.internalpatch(ui, repo, fp, 1, files=pfiles)
+                    hglib.updatedir(ui, repo, dict([(z, None) for z in pfiles]))
                     patchdone = 1
                 except:
                     if opts['force']:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.