def updatedir(*args, **kwargs): # updatedir moved from patch to cmdutil in hg 1.7 if hasattr(patch, 'updatedir'): patch.updatedir(*args, **kwargs) elif hasattr(cmdutil, 'updatedir'): cmdutil.updatedir(*args, **kwargs) else: # hg 1.9+ moved updatedir, and more importantly it's not needed with the way patch is called now.. scmutil.updatedir(*args, **kwargs)
def applypatch(ui, repo, patchname, strip=1, files=None, eolmode="strict", similarity=0): # in mercurial < 1.9, patch.patch expects files to be a dictionary that # will be filled with filenames that have been changed, and requires # that this be run through updatedir if files is None: files = set() filedict = {} try: retval = patch.patch(patchname, ui, strip=strip, cwd=repo.root, files=filedict, eolmode=eolmode) finally: updatedir(ui, repo, filedict) files.update(filedict.keys()) return retval
def applypatch(ui, repo, patchname, strip=1, files=None, eolmode='strict', similarity=0): # in mercurial < 1.9, patch.patch expects files to be a dictionary that # will be filled with filenames that have been changed, and requires # that this be run through updatedir if files is None: files = set() filedict = {} try: retval = patch.patch(patchname, ui, strip=strip, cwd=repo.root, files=filedict, eolmode=eolmode) finally: updatedir(ui, repo, filedict) files.update(filedict.keys()) return retval