diff hgext/narrow/narrowdirstate.py @ 38869:ad24b581e4d9

narrow: call narrowspec.{save,restore,clear}backup directly I want to move .hg/narrowspec to .hg/store/narrowspec and we need to decouple the narrowspec update from the dirstate update for that. This patch lets the callers call the narrowspec backup functions directly, in addition to the dirstate backup functions. The narrowspec methods are made to check if narrowing is enabled. For that, a repo instance was needed, which all the callers luckily already had available. Differential Revision: https://phab.mercurial-scm.org/D4096
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 03 Aug 2018 11:09:41 -0700
parents fed6fe856333
children 1a7d901a0a0c
line wrap: on
line diff
--- a/hgext/narrow/narrowdirstate.py	Sat Aug 04 23:15:06 2018 -0700
+++ b/hgext/narrow/narrowdirstate.py	Fri Aug 03 11:09:41 2018 -0700
@@ -11,7 +11,6 @@
 from mercurial import (
     error,
     match as matchmod,
-    narrowspec,
 )
 
 def wrapdirstate(repo, dirstate):
@@ -28,10 +27,6 @@
             return fn(self, *args)
         return _wrapper
 
-    def _narrowbackupname(backupname):
-        assert 'dirstate' in backupname
-        return backupname.replace('dirstate', narrowspec.FILENAME)
-
     class narrowdirstate(dirstate.__class__):
         def walk(self, match, subrepos, unknown, ignored, full=True,
                  narrowonly=True):
@@ -77,18 +72,5 @@
                 allfiles = [f for f in allfiles if repo.narrowmatch()(f)]
             super(narrowdirstate, self).rebuild(parent, allfiles, changedfiles)
 
-        def restorebackup(self, tr, backupname):
-            narrowspec.restorebackup(self._opener,
-                                     _narrowbackupname(backupname))
-            super(narrowdirstate, self).restorebackup(tr, backupname)
-
-        def savebackup(self, tr, backupname):
-            super(narrowdirstate, self).savebackup(tr, backupname)
-            narrowspec.savebackup(self._opener, _narrowbackupname(backupname))
-
-        def clearbackup(self, tr, backupname):
-            super(narrowdirstate, self).clearbackup(tr, backupname)
-            narrowspec.clearbackup(self._opener, _narrowbackupname(backupname))
-
     dirstate.__class__ = narrowdirstate
     return dirstate