hgext/obsolete.py
changeset 203 9799d0aa53c8
parent 202 83b7e2c62ac3
child 204 50039b9b535e
--- a/hgext/obsolete.py	Mon Apr 16 10:03:16 2012 +0200
+++ b/hgext/obsolete.py	Mon Apr 16 10:51:40 2012 +0200
@@ -364,9 +364,15 @@
     opull = repo.pull
     opush = repo.push
     o_rollback = repo._rollback
-    o_writejournal = repo._writejournal
     ocancopy = repo.cancopy
 
+    # /!\ 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
+
+
     class obsoletingrepo(repo.__class__):
 
         ### Public method
@@ -384,7 +390,10 @@
             obs = set()
             nm = self.changelog.nodemap
             for obj in self._obsobjrels:
-                rev = nm.get(obj, None)
+                try: # /!\api change in Hg 2.2 (e8d37b78acfb22ae2c1fb126c2)/!\
+                    rev = nm.get(obj)
+                except TypeError:  #XXX to remove while breaking Hg 2.1 support
+                    rev = nm.get(obj, None)
                 if rev is not None:
                     obs.add(rev)
             return obs
@@ -529,20 +538,24 @@
             return result
 
 
-
         ### rollback support
 
-        def _writejournal(self, desc):
-            """wrapped version of _writejournal that save obsolete data"""
-            entries = list(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)
-                entries.append(journalpath)
-            return tuple(entries)
+        # /!\ api change in  Hg 2.2 (97efd26eb9576f39590812ea9) /!\
+        if util.safehasattr(repo, '_journalfiles'): # Hg 2.2
+            def _journalfiles(self):
+                return o_journalfiles() + ('journal.obsolete-relations',) 
+        else: # XXX remove this bloc while breaking support to Hg 2.1
+             def _writejournal(self, desc):
+                """wrapped version of _writejournal that save obsolete data"""
+                entries = list(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)
+                    entries.append(journalpath)
+                return tuple(entries)
 
         def _rollback(self, dryrun=False, **kwargs):
             """wrapped version of _rollback that restore obsolete data"""