# HG changeset patch # User Alain Leufroy # Date 1334566300 -7200 # Node ID 9799d0aa53c82e965ccf35aca4aad83a2f6fc56b # Parent 83b7e2c62ac39693c2a2989cfa4f34487ef343e0 [obsolete] add supprt for futur Hg 2.2 diff -r 83b7e2c62ac3 -r 9799d0aa53c8 hgext/obsolete.py --- 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"""