# HG changeset patch # User Boris Feld # Date 1508500830 -7200 # Node ID 611ac10f1fae062b3129eb995d859b8734023613 # Parent 3eca2cbdc4985b641ce190d636f6afab23f8def7 effect-flag: remove wrapping of createmarkers for Mercurial 4.4 Now that effect-flag has landed in Mercurial 4.4, we don't need to wrap createmarkers for this version anymore. diff -r 3eca2cbdc498 -r 611ac10f1fae hgext3rd/evolve/obshistory.py --- a/hgext3rd/evolve/obshistory.py Fri Oct 20 14:56:03 2017 +0200 +++ b/hgext3rd/evolve/obshistory.py Fri Oct 20 14:00:30 2017 +0200 @@ -631,46 +631,48 @@ return False return True -@eh.wrapfunction(obsolete, 'createmarkers') -def createmarkerswithbits(orig, repo, relations, flag=0, date=None, - metadata=None, **kwargs): - """compute 'effect-flag' and augment the created markers +# Wrap pre Mercurial 4.4 createmarkers that didn't included effect-flag +if not util.safehasattr(obsutil, 'geteffectflag'): + @eh.wrapfunction(obsolete, 'createmarkers') + def createmarkerswithbits(orig, repo, relations, flag=0, date=None, + metadata=None, **kwargs): + """compute 'effect-flag' and augment the created markers - Wrap obsolete.createmarker in order to compute the effect of each - relationship and store them as flag in the metadata. + Wrap obsolete.createmarker in order to compute the effect of each + relationship and store them as flag in the metadata. - While we experiment, we store flag in a metadata field. This field is - "versionned" to easilly allow moving to other meaning for flags. + While we experiment, we store flag in a metadata field. This field is + "versionned" to easilly allow moving to other meaning for flags. - The comparison of description or other infos just before creating the obs - marker might induce overhead in some cases. However it is a good place to - start since it automatically makes all markers creation recording more - meaningful data. In the future, we can introduce way for commands to - provide precomputed effect to avoid the overhead. - """ - if not repo.ui.configbool('experimental', 'evolution.effect-flags', **efd): - return orig(repo, relations, flag, date, metadata, **kwargs) - if metadata is None: - metadata = {} - tr = repo.transaction('add-obsolescence-marker') - try: - for r in relations: - # Compute the effect flag for each obsmarker - effect = geteffectflag(r) + The comparison of description or other infos just before creating the obs + marker might induce overhead in some cases. However it is a good place to + start since it automatically makes all markers creation recording more + meaningful data. In the future, we can introduce way for commands to + provide precomputed effect to avoid the overhead. + """ + if not repo.ui.configbool('experimental', 'evolution.effect-flags', **efd): + return orig(repo, relations, flag, date, metadata, **kwargs) + if metadata is None: + metadata = {} + tr = repo.transaction('add-obsolescence-marker') + try: + for r in relations: + # Compute the effect flag for each obsmarker + effect = geteffectflag(r) - # Copy the metadata in order to add them, we copy because the - # effect flag might be different per relation - m = metadata.copy() - # we store the effect even if "0". This disctinct markers created - # without the feature with markers recording a no-op. - m['ef1'] = "%d" % effect + # Copy the metadata in order to add them, we copy because the + # effect flag might be different per relation + m = metadata.copy() + # we store the effect even if "0". This disctinct markers created + # without the feature with markers recording a no-op. + m['ef1'] = "%d" % effect - # And call obsolete.createmarkers for creating the obsmarker for real - orig(repo, [r], flag, date, m, **kwargs) + # And call obsolete.createmarkers for creating the obsmarker for real + orig(repo, [r], flag, date, m, **kwargs) - tr.close() - finally: - tr.release() + tr.close() + finally: + tr.release() def _getobsfate(successorssets): """ Compute a changeset obsolescence fate based on his successorssets.