# HG changeset patch # User Martin von Zweigbergk # Date 1612389358 28800 # Node ID 3c360ab2688dd4e4d4b74a8118bffa4453049757 # Parent 4f5e9a77ff7ab343d030f27ab92e334e8d9882d7 narrow: add --no-backup option for narrowing Most of our users at Google use Mercurial on a file system that keeps backups of previous versions of all files, including those in `.hg/`. They therefore don't need a separate backup in the file system when narrowing their repo (which they typically do by running `hg tracked --auto-remove-includes`). Backups can be very slow. `hg strip` already has a `--no-backup` option. This patch adds the same option to `hg tracked --removeinclude/--addexclude`. Differential Revision: https://phab.mercurial-scm.org/D9951 diff -r 4f5e9a77ff7a -r 3c360ab2688d hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py Fri Jan 29 15:23:07 2021 +0100 +++ b/hgext/narrow/narrowcommands.py Wed Feb 03 13:55:58 2021 -0800 @@ -214,6 +214,7 @@ newincludes, newexcludes, force, + backup, ): oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes) newmatch = narrowspec.match(repo.root, newincludes, newexcludes) @@ -272,7 +273,7 @@ hg.clean(repo, urev) overrides = {(b'devel', b'strip-obsmarkers'): False} with ui.configoverride(overrides, b'narrow'): - repair.strip(ui, unfi, tostrip, topic=b'narrow') + repair.strip(ui, unfi, tostrip, topic=b'narrow', backup=backup) todelete = [] for f, f2, size in repo.store.datafiles(): @@ -442,6 +443,12 @@ ), ( b'', + b'backup', + True, + _(b'back up local changes when narrowing'), + ), + ( + b'', b'update-working-copy', False, _(b'update working copy when the store has changed'), @@ -639,6 +646,7 @@ newincludes, newexcludes, opts[b'force_delete_local_changes'], + opts[b'backup'], ) # _narrow() updated the narrowspec and _widen() below needs to # use the updated values as its base (otherwise removed includes diff -r 4f5e9a77ff7a -r 3c360ab2688d tests/test-narrow-trackedcmd.t --- a/tests/test-narrow-trackedcmd.t Fri Jan 29 15:23:07 2021 +0100 +++ b/tests/test-narrow-trackedcmd.t Wed Feb 03 13:55:58 2021 -0800 @@ -110,6 +110,8 @@ --clear whether to replace the existing narrowspec --force-delete-local-changes forces deletion of local changes when narrowing + --[no-]backup back up local changes when narrowing + (default: on) --update-working-copy update working copy when the store has changed -e --ssh CMD specify ssh command to use diff -r 4f5e9a77ff7a -r 3c360ab2688d tests/test-narrow.t --- a/tests/test-narrow.t Fri Jan 29 15:23:07 2021 +0100 +++ b/tests/test-narrow.t Wed Feb 03 13:55:58 2021 -0800 @@ -492,3 +492,20 @@ searching for changes looking for unused includes to remove found no unused includes +Test --no-backup + $ hg tracked --addinclude d0 --addinclude d2 -q + $ hg unbundle .hg/strip-backup/*-narrow.hg -q + $ rm .hg/strip-backup/* + $ hg tracked --auto-remove-includes --no-backup + comparing with ssh://user@dummy/master + searching for changes + looking for unused includes to remove + path:d0 + path:d2 + remove these unused includes (yn)? y + looking for local changes to affected paths + deleting data/d0/f.i + deleting data/d2/f.i + deleting meta/d0/00manifest.i (tree !) + deleting meta/d2/00manifest.i (tree !) + $ ls .hg/strip-backup/