mercurial/localrepo.py
changeset 4613 3a645af7fb76
parent 4582 7de7a80e7422
child 4618 7c8f8b736365
equal deleted inserted replaced
4612:17ee7407097f 4613:3a645af7fb76
   584     def recover(self):
   584     def recover(self):
   585         l = self.lock()
   585         l = self.lock()
   586         if os.path.exists(self.sjoin("journal")):
   586         if os.path.exists(self.sjoin("journal")):
   587             self.ui.status(_("rolling back interrupted transaction\n"))
   587             self.ui.status(_("rolling back interrupted transaction\n"))
   588             transaction.rollback(self.sopener, self.sjoin("journal"))
   588             transaction.rollback(self.sopener, self.sjoin("journal"))
   589             self.reload()
   589             self.invalidate()
   590             return True
   590             return True
   591         else:
   591         else:
   592             self.ui.warn(_("no interrupted transaction available\n"))
   592             self.ui.warn(_("no interrupted transaction available\n"))
   593             return False
   593             return False
   594 
   594 
   599             lock = self.lock()
   599             lock = self.lock()
   600         if os.path.exists(self.sjoin("undo")):
   600         if os.path.exists(self.sjoin("undo")):
   601             self.ui.status(_("rolling back last transaction\n"))
   601             self.ui.status(_("rolling back last transaction\n"))
   602             transaction.rollback(self.sopener, self.sjoin("undo"))
   602             transaction.rollback(self.sopener, self.sjoin("undo"))
   603             util.rename(self.join("undo.dirstate"), self.join("dirstate"))
   603             util.rename(self.join("undo.dirstate"), self.join("dirstate"))
   604             self.reload()
   604             self.invalidate()
   605             self.wreload()
   605             self.dirstate.invalidate()
   606         else:
   606         else:
   607             self.ui.warn(_("no rollback information available\n"))
   607             self.ui.warn(_("no rollback information available\n"))
   608 
   608 
   609     def wreload(self):
   609     def invalidate(self):
   610         self.dirstate.reload()
   610         for a in "changelog manifest".split():
   611 
   611             if hasattr(self, a):
   612     def reload(self):
   612                 self.__delattr__(a)
   613         self.changelog.load()
       
   614         self.manifest.load()
       
   615         self.tagscache = None
   613         self.tagscache = None
   616         self.nodetagscache = None
   614         self.nodetagscache = None
   617 
   615 
   618     def do_lock(self, lockname, wait, releasefn=None, acquirefn=None,
   616     def do_lock(self, lockname, wait, releasefn=None, acquirefn=None,
   619                 desc=None):
   617                 desc=None):
   630         if acquirefn:
   628         if acquirefn:
   631             acquirefn()
   629             acquirefn()
   632         return l
   630         return l
   633 
   631 
   634     def lock(self, wait=1):
   632     def lock(self, wait=1):
   635         return self.do_lock(self.sjoin("lock"), wait, acquirefn=self.reload,
   633         return self.do_lock(self.sjoin("lock"), wait,
       
   634                             acquirefn=self.invalidate,
   636                             desc=_('repository %s') % self.origroot)
   635                             desc=_('repository %s') % self.origroot)
   637 
   636 
   638     def wlock(self, wait=1):
   637     def wlock(self, wait=1):
   639         return self.do_lock(self.join("wlock"), wait, self.dirstate.write,
   638         return self.do_lock(self.join("wlock"), wait, self.dirstate.write,
   640                             self.wreload,
   639                             self.dirstate.invalidate,
   641                             desc=_('working directory of %s') % self.origroot)
   640                             desc=_('working directory of %s') % self.origroot)
   642 
   641 
   643     def filecommit(self, fn, manifest1, manifest2, linkrev, transaction, changelist):
   642     def filecommit(self, fn, manifest1, manifest2, linkrev, transaction, changelist):
   644         """
   643         """
   645         commit an individual file as part of a larger transaction
   644         commit an individual file as part of a larger transaction
  1930         if elapsed <= 0:
  1929         if elapsed <= 0:
  1931             elapsed = 0.001
  1930             elapsed = 0.001
  1932         self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
  1931         self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
  1933                        (util.bytecount(total_bytes), elapsed,
  1932                        (util.bytecount(total_bytes), elapsed,
  1934                         util.bytecount(total_bytes / elapsed)))
  1933                         util.bytecount(total_bytes / elapsed)))
  1935         self.reload()
  1934         self.invalidate()
  1936         return len(self.heads()) + 1
  1935         return len(self.heads()) + 1
  1937 
  1936 
  1938     def clone(self, remote, heads=[], stream=False):
  1937     def clone(self, remote, heads=[], stream=False):
  1939         '''clone remote repository.
  1938         '''clone remote repository.
  1940 
  1939