comparison mercurial/localrepo.py @ 29190:e51f34183599

localrepo: use dirstate restorebackup instead of copying dirstate manually This is one step towards having dirstate manage its own storage. It will be useful for the implementation of sqldirstate [1]. I'm deleting two of the dirstate.invalidate() calls in localrepo because restorebackup method does that for us. [1] https://www.mercurial-scm.org/wiki/SQLDirstatePlan
author Mateusz Kwapich <mitrandir@fb.com>
date Fri, 13 May 2016 13:30:08 -0700
parents e0fc0ed41935
children ad1ce3c7af72
comparison
equal deleted inserted replaced
29189:930d4ee4647e 29190:e51f34183599
1040 # transaction, if tr.addfilegenerator (via 1040 # transaction, if tr.addfilegenerator (via
1041 # dirstate.write or so) isn't invoked while 1041 # dirstate.write or so) isn't invoked while
1042 # transaction running 1042 # transaction running
1043 repo.dirstate.write(None) 1043 repo.dirstate.write(None)
1044 else: 1044 else:
1045 # prevent in-memory changes from being written out at
1046 # the end of outer wlock scope or so
1047 repo.dirstate.invalidate()
1048
1049 # discard all changes (including ones already written 1045 # discard all changes (including ones already written
1050 # out) in this transaction 1046 # out) in this transaction
1051 repo.vfs.rename('journal.dirstate', 'dirstate') 1047 repo.dirstate.restorebackup(None, prefix='journal.')
1052 1048
1053 repo.invalidate(clearfilecache=True) 1049 repo.invalidate(clearfilecache=True)
1054 1050
1055 tr = transaction.transaction(rp, self.svfs, vfsmap, 1051 tr = transaction.transaction(rp, self.svfs, vfsmap,
1056 "journal", 1052 "journal",
1188 parents[1] not in self.changelog.nodemap) 1184 parents[1] not in self.changelog.nodemap)
1189 if parentgone: 1185 if parentgone:
1190 # prevent dirstateguard from overwriting already restored one 1186 # prevent dirstateguard from overwriting already restored one
1191 dsguard.close() 1187 dsguard.close()
1192 1188
1193 self.vfs.rename('undo.dirstate', 'dirstate') 1189 self.dirstate.restorebackup(None, prefix='undo.')
1194 try: 1190 try:
1195 branch = self.vfs.read('undo.branch') 1191 branch = self.vfs.read('undo.branch')
1196 self.dirstate.setbranch(encoding.tolocal(branch)) 1192 self.dirstate.setbranch(encoding.tolocal(branch))
1197 except IOError: 1193 except IOError:
1198 ui.warn(_('named branch could not be reset: ' 1194 ui.warn(_('named branch could not be reset: '
1199 'current branch is still \'%s\'\n') 1195 'current branch is still \'%s\'\n')
1200 % self.dirstate.branch()) 1196 % self.dirstate.branch())
1201 1197
1202 self.dirstate.invalidate()
1203 parents = tuple([p.rev() for p in self[None].parents()]) 1198 parents = tuple([p.rev() for p in self[None].parents()])
1204 if len(parents) > 1: 1199 if len(parents) > 1:
1205 ui.status(_('working directory now based on ' 1200 ui.status(_('working directory now based on '
1206 'revisions %d and %d\n') % parents) 1201 'revisions %d and %d\n') % parents)
1207 else: 1202 else: