changeset 40829:77173267878b

narrow: don't resurrect old commits when narrowing (don't strip obsmarkers) If you have an old obsolescence-chain of commits that has been pruned and you narrow your repo so that some of those commits get stripped (because they affected the removed paths), then we would currently resurrect the commit that came before (along the obsmarker chain) the last stripped commit. That happens by the usual rules for obsmarker-stripping. However, it's quite surprising when it happens when you narrow your repo. This patch makes narrowing not strip obsmarkers. Differential Revision: https://phab.mercurial-scm.org/D5364
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 03 Dec 2018 16:56:09 -0800
parents 25e9089c7686
children 23dc23897248
files hgext/narrow/narrowcommands.py tests/test-narrow.t
diffstat 2 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowcommands.py	Sun Nov 18 19:55:53 2018 +0900
+++ b/hgext/narrow/narrowcommands.py	Mon Dec 03 16:56:09 2018 -0800
@@ -215,7 +215,9 @@
                 urev = max(repo.revs('(::%n) - %ln + null',
                                      repo['.'].node(), visibletostrip))
                 hg.clean(repo, urev)
-            repair.strip(ui, unfi, tostrip, topic='narrow')
+            overrides = {('devel', 'strip-obsmarkers'): False}
+            with ui.configoverride(overrides, 'narrow'):
+                repair.strip(ui, unfi, tostrip, topic='narrow')
 
         todelete = []
         for f, f2, size in repo.store.datafiles():
--- a/tests/test-narrow.t	Sun Nov 18 19:55:53 2018 +0900
+++ b/tests/test-narrow.t	Mon Dec 03 16:56:09 2018 -0800
@@ -214,6 +214,29 @@
   000000000000
   $ cd ..
 
+Narrowing doesn't resurrect old commits (unlike what regular `hg strip` does)
+  $ hg clone --narrow ssh://user@dummy/master narrow-obsmarkers --include d0 --include d3 -q
+  $ cd narrow-obsmarkers
+  $ echo a >> d0/f2
+  $ hg add d0/f2
+  $ hg ci -m 'modify d0/'
+  $ echo a >> d3/f2
+  $ hg add d3/f2
+  $ hg commit --amend -m 'modify d0/ and d3/'
+  $ hg log -T "{rev}: {desc}\n"
+  5: modify d0/ and d3/
+  3: add d10/f
+  2: add d3/f
+  1: add d2/f
+  0: add d0/f
+  $ hg tracked --removeinclude d3 --force-delete-local-changes -q
+  $ hg log -T "{rev}: {desc}\n"
+  3: add d10/f
+  2: add d3/f
+  1: add d2/f
+  0: add d0/f
+  $ cd ..
+
 Can remove last include, making repo empty
   $ hg clone --narrow ssh://user@dummy/master narrow-empty --include d0 -r 5
   adding changesets