diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py --- a/hgext/largefiles/lfcommands.py +++ b/hgext/largefiles/lfcommands.py @@ -444,9 +444,9 @@ def updatelfiles(ui, repo, filelist=None updated, removed = 0, 0 for lfile in lfiles: abslfile = repo.wjoin(lfile) - abslfileorig = cmdutil.origpath(ui, repo, abslfile) + abslfileorig = scmutil.origpath(ui, repo, abslfile) absstandin = repo.wjoin(lfutil.standin(lfile)) - absstandinorig = cmdutil.origpath(ui, repo, absstandin) + absstandinorig = scmutil.origpath(ui, repo, absstandin) if os.path.exists(absstandin): if (os.path.exists(absstandinorig) and os.path.exists(abslfile)): diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -700,9 +700,9 @@ class queue(object): absf = repo.wjoin(f) if os.path.lexists(absf): self.ui.note(_('saving current version of %s as %s\n') % - (f, cmdutil.origpath(self.ui, repo, f))) - - absorig = cmdutil.origpath(self.ui, repo, absf) + (f, scmutil.origpath(self.ui, repo, f))) + + absorig = scmutil.origpath(self.ui, repo, absf) if copy: util.copyfile(absf, absorig) else: diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -512,7 +512,7 @@ def mergefiles(ui, repo, wctx, shelvectx # revert will overwrite unknown files, so move them out of the way for file in repo.status(unknown=True).unknown: if file in files: - util.rename(file, cmdutil.origpath(ui, repo, file)) + util.rename(file, scmutil.origpath(ui, repo, file)) ui.pushbuffer(True) cmdutil.revert(ui, repo, shelvectx, repo.dirstate.parents(), *pathtofiles(repo, files), diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3098,7 +3098,7 @@ def revert(ui, repo, ctx, parents, *pats xlist.append(abs) if dobackup and (backup <= dobackup or wctx[abs].cmp(ctx[abs])): - bakname = origpath(ui, repo, rel) + bakname = scmutil.origpath(ui, repo, rel) ui.note(_('saving current version of %s as %s\n') % (rel, bakname)) if not opts.get('dry_run'): @@ -3130,26 +3130,6 @@ def revert(ui, repo, ctx, parents, *pats 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 --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5953,7 +5953,7 @@ def resolve(ui, repo, *pats, **opts): if complete: try: util.rename(a + ".resolve", - cmdutil.origpath(ui, repo, a)) + scmutil.origpath(ui, repo, a)) except OSError as inst: if inst.errno != errno.ENOENT: raise @@ -5973,7 +5973,7 @@ def resolve(ui, repo, *pats, **opts): # replace filemerge's .orig file with our resolve file a = repo.wjoin(f) try: - util.rename(a + ".resolve", cmdutil.origpath(ui, repo, a)) + util.rename(a + ".resolve", scmutil.origpath(ui, repo, a)) except OSError as inst: if inst.errno != errno.ENOENT: raise diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -16,9 +16,9 @@ from .i18n import _ from .node import nullid, short from . import ( - cmdutil, error, match, + scmutil, simplemerge, tagmerge, templatekw, @@ -608,7 +608,7 @@ def _filemerge(premerge, repo, mynode, o b = temp("base", fca) c = temp("other", fco) if not fcd.isabsent(): - back = cmdutil.origpath(ui, repo, a) + back = scmutil.origpath(ui, repo, a) if premerge: util.copyfile(a, back) else: diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -838,6 +838,26 @@ def matchfiles(repo, files, badfn=None): '''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 = + 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 = {} diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -1910,7 +1910,7 @@ class gitsubrepo(abstractsubrepo): status = self.status(None) names = status.modified for name in names: - bakname = cmdutil.origpath(self.ui, self._subparent, name) + bakname = scmutil.origpath(self.ui, self._subparent, name) self.ui.note(_('saving current version of %s as %s\n') % (name, bakname)) self.wvfs.rename(name, bakname)