diff hgext/rebase.py @ 50408:82e5a9b1ef1e

extras: re-use Projection from jaraco.collections
author Jason R. Coombs <jaraco@jaraco.com>
date Tue, 21 Mar 2023 20:47:30 -0400
parents e8f1e0e295bb
children 771294224bf6
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Mar 21 17:21:45 2023 -0400
+++ b/hgext/rebase.py	Tue Mar 21 20:47:30 2023 -0400
@@ -24,6 +24,7 @@
     wdirrev,
 )
 from mercurial.pycompat import open
+from mercurial.thirdparty.jaraco.collections import Projection
 from mercurial import (
     bookmarks,
     cmdutil,
@@ -52,6 +53,7 @@
     util,
 )
 
+
 # The following constants are used throughout the rebase module. The ordering of
 # their values must be maintained.
 
@@ -93,19 +95,8 @@
     yield b'intermediate-source'
 
 
-def _project(orig, names):
-    """Project a subset of names from orig."""
-    names_saved = tuple(names)
-    values = (orig.get(name, None) for name in names_saved)
-    return {
-        name: value
-        for name, value in zip(names_saved, values)
-        if value is not None
-    }
-
-
 def _save_extras(ctx, extra):
-    extra.update(_project(ctx.extra(), retained_extras()))
+    extra.update(Projection(retained_extras(), ctx.extra()))
 
 
 def _savebranch(ctx, extra):