Commits

Pierre-Yves David committed 7ba30bd

obsolete: fix rollback wrapper for 2.2-rc

Comments (0)

Files changed (1)

hgext/obsolete.py

     # /!\ 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__):
         # /!\ 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'
                     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)