##// END OF EJS Templates
revert: extract origvfs logic in a sub-function...
Boris Feld -
r40783:65591a51 default
parent child Browse files
Show More
@@ -814,21 +814,29 b' def parsefollowlinespattern(repo, rev, p'
814 raise error.ParseError(msg)
814 raise error.ParseError(msg)
815 return files[0]
815 return files[0]
816
816
817 def getorigvfs(ui, repo):
818 """return a vfs suitable to save 'orig' file
819
820 return None if no special directory is configured"""
821 origbackuppath = ui.config('ui', 'origbackuppath')
822 if not origbackuppath:
823 return None
824 return vfs.vfs(repo.wvfs.join(origbackuppath))
825
817 def origpath(ui, repo, filepath):
826 def origpath(ui, repo, filepath):
818 '''customize where .orig files are created
827 '''customize where .orig files are created
819
828
820 Fetch user defined path from config file: [ui] origbackuppath = <path>
829 Fetch user defined path from config file: [ui] origbackuppath = <path>
821 Fall back to default (filepath with .orig suffix) if not specified
830 Fall back to default (filepath with .orig suffix) if not specified
822 '''
831 '''
823 origbackuppath = ui.config('ui', 'origbackuppath')
832 origvfs = getorigvfs(ui, repo)
824 if not origbackuppath:
833 if origvfs is None:
825 return filepath + ".orig"
834 return filepath + ".orig"
826
835
827 # Convert filepath from an absolute path into a path inside the repo.
836 # Convert filepath from an absolute path into a path inside the repo.
828 filepathfromroot = util.normpath(os.path.relpath(filepath,
837 filepathfromroot = util.normpath(os.path.relpath(filepath,
829 start=repo.root))
838 start=repo.root))
830
839
831 origvfs = vfs.vfs(repo.wjoin(origbackuppath))
832 origbackupdir = origvfs.dirname(filepathfromroot)
840 origbackupdir = origvfs.dirname(filepathfromroot)
833 if not origvfs.isdir(origbackupdir) or origvfs.islink(origbackupdir):
841 if not origvfs.isdir(origbackupdir) or origvfs.islink(origbackupdir):
834 ui.note(_('creating directory: %s\n') % origvfs.join(origbackupdir))
842 ui.note(_('creating directory: %s\n') % origvfs.join(origbackupdir))
General Comments 0
You need to be logged in to leave comments. Login now