changeset 50441:e8f1e0e295bb

extras: expose 'retained_extras' for extensions to extend
author Jason R. Coombs <jaraco@jaraco.com>
date Tue, 21 Mar 2023 17:21:45 -0400
parents 2cd959fe631a
children 82e5a9b1ef1e
files hgext/rebase.py
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Mar 21 17:17:09 2023 -0400
+++ b/hgext/rebase.py	Tue Mar 21 17:21:45 2023 -0400
@@ -84,19 +84,28 @@
     return 1
 
 
-graft_extras = b'source', b'intermediate-source'
+def retained_extras():
+    """
+    Yield the names of the extras to be retained.
+    """
+    # graft
+    yield b'source'
+    yield b'intermediate-source'
 
 
 def _project(orig, names):
     """Project a subset of names from orig."""
-    values = (orig.get(name, None) for name in names)
+    names_saved = tuple(names)
+    values = (orig.get(name, None) for name in names_saved)
     return {
-        name: value for name, value in zip(names, values) if value is not None
+        name: value
+        for name, value in zip(names_saved, values)
+        if value is not None
     }
 
 
-def _savegraft(ctx, extra):
-    extra.update(_project(ctx.extra(), graft_extras))
+def _save_extras(ctx, extra):
+    extra.update(_project(ctx.extra(), retained_extras()))
 
 
 def _savebranch(ctx, extra):
@@ -199,7 +208,7 @@
         self.date = opts.get('date', None)
 
         e = opts.get('extrafn')  # internal, used by e.g. hgsubversion
-        self.extrafns = [_savegraft]
+        self.extrafns = [_save_extras]
         if e:
             self.extrafns = [e]