# HG changeset patch # User Martin von Zweigbergk # Date 2018-12-04 00:56:09 # Node ID 77173267878b2afdb8280538b91873cfa4071ff7 # Parent 25e9089c7686be81d3500432be008ef08a142487 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 diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -215,7 +215,9 @@ def _narrow(ui, repo, remote, commoninc, 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(): diff --git a/tests/test-narrow.t b/tests/test-narrow.t --- a/tests/test-narrow.t +++ b/tests/test-narrow.t @@ -214,6 +214,29 @@ Updates to nullid if necessary 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