# HG changeset patch # User Christian Delahousse # Date 1447368966 21600 # Node ID dda0aa3baeddc95a3834bed1fc718c747f224bbf # Parent d47ac02fcefa2a32d1b1d9ce9b837247c0d9c470 cmdutil: add origbackuppath helper diff -r d47ac02fcefa -r dda0aa3baedd mercurial/cmdutil.py --- a/mercurial/cmdutil.py Tue Nov 10 11:16:25 2015 -0800 +++ b/mercurial/cmdutil.py Thu Nov 12 16:56:06 2015 -0600 @@ -3114,6 +3114,26 @@ finally: wlock.release() +def origpath(ui, repo, filepath): + '''customize where .orig files are created + + Fetch user defined path from config file: [ui] origbackuppath = + Fall back to default (filepath) if not specified + ''' + origbackuppath = ui.config('ui', 'origbackuppath', None) + if origbackuppath is None: + return filepath + ".orig" + + filepathfromroot = os.path.relpath(filepath, start=repo.root) + fullorigpath = repo.wjoin(origbackuppath, filepathfromroot) + + origbackupdir = repo.vfs.dirname(fullorigpath) + if not repo.vfs.exists(origbackupdir): + ui.note(_('creating directory: %s\n') % origbackupdir) + util.makedirs(origbackupdir) + + return fullorigpath + ".orig" + def _revertprefetch(repo, ctx, *files): """Let extension changing the storage layer prefetch content""" pass diff -r d47ac02fcefa -r dda0aa3baedd mercurial/help/config.txt --- a/mercurial/help/config.txt Tue Nov 10 11:16:25 2015 -0800 +++ b/mercurial/help/config.txt Thu Nov 12 16:56:06 2015 -0600 @@ -1496,6 +1496,10 @@ markers is different from the encoding of the merged files, serious problems may occur. +``origbackuppath`` + The path to a directory used to store generated .orig files. If the path is + not a directory, one will be created. + ``patch`` An optional external tool that ``hg import`` and some extensions will use for applying patches. By default Mercurial uses an