# HG changeset patch # User Pierre-Yves David # Date 1533166262 -7200 # Node ID 28824ad64a12ca3c67063e061a72d042dfbe64c3 # Parent ca7f02c9fa57033c5c0fbe66542c9cfb73851638 compat: restore compatibility with Mercurial <= 4.5 The __init__ arguments changed a lot in 4.6 and 4.7, lets do be as transparent as possible diff -r ca7f02c9fa57 -r 28824ad64a12 hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py Tue Jul 31 07:38:37 2018 -0500 +++ b/hgext3rd/evolve/compat.py Thu Aug 02 01:31:02 2018 +0200 @@ -28,11 +28,13 @@ changesetdisplayer = logcmdutil.changesetdisplayer changesetprinter = logcmdutil.changesetprinter displaygraph = logcmdutil.displaygraph + changesetdiffer = logcmdutil.changesetdiffer except (AttributeError, ImportError): from mercurial import cmdutil changesetdisplayer = cmdutil.show_changeset changesetprinter = cmdutil.changeset_printer displaygraph = cmdutil.displaygraph + changesetdiffer = None from . import ( exthelper, diff -r ca7f02c9fa57 -r 28824ad64a12 hgext3rd/evolve/obshistory.py --- a/hgext3rd/evolve/obshistory.py Tue Jul 31 07:38:37 2018 -0500 +++ b/hgext3rd/evolve/obshistory.py Thu Aug 02 01:31:02 2018 +0200 @@ -141,8 +141,16 @@ We display the node, description (if available) and various information about obsolescence markers affecting it""" - def __init__(self, ui, repo, differ=None, diffopts=None, buffered=False): - super(obsmarker_printer, self).__init__(ui, repo, differ=differ, diffopts=diffopts, buffered=buffered) + def __init__(self, ui, repo, *args, **kwargs): + + if kwargs.pop('obspatch', False): + if compat.changesetdiffer is None: + kwargs['matchfn'] = scmutil.matchall(repo) + else: + kwargs['differ'] = scmutil.matchall(repo) + + super(obsmarker_printer, self).__init__(ui, repo, *args, **kwargs) + diffopts = kwargs.get('diffopts', {}) # Compat 4.6 if not util.safehasattr(self, "_includediff"): @@ -415,11 +423,8 @@ return sorted(seen), nodesucc, nodeprec def _debugobshistorygraph(ui, repo, revs, opts): - matchfn = None - if opts.get('patch'): - matchfn = scmutil.matchall(repo) - displayer = obsmarker_printer(ui, repo.unfiltered(), matchfn, opts, buffered=True) + displayer = obsmarker_printer(ui, repo.unfiltered(), obspatch=True, diffopts=opts, buffered=True) edges = graphmod.asciiedges walker = _obshistorywalker(repo.unfiltered(), revs, opts.get('all', False), opts.get('filternonlocal', False)) compat.displaygraph(ui, repo, walker, displayer, edges)