Mercurial > hg > evolve
changeset 205:7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Mon, 23 Apr 2012 14:54:06 +0200 |
parents | 50039b9b535e |
children | 80f602e6ae8a |
files | hgext/obsolete.py |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/obsolete.py +++ b/hgext/obsolete.py @@ -369,8 +369,7 @@ # /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\ if util.safehasattr(repo, '_journalfiles'): # Hg 2.2 o_journalfiles = repo._journalfiles - else: # XXX remove this bloc while breaking support to Hg 2.1 - o_writejournal = repo._writejournal + o_writejournal = repo._writejournal class obsoletingrepo(repo.__class__): @@ -543,9 +542,20 @@ # /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\ if util.safehasattr(repo, '_journalfiles'): # Hg 2.2 def _journalfiles(self): - return o_journalfiles() + ('journal.obsolete-relations',) + return o_journalfiles() + (self.join('journal.obsolete-relations'),) + + def _writejournal(self, desc): + """wrapped version of _writejournal that save obsolete data""" + o_writejournal(desc) + filename = 'obsolete-relations' + filepath = self.join(filename) + if os.path.exists(filepath): + journalname = 'journal.' + filename + journalpath = self.join(journalname) + util.copyfile(filepath, journalpath) + else: # XXX remove this bloc while breaking support to Hg 2.1 - def _writejournal(self, desc): + def _writejournal(self, desc): """wrapped version of _writejournal that save obsolete data""" entries = list(o_writejournal(desc)) filename = 'obsolete-relations' @@ -557,15 +567,16 @@ entries.append(journalpath) return tuple(entries) - def _rollback(self, dryrun=False, **kwargs): + def _rollback(self, dryrun, force): """wrapped version of _rollback that restore obsolete data""" - ret = o_rollback(dryrun, **kwargs) + ret = o_rollback(dryrun, force) if not (ret or dryrun): #rollback did not failed src = self.join('undo.obsolete-relations') dst = self.join('obsolete-relations') if os.path.exists(src): util.rename(src, dst) - elif os.path.exists(dst): #unlink in any case + elif os.path.exists(dst): + # If no state was saved because the file did not existed before. os.unlink(dst) # invalidate cache self.__dict__.pop('_obssubrels', None)