diff hgext/rebase.py @ 50643:cbcbf63b6dbf

rewrite: simplify the `retained_extras` extra logic First, we move the definition of value outside of the rebase extensions, as this apply to all rebase-like operation and some live in other place (like evolve). Second we make it a simple set, so that it is easy for an extension to add a new value in it. Third, we move the associated logic in core too. That make it easily available to other extensions. Fourth we simplify it usage, as the verbose version of the filtering is just a handful on line long, we are just going to test all the value for updates, so the Projection overlay is not bringing much here. Note that, we make it a module level set, is a key is worth preserving it is probably worth preserving in all cases. This was already the behavior prior to this change.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 25 May 2023 00:23:05 +0200
parents 771294224bf6
children a151fd01e98c
line wrap: on
line diff
--- a/hgext/rebase.py	Mon May 29 18:41:58 2023 +0200
+++ b/hgext/rebase.py	Thu May 25 00:23:05 2023 +0200
@@ -24,7 +24,6 @@
     wdirrev,
 )
 from mercurial.pycompat import open
-from mercurial.thirdparty.jaraco.collections import Projection
 from mercurial import (
     bookmarks,
     cmdutil,
@@ -86,19 +85,6 @@
     return 1
 
 
-def retained_extras():
-    """
-    Yield the names of the extras to be retained.
-    """
-    # graft
-    yield b'source'
-    yield b'intermediate-source'
-
-
-def _save_extras(ctx, extra):
-    extra.update(Projection(retained_extras(), ctx.extra()))
-
-
 def _savebranch(ctx, extra):
     extra[b'branch'] = ctx.branch()
 
@@ -199,7 +185,7 @@
         self.date = opts.get('date', None)
 
         e = opts.get('extrafn')  # internal, used by e.g. hgsubversion
-        self.extrafns = [_save_extras]
+        self.extrafns = [rewriteutil.preserve_extras_on_rebase]
         if e:
             self.extrafns = [e]