mercurial/cmdutil.py
changeset 22155 530390629842
parent 22154 fc422de25773
child 22156 03a45eff9d2b
equal deleted inserted replaced
22154:fc422de25773 22155:530390629842
  2364                 names[abs] = m.rel(abs), m.exact(abs)
  2364                 names[abs] = m.rel(abs), m.exact(abs)
  2365 
  2365 
  2366         # get the list of subrepos that must be reverted
  2366         # get the list of subrepos that must be reverted
  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`.
  2370         m = scmutil.matchfiles(repo, names)
  2370         m = scmutil.matchfiles(repo, names)
  2371         changes = repo.status(node1=parent, match=m)[:4]
  2371 
  2372         dsmodified, dsadded, dsremoved, dsdeleted = map(set, changes)
  2372         changes = repo.status(node1=node, match=m, clean=True)
       
  2373         modified = set(changes[0])
       
  2374         added    = set(changes[1])
       
  2375         removed  = set(changes[2])
       
  2376         deleted  = set(changes[3])
       
  2377 
       
  2378         # We need to account for the state of file in the dirstate
       
  2379         #
       
  2380         # Even, when we revert agains something else than parent. this will
       
  2381         # slightly alter the behavior of revert (doing back up or not, delete
       
  2382         # or just forget etc)
       
  2383         if parent == node:
       
  2384             dsmodified = modified
       
  2385             dsadded = added
       
  2386             dsremoved = removed
       
  2387             modified, added, removed = set(), set(), set()
       
  2388         else:
       
  2389             changes = repo.status(node1=parent, match=m)
       
  2390             dsmodified = set(changes[0])
       
  2391             dsadded    = set(changes[1])
       
  2392             dsremoved  = set(changes[2])
  2373 
  2393 
  2374         # if f is a rename, update `names` to also revert the source
  2394         # if f is a rename, update `names` to also revert the source
  2375         cwd = repo.getcwd()
  2395         cwd = repo.getcwd()
  2376         for f in dsadded:
  2396         for f in dsadded:
  2377             src = repo.dirstate.copied(f)
  2397             src = repo.dirstate.copied(f)
  2393         dsmodified -= missingmodified
  2413         dsmodified -= missingmodified
  2394         missingadded = dsadded - smf
  2414         missingadded = dsadded - smf
  2395         dsadded -= missingadded
  2415         dsadded -= missingadded
  2396         missingremoved = dsremoved - smf
  2416         missingremoved = dsremoved - smf
  2397         dsremoved -= missingremoved
  2417         dsremoved -= missingremoved
  2398         missingdeleted = dsdeleted - smf
  2418         missingdeleted = deleted - smf
  2399         dsdeleted -= missingdeleted
  2419         deleted -= missingdeleted
  2400 
  2420 
  2401         # action to be actually performed by revert
  2421         # action to be actually performed by revert
  2402         # (<list of file>, message>) tuple
  2422         # (<list of file>, message>) tuple
  2403         actions = {'revert': ([], _('reverting %s\n')),
  2423         actions = {'revert': ([], _('reverting %s\n')),
  2404                    'add': ([], _('adding %s\n')),
  2424                    'add': ([], _('adding %s\n')),
  2414             (missingmodified,  (actions['remove'],   True)),
  2434             (missingmodified,  (actions['remove'],   True)),
  2415             (dsadded,          (actions['revert'],   True)),
  2435             (dsadded,          (actions['revert'],   True)),
  2416             (missingadded,     (actions['remove'],   False)),
  2436             (missingadded,     (actions['remove'],   False)),
  2417             (dsremoved,        (actions['undelete'], True)),
  2437             (dsremoved,        (actions['undelete'], True)),
  2418             (missingremoved,   (None,                False)),
  2438             (missingremoved,   (None,                False)),
  2419             (dsdeleted,        (actions['revert'],   False)),
  2439             (deleted,          (actions['revert'],   False)),
  2420             (missingdeleted,   (actions['remove'],   False)),
  2440             (missingdeleted,   (actions['remove'],   False)),
  2421             )
  2441             )
  2422 
  2442 
  2423         for abs, (rel, exact) in sorted(names.items()):
  2443         for abs, (rel, exact) in sorted(names.items()):
  2424             # hash on file in target manifest (or None if missing from target)
  2444             # hash on file in target manifest (or None if missing from target)