Mercurial > hg-stable
changeset 26937:dda0aa3baedd
cmdutil: add origbackuppath helper
author | Christian Delahousse <cdelahousse@fb.com> |
---|---|
date | Thu, 12 Nov 2015 16:56:06 -0600 |
parents | d47ac02fcefa |
children | 080276d377d9 |
files | mercurial/cmdutil.py mercurial/help/config.txt |
diffstat | 2 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 = <path> + 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
--- 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