Mercurial > hg
changeset 16456:42862d64aa8f
journal: use tryread helper to backup files (issue3375)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 17 Apr 2012 11:13:38 -0500 |
parents | 154219f3a6a4 |
children | 91196ebcaeed |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 6 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Apr 17 11:11:59 2012 -0500 +++ b/mercurial/localrepo.py Tue Apr 17 11:13:38 2012 -0500 @@ -743,28 +743,16 @@ return [undoname(x) for x in self._journalfiles()] def _writejournal(self, desc): - # save dirstate for rollback - try: - ds = self.opener.read("dirstate") - except IOError: - ds = "" - self.opener.write("journal.dirstate", ds) + self.opener.write("journal.dirstate", + self.opener.tryread("dirstate")) self.opener.write("journal.branch", encoding.fromlocal(self.dirstate.branch())) self.opener.write("journal.desc", "%d\n%s\n" % (len(self), desc)) - - try: - bk = self.opener.read("bookmarks") - except IOError: - bk = "" - self.opener.write("journal.bookmarks", bk) - - phasesname = self.sjoin('phaseroots') - if os.path.exists(phasesname): - util.copyfile(phasesname, self.sjoin('journal.phaseroots')) - else: - self.sopener.write('journal.phaseroots', '') + self.opener.write("journal.bookmarks", + self.opener.tryread("bookmarks")) + self.sopener.write("journal.phaseroots", + self.sopener.tryread("phaseroots")) def recover(self): lock = self.lock()