Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 19510:8b190adb7ee3 stable
revert: make backup when unforgetting a file (issue3423)
This skips the backup if it would be a duplicate.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 26 Jul 2013 17:08:05 -0500 |
parents | 607191a45f8c |
children | ca2dfc2f63eb |
comparison
equal
deleted
inserted
replaced
19509:8963a706e075 | 19510:8b190adb7ee3 |
---|---|
1974 # action if not in target manifest | 1974 # action if not in target manifest |
1975 # make backup if in target manifest | 1975 # make backup if in target manifest |
1976 # make backup if not in target manifest | 1976 # make backup if not in target manifest |
1977 (modified, revert, remove, True, True), | 1977 (modified, revert, remove, True, True), |
1978 (added, revert, remove, True, False), | 1978 (added, revert, remove, True, False), |
1979 (removed, undelete, None, False, False), | 1979 (removed, undelete, None, True, False), |
1980 (deleted, revert, remove, False, False), | 1980 (deleted, revert, remove, False, False), |
1981 ) | 1981 ) |
1982 | 1982 |
1983 for abs, (rel, exact) in sorted(names.items()): | 1983 for abs, (rel, exact) in sorted(names.items()): |
1984 mfentry = mf.get(abs) | 1984 mfentry = mf.get(abs) |
1985 target = repo.wjoin(abs) | 1985 target = repo.wjoin(abs) |
1986 def handle(xlist, dobackup): | 1986 def handle(xlist, dobackup): |
1987 xlist[0].append(abs) | 1987 xlist[0].append(abs) |
1988 if (dobackup and not opts.get('no_backup') and | 1988 if (dobackup and not opts.get('no_backup') and |
1989 os.path.lexists(target)): | 1989 os.path.lexists(target) and |
1990 repo[None][abs].cmp(ctx[abs])): | |
1990 bakname = "%s.orig" % rel | 1991 bakname = "%s.orig" % rel |
1991 ui.note(_('saving current version of %s as %s\n') % | 1992 ui.note(_('saving current version of %s as %s\n') % |
1992 (rel, bakname)) | 1993 (rel, bakname)) |
1993 if not opts.get('dry_run'): | 1994 if not opts.get('dry_run'): |
1994 util.rename(target, bakname) | 1995 util.rename(target, bakname) |