mercurial/cmdutil.py
changeset 22154 fc422de25773
parent 22153 fc8bc2787528
child 22155 530390629842
equal deleted inserted replaced
22153:fc8bc2787528 22154:fc422de25773
  2367         targetsubs = sorted(s for s in ctx.substate if m(s))
  2367         targetsubs = sorted(s for s in ctx.substate if m(s))
  2368 
  2368 
  2369         # Find status of all file in `names`. (Against working directory parent)
  2369         # Find status of all file in `names`. (Against working directory parent)
  2370         m = scmutil.matchfiles(repo, names)
  2370         m = scmutil.matchfiles(repo, names)
  2371         changes = repo.status(node1=parent, match=m)[:4]
  2371         changes = repo.status(node1=parent, match=m)[:4]
  2372         modified, added, removed, deleted = map(set, changes)
  2372         dsmodified, dsadded, dsremoved, dsdeleted = map(set, changes)
  2373 
  2373 
  2374         # if f is a rename, update `names` to also revert the source
  2374         # if f is a rename, update `names` to also revert the source
  2375         cwd = repo.getcwd()
  2375         cwd = repo.getcwd()
  2376         for f in added:
  2376         for f in dsadded:
  2377             src = repo.dirstate.copied(f)
  2377             src = repo.dirstate.copied(f)
  2378             if src and src not in names and repo.dirstate[src] == 'r':
  2378             if src and src not in names and repo.dirstate[src] == 'r':
  2379                 removed.add(src)
  2379                 dsremoved.add(src)
  2380                 names[src] = (repo.pathto(src, cwd), True)
  2380                 names[src] = (repo.pathto(src, cwd), True)
  2381 
  2381 
  2382         ## computation of the action to performs on `names` content.
  2382         ## computation of the action to performs on `names` content.
  2383 
  2383 
  2384         def removeforget(abs):
  2384         def removeforget(abs):
  2387             return _('removing %s\n')
  2387             return _('removing %s\n')
  2388 
  2388 
  2389         # split between files known in target manifest and the others
  2389         # split between files known in target manifest and the others
  2390         smf = set(mf)
  2390         smf = set(mf)
  2391 
  2391 
  2392         missingmodified = modified - smf
  2392         missingmodified = dsmodified - smf
  2393         modified -= missingmodified
  2393         dsmodified -= missingmodified
  2394         missingadded = added - smf
  2394         missingadded = dsadded - smf
  2395         added -= missingadded
  2395         dsadded -= missingadded
  2396         missingremoved = removed - smf
  2396         missingremoved = dsremoved - smf
  2397         removed -= missingremoved
  2397         dsremoved -= missingremoved
  2398         missingdeleted = deleted - smf
  2398         missingdeleted = dsdeleted - smf
  2399         deleted -= missingdeleted
  2399         dsdeleted -= missingdeleted
  2400 
  2400 
  2401         # action to be actually performed by revert
  2401         # action to be actually performed by revert
  2402         # (<list of file>, message>) tuple
  2402         # (<list of file>, message>) tuple
  2403         actions = {'revert': ([], _('reverting %s\n')),
  2403         actions = {'revert': ([], _('reverting %s\n')),
  2404                    'add': ([], _('adding %s\n')),
  2404                    'add': ([], _('adding %s\n')),
  2408         disptable = (
  2408         disptable = (
  2409             # dispatch table:
  2409             # dispatch table:
  2410             #   file state
  2410             #   file state
  2411             #   action
  2411             #   action
  2412             #   make backup
  2412             #   make backup
  2413             (modified,         (actions['revert'],   True)),
  2413             (dsmodified,       (actions['revert'],   True)),
  2414             (missingmodified,  (actions['remove'],   True)),
  2414             (missingmodified,  (actions['remove'],   True)),
  2415             (added,            (actions['revert'],   True)),
  2415             (dsadded,          (actions['revert'],   True)),
  2416             (missingadded,     (actions['remove'],   False)),
  2416             (missingadded,     (actions['remove'],   False)),
  2417             (removed,          (actions['undelete'], True)),
  2417             (dsremoved,        (actions['undelete'], True)),
  2418             (missingremoved,   (None,                False)),
  2418             (missingremoved,   (None,                False)),
  2419             (deleted,          (actions['revert'],   False)),
  2419             (dsdeleted,        (actions['revert'],   False)),
  2420             (missingdeleted,   (actions['remove'],   False)),
  2420             (missingdeleted,   (actions['remove'],   False)),
  2421             )
  2421             )
  2422 
  2422 
  2423         for abs, (rel, exact) in sorted(names.items()):
  2423         for abs, (rel, exact) in sorted(names.items()):
  2424             # hash on file in target manifest (or None if missing from target)
  2424             # hash on file in target manifest (or None if missing from target)