1314 """open an editor to edit rules |
1314 """open an editor to edit rules |
1315 |
1315 |
1316 rules are in the format [ [act, ctx], ...] like in state.rules |
1316 rules are in the format [ [act, ctx], ...] like in state.rules |
1317 """ |
1317 """ |
1318 if repo.ui.configbool("experimental", "histedit.autoverb"): |
1318 if repo.ui.configbool("experimental", "histedit.autoverb"): |
|
1319 newact = util.sortdict() |
1319 for act in actions: |
1320 for act in actions: |
1320 ctx = repo[act.node] |
1321 ctx = repo[act.node] |
1321 summary = _getsummary(ctx) |
1322 summary = _getsummary(ctx) |
1322 fword = summary.split(' ', 1)[0].lower() |
1323 fword = summary.split(' ', 1)[0].lower() |
|
1324 added = False |
|
1325 |
1323 # if it doesn't end with the special character '!' just skip this |
1326 # if it doesn't end with the special character '!' just skip this |
1324 if fword.endswith('!'): |
1327 if fword.endswith('!'): |
1325 fword = fword[:-1] |
1328 fword = fword[:-1] |
1326 if fword in primaryactions | secondaryactions | tertiaryactions: |
1329 if fword in primaryactions | secondaryactions | tertiaryactions: |
1327 act.verb = fword |
1330 act.verb = fword |
|
1331 # get the target summary |
|
1332 tsum = summary[len(fword) + 1:].lstrip() |
|
1333 # safe but slow: reverse iterate over the actions so we |
|
1334 # don't clash on two commits having the same summary |
|
1335 for na, l in reversed(list(newact.iteritems())): |
|
1336 actx = repo[na.node] |
|
1337 asum = _getsummary(actx) |
|
1338 if asum == tsum: |
|
1339 added = True |
|
1340 l.append(act) |
|
1341 break |
|
1342 |
|
1343 if not added: |
|
1344 newact[act] = [] |
|
1345 |
|
1346 # copy over and flatten the new list |
|
1347 actions = [] |
|
1348 for na, l in newact.iteritems(): |
|
1349 actions.append(na) |
|
1350 actions += l |
1328 |
1351 |
1329 rules = '\n'.join([act.torule() for act in actions]) |
1352 rules = '\n'.join([act.torule() for act in actions]) |
1330 rules += '\n\n' |
1353 rules += '\n\n' |
1331 rules += editcomment |
1354 rules += editcomment |
1332 rules = ui.edit(rules, ui.username(), {'prefix': 'histedit'}) |
1355 rules = ui.edit(rules, ui.username(), {'prefix': 'histedit'}) |