##// END OF EJS Templates
merge-actions: make merge action a full featured object...
marmoute -
r49560:9bc86adf default
parent child Browse files
Show More
@@ -61,7 +61,7 b' eh = exthelper.exthelper()'
61
61
62 lfstatus = lfutil.lfstatus
62 lfstatus = lfutil.lfstatus
63
63
64 MERGE_ACTION_LARGEFILE_MARK_REMOVED = b'lfmr'
64 MERGE_ACTION_LARGEFILE_MARK_REMOVED = mergestatemod.MergeAction('lfmr')
65
65
66 # -- Utility functions: commonly/repeatedly needed functionality ---------------
66 # -- Utility functions: commonly/repeatedly needed functionality ---------------
67
67
@@ -1201,7 +1201,7 b' def calculateupdates('
1201
1201
1202 for f, a in mresult1.filemap(sort=True):
1202 for f, a in mresult1.filemap(sort=True):
1203 m, args, msg = a
1203 m, args, msg = a
1204 repo.ui.debug(b' %s: %s -> %s\n' % (f, msg, m))
1204 repo.ui.debug(b' %s: %s -> %s\n' % (f, msg, m.__bytes__()))
1205 if f in fbids:
1205 if f in fbids:
1206 d = fbids[f]
1206 d = fbids[f]
1207 if m in d:
1207 if m in d:
@@ -1222,13 +1222,15 b' def calculateupdates('
1222 repo.ui.debug(b" list of bids for %s:\n" % f)
1222 repo.ui.debug(b" list of bids for %s:\n" % f)
1223 for m, l in sorted(bids.items()):
1223 for m, l in sorted(bids.items()):
1224 for _f, args, msg in l:
1224 for _f, args, msg in l:
1225 repo.ui.debug(b' %s -> %s\n' % (msg, m))
1225 repo.ui.debug(b' %s -> %s\n' % (msg, m.__bytes__()))
1226 # bids is a mapping from action method to list af actions
1226 # bids is a mapping from action method to list af actions
1227 # Consensus?
1227 # Consensus?
1228 if len(bids) == 1: # all bids are the same kind of method
1228 if len(bids) == 1: # all bids are the same kind of method
1229 m, l = list(bids.items())[0]
1229 m, l = list(bids.items())[0]
1230 if all(a == l[0] for a in l[1:]): # len(bids) is > 1
1230 if all(a == l[0] for a in l[1:]): # len(bids) is > 1
1231 repo.ui.note(_(b" %s: consensus for %s\n") % (f, m))
1231 repo.ui.note(
1232 _(b" %s: consensus for %s\n") % (f, m.__bytes__())
1233 )
1232 mresult.addfile(f, *l[0])
1234 mresult.addfile(f, *l[0])
1233 continue
1235 continue
1234 # If keep is an option, just do it.
1236 # If keep is an option, just do it.
@@ -1286,11 +1288,12 b' def calculateupdates('
1286 repo.ui.note(_(b' %s: multiple bids for merge action:\n') % f)
1288 repo.ui.note(_(b' %s: multiple bids for merge action:\n') % f)
1287 for m, l in sorted(bids.items()):
1289 for m, l in sorted(bids.items()):
1288 for _f, args, msg in l:
1290 for _f, args, msg in l:
1289 repo.ui.note(b' %s -> %s\n' % (msg, m))
1291 repo.ui.note(b' %s -> %s\n' % (msg, m.__bytes__()))
1290 # Pick random action. TODO: Instead, prompt user when resolving
1292 # Pick random action. TODO: Instead, prompt user when resolving
1291 m, l = list(bids.items())[0]
1293 m, l = list(bids.items())[0]
1292 repo.ui.warn(
1294 repo.ui.warn(
1293 _(b' %s: ambiguous merge - picked %s action\n') % (f, m)
1295 _(b' %s: ambiguous merge - picked %s action\n')
1296 % (f, m.__bytes__())
1294 )
1297 )
1295 mresult.addfile(f, *l[0])
1298 mresult.addfile(f, *l[0])
1296 continue
1299 continue
@@ -1623,7 +1626,7 b' def applyupdates('
1623 # keep (noop, just log it)
1626 # keep (noop, just log it)
1624 for a in mergestatemod.NO_OP_ACTIONS:
1627 for a in mergestatemod.NO_OP_ACTIONS:
1625 for f, args, msg in mresult.getactions((a,), sort=True):
1628 for f, args, msg in mresult.getactions((a,), sort=True):
1626 repo.ui.debug(b" %s: %s -> %s\n" % (f, msg, a))
1629 repo.ui.debug(b" %s: %s -> %s\n" % (f, msg, a.__bytes__()))
1627 # no progress
1630 # no progress
1628
1631
1629 # directory rename, move local
1632 # directory rename, move local
@@ -98,29 +98,59 b" LEGACY_MERGE_DRIVER_STATE = b'm'"
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 = (
General Comments 0
You need to be logged in to leave comments. Login now