2469 actions = {'revert': ([], _('reverting %s\n')), |
2469 actions = {'revert': ([], _('reverting %s\n')), |
2470 'add': ([], _('adding %s\n')), |
2470 'add': ([], _('adding %s\n')), |
2471 'remove': ([], removeforget), |
2471 'remove': ([], removeforget), |
2472 'undelete': ([], _('undeleting %s\n'))} |
2472 'undelete': ([], _('undeleting %s\n'))} |
2473 |
2473 |
|
2474 |
|
2475 # should we do a backup? |
|
2476 backup = not opts.get('no_backup') |
|
2477 discard = False |
|
2478 |
2474 disptable = ( |
2479 disptable = ( |
2475 # dispatch table: |
2480 # dispatch table: |
2476 # file state |
2481 # file state |
2477 # action |
2482 # action |
2478 # make backup |
2483 # make backup |
2479 (modified, actions['revert'], False), |
2484 (modified, actions['revert'], discard), |
2480 (dsmodified, actions['revert'], True), |
2485 (dsmodified, actions['revert'], backup), |
2481 (dsadded, actions['remove'], True), |
2486 (dsadded, actions['remove'], backup), |
2482 (removed, actions['add'], True), |
2487 (removed, actions['add'], backup), |
2483 (dsremoved, actions['undelete'], True), |
2488 (dsremoved, actions['undelete'], backup), |
2484 (clean, None, False), |
2489 (clean, None, discard), |
2485 ) |
2490 ) |
2486 |
2491 |
2487 for abs, (rel, exact) in sorted(names.items()): |
2492 for abs, (rel, exact) in sorted(names.items()): |
2488 # target file to be touch on disk (relative to cwd) |
2493 # target file to be touch on disk (relative to cwd) |
2489 target = repo.wjoin(abs) |
2494 target = repo.wjoin(abs) |
2496 if xlist is None: |
2501 if xlist is None: |
2497 if exact: |
2502 if exact: |
2498 ui.warn(_('no changes needed to %s\n') % rel) |
2503 ui.warn(_('no changes needed to %s\n') % rel) |
2499 break |
2504 break |
2500 xlist[0].append(abs) |
2505 xlist[0].append(abs) |
2501 if (dobackup and not opts.get('no_backup') and |
2506 if (dobackup and os.path.lexists(target) and |
2502 os.path.lexists(target) and |
|
2503 abs in ctx and repo[None][abs].cmp(ctx[abs])): |
2507 abs in ctx and repo[None][abs].cmp(ctx[abs])): |
2504 bakname = "%s.orig" % rel |
2508 bakname = "%s.orig" % rel |
2505 ui.note(_('saving current version of %s as %s\n') % |
2509 ui.note(_('saving current version of %s as %s\n') % |
2506 (rel, bakname)) |
2510 (rel, bakname)) |
2507 if not opts.get('dry_run'): |
2511 if not opts.get('dry_run'): |