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 util.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 internalpatch(patchobj, ui, strip, cwd, reverse=False, 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. """ eolmode = ui.config("patch", "eol", "strict") try: eol = {"strict": None, "crlf": "\r\n", "lf": "\n"}[eolmode.lower()] except KeyError: raise util.Abort(_("Unsupported line endings type: %s") % eolmode) try: fp = file(patchobj, "rb") except TypeError: fp = patchobj if cwd: curdir = os.getcwd() os.chdir(cwd) try: ret = patch.applydiff(ui, fp, files, strip=strip, eol=eol) finally: if cwd: os.chdir(curdir) if ret < 0: raise PatchError return ret > 0
def internalpatch(patchobj, ui, strip, cwd, reverse=False, 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. """ eolmode = ui.config('patch', 'eol', 'strict') if eolmode.lower() not in patch.eolmodes: raise util.Abort(_('Unsupported line endings type: %s') % eolmode) try: fp = file(patchobj, 'rb') except TypeError: fp = patchobj if cwd: curdir = os.getcwd() os.chdir(cwd) try: ret = patch.applydiff(ui, fp, files, strip=strip, eolmode=eolmode) finally: if cwd: os.chdir(curdir) if ret < 0: raise PatchError return ret > 0
def patchrepoold(ui, meta, parentctx, patchfp): files = {} try: oldpatchfile = patch.patchfile olditerhunks = patch.iterhunks patch.patchfile = mempatchproxy(parentctx, files) patch.iterhunks = filteriterhunks(meta) try: # We can safely ignore the changed list since we are # handling non-git patches. Touched files are known # by our memory patcher. patch_st = patch.applydiff(ui, patchfp, {}, strip=0) finally: patch.patchfile = oldpatchfile patch.iterhunks = olditerhunks except patch.PatchError: # TODO: this happens if the svn server has the wrong mime # type stored and doesn't know a file is binary. It would # be better to do one file at a time and only do a # full fetch on files that had problems. raise BadPatchApply("patching failed") # if this patch didn't apply right, fall back to exporting the # entire rev. if patch_st == -1: assert False, "This should only happen on case-insensitive" " volumes." elif patch_st == 1: # When converting Django, I saw fuzz on .po files that was # causing revisions to end up failing verification. If that # can be fixed, maybe this won't ever be reached. raise BadPatchApply("patching succeeded with fuzz") return files
def internalpatch(patchobj, ui, strip, cwd, reverse=False, 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) try: ret = patch.applydiff(ui, fp, files, strip=strip, reverse=reverse) finally: if cwd: os.chdir(curdir) if ret < 0: raise PatchError return ret > 0
d2 = property_exec_set_re.sub('', d2) d2 = property_exec_removed_re.sub('', d2) # Here we ensure that all files, including the new empty ones # are marked as touched. Content is loaded on demand. touched_files.update(any_file_re.findall(d)) if d2.strip() and len(re.findall('\n[-+]', d2.strip())) > 0: try: oldpatchfile = patch.patchfile olditerhunks = patch.iterhunks patch.patchfile = mempatchproxy(parentctx, files_data) patch.iterhunks = filteriterhunks(meta) try: # We can safely ignore the changed list since we are # handling non-git patches. Touched files are known # by our memory patcher. patch_st = patch.applydiff(ui, cStringIO.StringIO(d2), {}, strip=0) finally: patch.patchfile = oldpatchfile patch.iterhunks = olditerhunks except patch.PatchError: # TODO: this happens if the svn server has the wrong mime # type stored and doesn't know a file is binary. It would # be better to do one file at a time and only do a # full fetch on files that had problems. raise BadPatchApply('patching failed') for x in files_data.iterkeys(): ui.note('M %s\n' % x) # if this patch didn't apply right, fall back to exporting the # entire rev. if patch_st == -1: assert False, ('This should only happen on case-insensitive'