comparison mercurial/subrepo.py @ 41603:ea5ebb8f72bd

subrepo: migrate to scmutil.backuppath() This has a test impact. It seems to me to be for the better. Differential Revision: https://phab.mercurial-scm.org/D5859
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 05 Feb 2019 09:43:34 -0800
parents 59025c9b3540
children 2c549abc6b85
comparison
equal deleted inserted replaced
41602:92bd3d86f2e0 41603:ea5ebb8f72bd
1822 def revert(self, substate, *pats, **opts): 1822 def revert(self, substate, *pats, **opts):
1823 self.ui.status(_('reverting subrepo %s\n') % substate[0]) 1823 self.ui.status(_('reverting subrepo %s\n') % substate[0])
1824 if not opts.get(r'no_backup'): 1824 if not opts.get(r'no_backup'):
1825 status = self.status(None) 1825 status = self.status(None)
1826 names = status.modified 1826 names = status.modified
1827 origvfs = scmutil.getorigvfs(self.ui, self._subparent)
1828 if origvfs is None:
1829 origvfs = self.wvfs
1830 for name in names: 1827 for name in names:
1831 bakname = scmutil.origpath(self.ui, self._subparent, name) 1828 # backuppath() expects a path relative to the parent repo (the
1829 # repo that ui.origbackuppath is relative to)
1830 parentname = os.path.join(self._path, name)
1831 bakname = scmutil.backuppath(self.ui, self._subparent,
1832 parentname)
1832 self.ui.note(_('saving current version of %s as %s\n') % 1833 self.ui.note(_('saving current version of %s as %s\n') %
1833 (name, os.path.relpath(bakname))) 1834 (name, os.path.relpath(bakname)))
1834 name = self.wvfs.join(name) 1835 util.rename(self.wvfs.join(name), bakname)
1835 origvfs.rename(name, bakname)
1836 1836
1837 if not opts.get(r'dry_run'): 1837 if not opts.get(r'dry_run'):
1838 self.get(substate, overwrite=True) 1838 self.get(substate, overwrite=True)
1839 return [] 1839 return []
1840 1840