Patchwork [3,of,6] subrepo-git: use an official origvfs when appropriate

login
register
mail settings
Submitter Boris Feld
Date Nov. 26, 2018, 6:22 p.m.
Message ID <3d8d2de85c9afc06b7aa.1543256565@localhost.localdomain>
Download mbox | patch
Permalink /patch/36777/
State Accepted
Headers show

Comments

Boris Feld - Nov. 26, 2018, 6:22 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542913288 -3600
#      Thu Nov 22 20:01:28 2018 +0100
# Node ID 3d8d2de85c9afc06b7aad740aa1ad2c817d18dfa
# Parent  a83de6825f6aac64efc059e6224225b073d441f4
# EXP-Topic vfs.audit-rename
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 3d8d2de85c9a
subrepo-git: use an official origvfs when appropriate

The origvfs has the auditor properly set and can move file without issue.

The current code is currently working without errors because rename are not
audited, yet.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1806,11 +1806,15 @@  class gitsubrepo(abstractsubrepo):
         if not opts.get(r'no_backup'):
             status = self.status(None)
             names = status.modified
+            origvfs = scmutil.getorigvfs(self.ui, self._subparent)
+            if origvfs is None:
+                origvfs = self.wvfs
             for name in names:
                 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)
+                name = self.wvfs.join(name)
+                origvfs.rename(name, bakname)
 
         if not opts.get(r'dry_run'):
             self.get(substate, overwrite=True)