comparison mercurial/localrepo.py @ 38908: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 df0873ab5c14
children 576eef1ab43d
comparison
equal deleted inserted replaced
38907:0db50770f388 38908:ad24b581e4d9
1371 # transaction running 1371 # transaction running
1372 repo.dirstate.write(None) 1372 repo.dirstate.write(None)
1373 else: 1373 else:
1374 # discard all changes (including ones already written 1374 # discard all changes (including ones already written
1375 # out) in this transaction 1375 # out) in this transaction
1376 narrowspec.restorebackup(self, 'journal.narrowspec')
1376 repo.dirstate.restorebackup(None, 'journal.dirstate') 1377 repo.dirstate.restorebackup(None, 'journal.dirstate')
1377 1378
1378 repo.invalidate(clearfilecache=True) 1379 repo.invalidate(clearfilecache=True)
1379 1380
1380 tr = transaction.transaction(rp, self.svfs, vfsmap, 1381 tr = transaction.transaction(rp, self.svfs, vfsmap,
1459 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] 1460 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
1460 1461
1461 @unfilteredmethod 1462 @unfilteredmethod
1462 def _writejournal(self, desc): 1463 def _writejournal(self, desc):
1463 self.dirstate.savebackup(None, 'journal.dirstate') 1464 self.dirstate.savebackup(None, 'journal.dirstate')
1465 narrowspec.savebackup(self, 'journal.narrowspec')
1464 self.vfs.write("journal.branch", 1466 self.vfs.write("journal.branch",
1465 encoding.fromlocal(self.dirstate.branch())) 1467 encoding.fromlocal(self.dirstate.branch()))
1466 self.vfs.write("journal.desc", 1468 self.vfs.write("journal.desc",
1467 "%d\n%s\n" % (len(self), desc)) 1469 "%d\n%s\n" % (len(self), desc))
1468 self.vfs.write("journal.bookmarks", 1470 self.vfs.write("journal.bookmarks",
1546 parents[1] not in self.changelog.nodemap) 1548 parents[1] not in self.changelog.nodemap)
1547 if parentgone: 1549 if parentgone:
1548 # prevent dirstateguard from overwriting already restored one 1550 # prevent dirstateguard from overwriting already restored one
1549 dsguard.close() 1551 dsguard.close()
1550 1552
1553 narrowspec.restorebackup(self, 'undo.narrowspec')
1551 self.dirstate.restorebackup(None, 'undo.dirstate') 1554 self.dirstate.restorebackup(None, 'undo.dirstate')
1552 try: 1555 try:
1553 branch = self.vfs.read('undo.branch') 1556 branch = self.vfs.read('undo.branch')
1554 self.dirstate.setbranch(encoding.tolocal(branch)) 1557 self.dirstate.setbranch(encoding.tolocal(branch))
1555 except IOError: 1558 except IOError: