Mercurial > public > mercurial-scm > hg-stable
diff mercurial/scmutil.py @ 27651:07fc2f2134ba
origpath: move from cmdutil to scmutil
This is a lower-level function so it doesn't need to be in cmdutil, and putting
it here avoids a bunch of potential import cycle issues.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sat, 02 Jan 2016 03:02:57 -0800 |
parents | b8405d739149 |
children | 22e362da27cf |
line wrap: on
line diff
--- a/mercurial/scmutil.py Sun Nov 22 17:57:35 2015 -0800 +++ b/mercurial/scmutil.py Sat Jan 02 03:02:57 2016 -0800 @@ -838,6 +838,26 @@ '''Return a matcher that will efficiently match exactly these files.''' return matchmod.exact(repo.root, repo.getcwd(), files, badfn=badfn) +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 addremove(repo, matcher, prefix, opts=None, dry_run=None, similarity=None): if opts is None: opts = {}