mercurial/mergestate.py
changeset 48711 9bc86adf32f6
parent 48710 b0aa9b0b9c21
child 48712 773ad0f5152d
equal deleted inserted replaced
48710:b0aa9b0b9c21 48711:9bc86adf32f6
    96 LEGACY_MERGE_DRIVER_STATE = b'm'
    96 LEGACY_MERGE_DRIVER_STATE = b'm'
    97 # This record was release in 3.7 and usage was removed in 5.6
    97 # This record was release in 3.7 and usage was removed in 5.6
    98 LEGACY_MERGE_DRIVER_MERGE = b'D'
    98 LEGACY_MERGE_DRIVER_MERGE = b'D'
    99 
    99 
   100 
   100 
   101 ACTION_FORGET = b'f'
   101 class MergeAction(object):
   102 ACTION_REMOVE = b'r'
   102     """represent an "action" merge need to take for a given file
   103 ACTION_ADD = b'a'
   103 
   104 ACTION_GET = b'g'
   104     Attributes:
   105 ACTION_PATH_CONFLICT = b'p'
   105 
   106 ACTION_PATH_CONFLICT_RESOLVE = b'pr'
   106     _short: internal representation used to identify each action
   107 ACTION_ADD_MODIFIED = b'am'
   107     """
   108 ACTION_CREATED = b'c'
   108 
   109 ACTION_DELETED_CHANGED = b'dc'
   109     def __init__(self, short):
   110 ACTION_CHANGED_DELETED = b'cd'
   110         self._short = short
   111 ACTION_MERGE = b'm'
   111 
   112 ACTION_LOCAL_DIR_RENAME_GET = b'dg'
   112     def __hash__(self):
   113 ACTION_DIR_RENAME_MOVE_LOCAL = b'dm'
   113         return hash(self._short)
   114 ACTION_KEEP = b'k'
   114 
       
   115     def __repr__(self):
       
   116         return 'MergeAction<%s>' % self._short.decode('ascii')
       
   117 
       
   118     def __bytes__(self):
       
   119         return self._short
       
   120 
       
   121     def __eq__(self, other):
       
   122         if other is None:
       
   123             return False
       
   124         assert isinstance(other, MergeAction)
       
   125         return self._short == other._short
       
   126 
       
   127     def __lt__(self, other):
       
   128         return self._short < other._short
       
   129 
       
   130 
       
   131 ACTION_FORGET = MergeAction(b'f')
       
   132 ACTION_REMOVE = MergeAction(b'r')
       
   133 ACTION_ADD = MergeAction(b'a')
       
   134 ACTION_GET = MergeAction(b'g')
       
   135 ACTION_PATH_CONFLICT = MergeAction(b'p')
       
   136 ACTION_PATH_CONFLICT_RESOLVE = MergeAction('pr')
       
   137 ACTION_ADD_MODIFIED = MergeAction(b'am')
       
   138 ACTION_CREATED = MergeAction(b'c')
       
   139 ACTION_DELETED_CHANGED = MergeAction(b'dc')
       
   140 ACTION_CHANGED_DELETED = MergeAction(b'cd')
       
   141 ACTION_MERGE = MergeAction(b'm')
       
   142 ACTION_LOCAL_DIR_RENAME_GET = MergeAction(b'dg')
       
   143 ACTION_DIR_RENAME_MOVE_LOCAL = MergeAction(b'dm')
       
   144 ACTION_KEEP = MergeAction(b'k')
   115 # the file was absent on local side before merge and we should
   145 # the file was absent on local side before merge and we should
   116 # keep it absent (absent means file not present, it can be a result
   146 # keep it absent (absent means file not present, it can be a result
   117 # of file deletion, rename etc.)
   147 # of file deletion, rename etc.)
   118 ACTION_KEEP_ABSENT = b'ka'
   148 ACTION_KEEP_ABSENT = MergeAction(b'ka')
   119 # the file is absent on the ancestor and remote side of the merge
   149 # the file is absent on the ancestor and remote side of the merge
   120 # hence this file is new and we should keep it
   150 # hence this file is new and we should keep it
   121 ACTION_KEEP_NEW = b'kn'
   151 ACTION_KEEP_NEW = MergeAction(b'kn')
   122 ACTION_EXEC = b'e'
   152 ACTION_EXEC = MergeAction(b'e')
   123 ACTION_CREATED_MERGE = b'cm'
   153 ACTION_CREATED_MERGE = MergeAction(b'cm')
   124 
   154 
   125 # actions which are no op
   155 # actions which are no op
   126 NO_OP_ACTIONS = (
   156 NO_OP_ACTIONS = (
   127     ACTION_KEEP,
   157     ACTION_KEEP,
   128     ACTION_KEEP_ABSENT,
   158     ACTION_KEEP_ABSENT,