extras: expose 'retained_extras' for extensions to extend
authorJason R. Coombs <jaraco@jaraco.com>
Tue, 21 Mar 2023 17:21:45 -0400
changeset 50407 e8f1e0e295bb
parent 50406 2cd959fe631a
child 50408 82e5a9b1ef1e
extras: expose 'retained_extras' for extensions to extend
hgext/rebase.py
--- 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]