mercurial/localrepo.py
changeset 16236 97efd26eb957
parent 16208 85db991780b7
child 16253 17f179805297
equal deleted inserted replaced
16235:eb39bbda167b 16236:97efd26eb957
   748         # abort here if the journal already exists
   748         # abort here if the journal already exists
   749         if os.path.exists(self.sjoin("journal")):
   749         if os.path.exists(self.sjoin("journal")):
   750             raise error.RepoError(
   750             raise error.RepoError(
   751                 _("abandoned transaction found - run hg recover"))
   751                 _("abandoned transaction found - run hg recover"))
   752 
   752 
   753         journalfiles = self._writejournal(desc)
   753         self._writejournal(desc)
   754         renames = [(x, undoname(x)) for x in journalfiles]
   754         renames = [(x, undoname(x)) for x in self._journalfiles()]
   755 
   755 
   756         tr = transaction.transaction(self.ui.warn, self.sopener,
   756         tr = transaction.transaction(self.ui.warn, self.sopener,
   757                                      self.sjoin("journal"),
   757                                      self.sjoin("journal"),
   758                                      aftertrans(renames),
   758                                      aftertrans(renames),
   759                                      self.store.createmode)
   759                                      self.store.createmode)
   760         self._transref = weakref.ref(tr)
   760         self._transref = weakref.ref(tr)
   761         return tr
   761         return tr
       
   762 
       
   763     def _journalfiles(self):
       
   764         return (self.sjoin('journal'), self.join('journal.dirstate'),
       
   765                 self.join('journal.branch'), self.join('journal.desc'),
       
   766                 self.join('journal.bookmarks'),
       
   767                 self.sjoin('journal.phaseroots'))
       
   768 
       
   769     def undofiles(self):
       
   770         return [undoname(x) for x in self._journalfiles()]
   762 
   771 
   763     def _writejournal(self, desc):
   772     def _writejournal(self, desc):
   764         # save dirstate for rollback
   773         # save dirstate for rollback
   765         try:
   774         try:
   766             ds = self.opener.read("dirstate")
   775             ds = self.opener.read("dirstate")
   780         phasesname = self.sjoin('phaseroots')
   789         phasesname = self.sjoin('phaseroots')
   781         if os.path.exists(phasesname):
   790         if os.path.exists(phasesname):
   782             util.copyfile(phasesname, self.sjoin('journal.phaseroots'))
   791             util.copyfile(phasesname, self.sjoin('journal.phaseroots'))
   783         else:
   792         else:
   784             self.sopener.write('journal.phaseroots', '')
   793             self.sopener.write('journal.phaseroots', '')
   785 
       
   786         return (self.sjoin('journal'), self.join('journal.dirstate'),
       
   787                 self.join('journal.branch'), self.join('journal.desc'),
       
   788                 self.join('journal.bookmarks'),
       
   789                 self.sjoin('journal.phaseroots'))
       
   790 
   794 
   791     def recover(self):
   795     def recover(self):
   792         lock = self.lock()
   796         lock = self.lock()
   793         try:
   797         try:
   794             if os.path.exists(self.sjoin("journal")):
   798             if os.path.exists(self.sjoin("journal")):