Patchwork D9951: narrow: add --no-backup option for narrowing

login
register
mail settings
Submitter phabricator
Date Feb. 3, 2021, 10:07 p.m.
Message ID <differential-rev-PHID-DREV-p7wuvjnjqnfxme7bnpcg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48263/
State Superseded
Headers show

Comments

phabricator - Feb. 3, 2021, 10:07 p.m.
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9951

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  tests/test-narrow-trackedcmd.t
  tests/test-narrow.t

CHANGE DETAILS




To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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 @@ 
   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/
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 @@ 
       --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/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -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