mercurial/cmd_impls/graft.py
changeset 52351 9042ffea4edd
parent 52350 d4e30c15626d
child 52503 cef86c1d5dfd
equal deleted inserted replaced
52350:d4e30c15626d 52351:9042ffea4edd
     1 # graft.py - implementation of the graft command
     1 # graft.py - implementation of the graft command
     2 
     2 
     3 from __future__ import annotations
     3 from __future__ import annotations
     4 
     4 
       
     5 import typing
       
     6 
       
     7 from typing import (
       
     8     Any,
       
     9     Tuple,
       
    10 )
       
    11 
     5 from ..i18n import _
    12 from ..i18n import _
     6 
    13 
     7 from .. import cmdutil, error, logcmdutil, merge as mergemod, state as statemod
    14 from .. import cmdutil, error, logcmdutil, merge as mergemod, state as statemod
     8 
    15 
     9 
    16 
    10 def cmd_graft(ui, repo, *revs, **opts):
    17 if typing.TYPE_CHECKING:
       
    18     _ActionT = str
       
    19     _CmdArgsT = Any  # TODO: (statedata, revs, editor, cont, dry_run, tool)
       
    20 
       
    21 
       
    22 def cmd_graft(ui, repo, *revs, **opts) -> int:
    11     """implement the graft command as defined in mercurial/commands.py"""
    23     """implement the graft command as defined in mercurial/commands.py"""
    12     ret = _process_args(ui, repo, *revs, **opts)
    24     ret = _process_args(ui, repo, *revs, **opts)
    13     action, graftstate, args = ret
    25     action, graftstate, args = ret
    14     if action == "ERROR":
    26     if action == "ERROR":
    15         return -1
    27         return -1
    23         return _graft_revisions(ui, repo, graftstate, *args)
    35         return _graft_revisions(ui, repo, graftstate, *args)
    24     else:
    36     else:
    25         raise error.ProgrammingError('unknown action: %s' % action)
    37         raise error.ProgrammingError('unknown action: %s' % action)
    26 
    38 
    27 
    39 
    28 def _process_args(ui, repo, *revs, **opts):
    40 def _process_args(
       
    41     ui, repo, *revs, **opts
       
    42 ) -> Tuple[_ActionT, statemod.cmdstate | None, _CmdArgsT | None]:
    29     """process the graft command argument to figure out what to do
    43     """process the graft command argument to figure out what to do
    30 
    44 
    31     This also filter the selected revision to skip the one that cannot be graft
    45     This also filter the selected revision to skip the one that cannot be graft
    32     or were already grafted.
    46     or were already grafted.
    33     """
    47     """