hgext/rebase.py
changeset 50442 82e5a9b1ef1e
parent 50441 e8f1e0e295bb
child 50463 771294224bf6
equal deleted inserted replaced
50441:e8f1e0e295bb 50442:82e5a9b1ef1e
    22     nullrev,
    22     nullrev,
    23     short,
    23     short,
    24     wdirrev,
    24     wdirrev,
    25 )
    25 )
    26 from mercurial.pycompat import open
    26 from mercurial.pycompat import open
       
    27 from mercurial.thirdparty.jaraco.collections import Projection
    27 from mercurial import (
    28 from mercurial import (
    28     bookmarks,
    29     bookmarks,
    29     cmdutil,
    30     cmdutil,
    30     commands,
    31     commands,
    31     copies,
    32     copies,
    50     smartset,
    51     smartset,
    51     state as statemod,
    52     state as statemod,
    52     util,
    53     util,
    53 )
    54 )
    54 
    55 
       
    56 
    55 # The following constants are used throughout the rebase module. The ordering of
    57 # The following constants are used throughout the rebase module. The ordering of
    56 # their values must be maintained.
    58 # their values must be maintained.
    57 
    59 
    58 # Indicates that a revision needs to be rebased
    60 # Indicates that a revision needs to be rebased
    59 revtodo = -1
    61 revtodo = -1
    91     # graft
    93     # graft
    92     yield b'source'
    94     yield b'source'
    93     yield b'intermediate-source'
    95     yield b'intermediate-source'
    94 
    96 
    95 
    97 
    96 def _project(orig, names):
       
    97     """Project a subset of names from orig."""
       
    98     names_saved = tuple(names)
       
    99     values = (orig.get(name, None) for name in names_saved)
       
   100     return {
       
   101         name: value
       
   102         for name, value in zip(names_saved, values)
       
   103         if value is not None
       
   104     }
       
   105 
       
   106 
       
   107 def _save_extras(ctx, extra):
    98 def _save_extras(ctx, extra):
   108     extra.update(_project(ctx.extra(), retained_extras()))
    99     extra.update(Projection(retained_extras(), ctx.extra()))
   109 
   100 
   110 
   101 
   111 def _savebranch(ctx, extra):
   102 def _savebranch(ctx, extra):
   112     extra[b'branch'] = ctx.branch()
   103     extra[b'branch'] = ctx.branch()
   113 
   104