# HG changeset patch # User Martin von Zweigbergk # Date 2021-02-03 21:55:58 # 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 --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -214,6 +214,7 @@ def _narrow( newincludes, newexcludes, force, + backup, ): oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes) newmatch = narrowspec.match(repo.root, newincludes, newexcludes) @@ -272,7 +273,7 @@ def _narrow( 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 @@ def _widen( ), ( 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 @@ def trackedcmd(ui, repo, remotepath=None 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 --git a/tests/test-narrow-trackedcmd.t b/tests/test-narrow-trackedcmd.t --- a/tests/test-narrow-trackedcmd.t +++ b/tests/test-narrow-trackedcmd.t @@ -110,6 +110,8 @@ Testing the --import-rules flag of `hg t --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 --git a/tests/test-narrow.t b/tests/test-narrow.t --- a/tests/test-narrow.t +++ b/tests/test-narrow.t @@ -492,3 +492,20 @@ Test --auto-remove-includes 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/