revert: always show relative path to .orig backup
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 06 Feb 2019 14:57:08 -0800
changeset 41591 4d4842445afc
parent 41590 349c8879becd
child 41592 e67a85e0f19e
revert: always show relative path to .orig backup This helps make some future patches easier when I replace origpath() by another function that works with repo-relative paths (origpath() works with cwd-relative paths). Always showing a relative path seems a little more user-friendly and is more consistent between configured ui.origbackuppath and not. OTOH, it's annoying if ui.origbackuppath is far outside the repo. This is just --verbose output, so I don't think it's worth spending much time on (I've already wasted too many hours on it). Differential Revision: https://phab.mercurial-scm.org/D5871
mercurial/cmdutil.py
tests/test-largefiles-misc.t
tests/test-revert.t
--- a/mercurial/cmdutil.py	Tue Feb 05 17:02:40 2019 -0500
+++ b/mercurial/cmdutil.py	Wed Feb 06 14:57:08 2019 -0800
@@ -3018,8 +3018,9 @@
                             tobackup.add(abs)
                         elif (backup <= dobackup or wctx[abs].cmp(ctx[abs])):
                             bakname = scmutil.origpath(ui, repo, rel)
+                            relbakname = os.path.relpath(bakname)
                             ui.note(_('saving current version of %s as %s\n') %
-                                    (rel, bakname))
+                                    (rel, relbakname))
                             if not opts.get('dry_run'):
                                 if interactive:
                                     util.copyfile(target, bakname)
--- a/tests/test-largefiles-misc.t	Tue Feb 05 17:02:40 2019 -0500
+++ b/tests/test-largefiles-misc.t	Wed Feb 06 14:57:08 2019 -0800
@@ -578,7 +578,7 @@
   $ echo moremore >> anotherlarge
   $ hg revert anotherlarge -v --config 'ui.origbackuppath=.hg/origbackups'
   creating directory: $TESTTMP/addrm2/.hg/origbackups/.hglf/sub
-  saving current version of ../.hglf/sub/anotherlarge as $TESTTMP/addrm2/.hg/origbackups/.hglf/sub/anotherlarge
+  saving current version of ../.hglf/sub/anotherlarge as ../.hg/origbackups/.hglf/sub/anotherlarge
   reverting ../.hglf/sub/anotherlarge
   creating directory: $TESTTMP/addrm2/.hg/origbackups/sub
   found 90c622cf65cebe75c5842f9136c459333faf392e in store
--- a/tests/test-revert.t	Tue Feb 05 17:02:40 2019 -0500
+++ b/tests/test-revert.t	Wed Feb 06 14:57:08 2019 -0800
@@ -92,7 +92,7 @@
   $ echo z > e
   $ hg revert --all -v --config 'ui.origbackuppath=.hg/origbackups'
   creating directory: $TESTTMP/repo/.hg/origbackups
-  saving current version of e as $TESTTMP/repo/.hg/origbackups/e
+  saving current version of e as .hg/origbackups/e
   reverting e
   $ rm -rf .hg/origbackups