hgext/histedit.py
changeset 29878 d7de02efa47e
parent 29877 1c19d3efe15d
child 29879 b566c5992e07
equal deleted inserted replaced
29877:1c19d3efe15d 29878:d7de02efa47e
  1371     other constraints.
  1371     other constraints.
  1372 
  1372 
  1373     Will abort if there are to many or too few rules, a malformed rule,
  1373     Will abort if there are to many or too few rules, a malformed rule,
  1374     or a rule on a changeset outside of the user-given range.
  1374     or a rule on a changeset outside of the user-given range.
  1375     """
  1375     """
  1376     expected = set(c.hex() for c in ctxs)
  1376     expected = set(c.node() for c in ctxs)
  1377     seen = set()
  1377     seen = set()
  1378     prev = None
  1378     prev = None
  1379     for action in actions:
  1379     for action in actions:
  1380         action.verify(prev)
  1380         action.verify(prev)
  1381         prev = action
  1381         prev = action
  1384             if constraint not in _constraints.known():
  1384             if constraint not in _constraints.known():
  1385                 raise error.ParseError(_('unknown constraint "%s"') %
  1385                 raise error.ParseError(_('unknown constraint "%s"') %
  1386                         constraint)
  1386                         constraint)
  1387 
  1387 
  1388         if action.node is not None:
  1388         if action.node is not None:
  1389             ha = node.hex(action.node)
  1389             if _constraints.noother in constrs and action.node not in expected:
  1390             if _constraints.noother in constrs and ha not in expected:
       
  1391                 raise error.ParseError(
  1390                 raise error.ParseError(
  1392                     _('%s "%s" changeset was not a candidate')
  1391                     _('%s "%s" changeset was not a candidate')
  1393                      % (action.verb, ha[:12]),
  1392                      % (action.verb, node.short(action.node)),
  1394                     hint=_('only use listed changesets'))
  1393                     hint=_('only use listed changesets'))
  1395             if _constraints.forceother in constrs and ha in expected:
  1394             if _constraints.forceother in constrs and action.node in expected:
  1396                 raise error.ParseError(
  1395                 raise error.ParseError(
  1397                     _('%s "%s" changeset was not an edited list candidate')
  1396                     _('%s "%s" changeset was not an edited list candidate')
  1398                      % (action.verb, ha[:12]),
  1397                      % (action.verb, node.short(action.node)),
  1399                     hint=_('only use listed changesets'))
  1398                     hint=_('only use listed changesets'))
  1400             if _constraints.noduplicates in constrs and ha in seen:
  1399             if _constraints.noduplicates in constrs and action.node in seen:
  1401                 raise error.ParseError(_(
  1400                 raise error.ParseError(_(
  1402                         'duplicated command for changeset %s') %
  1401                         'duplicated command for changeset %s') %
  1403                         ha[:12])
  1402                         node.short(action.node))
  1404             seen.add(ha)
  1403             seen.add(action.node)
  1405     missing = sorted(expected - seen)  # sort to stabilize output
  1404     missing = sorted(expected - seen)  # sort to stabilize output
  1406 
  1405 
  1407     if state.repo.ui.configbool('histedit', 'dropmissing'):
  1406     if state.repo.ui.configbool('histedit', 'dropmissing'):
  1408         if len(actions) == 0:
  1407         if len(actions) == 0:
  1409             raise error.ParseError(_('no rules provided'),
  1408             raise error.ParseError(_('no rules provided'),
  1410                     hint=_('use strip extension to remove commits'))
  1409                     hint=_('use strip extension to remove commits'))
  1411 
  1410 
  1412         drops = [drop(state, node.bin(n)) for n in missing]
  1411         drops = [drop(state, n) for n in missing]
  1413         # put the in the beginning so they execute immediately and
  1412         # put the in the beginning so they execute immediately and
  1414         # don't show in the edit-plan in the future
  1413         # don't show in the edit-plan in the future
  1415         actions[:0] = drops
  1414         actions[:0] = drops
  1416     elif missing:
  1415     elif missing:
  1417         raise error.ParseError(_('missing rules for changeset %s') %
  1416         raise error.ParseError(_('missing rules for changeset %s') %
  1418                 missing[0][:12],
  1417                 node.short(missing[0]),
  1419                 hint=_('use "drop %s" to discard, see also: '
  1418                 hint=_('use "drop %s" to discard, see also: '
  1420                        '"hg help -e histedit.config"') % missing[0][:12])
  1419                        '"hg help -e histedit.config"')
       
  1420                        % node.short(missing[0]))
  1421 
  1421 
  1422 def adjustreplacementsfrommarkers(repo, oldreplacements):
  1422 def adjustreplacementsfrommarkers(repo, oldreplacements):
  1423     """Adjust replacements from obsolescense markers
  1423     """Adjust replacements from obsolescense markers
  1424 
  1424 
  1425     Replacements structure is originally generated based on
  1425     Replacements structure is originally generated based on