Commit e637a342 authored by Sune Foldager's avatar Sune Foldager
Browse files

shelve: fix api changes and remove custom internalpatch

--HG--
branch : hgtk
parent afbddd929e4a
......@@ -27,39 +27,6 @@ from tortoisehg.hgtk import gtklib
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)
......@@ -540,7 +507,7 @@ def shelve(ui, repo, *pats, **opts):
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)
......@@ -601,9 +568,9 @@ def unshelve(ui, repo, *pats, **opts):
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']:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment