# HG changeset patch # User Martin von Zweigbergk # Date 2019-04-17 17:49:11 # Node ID aa8f83923aef2241514156a5614eaf84a9d09e99 # Parent 644eaffab9db5673a1e5fdaf5b6fddb7cbb0bc58 narrow: also warn when not deleting untracked or ignored files Differential Revision: https://phab.mercurial-scm.org/D6265 diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py --- a/mercurial/narrowspec.py +++ b/mercurial/narrowspec.py @@ -293,8 +293,8 @@ def updateworkingcopy(repo, assumeclean= removedmatch = matchmod.differencematcher(oldmatch, newmatch) ds = repo.dirstate - lookup, status = ds.status(removedmatch, subrepos=[], ignored=False, - clean=True, unknown=False) + lookup, status = ds.status(removedmatch, subrepos=[], ignored=True, + clean=True, unknown=True) trackeddirty = status.modified + status.added clean = status.clean if assumeclean: @@ -306,6 +306,10 @@ def updateworkingcopy(repo, assumeclean= uipathfn = scmutil.getuipathfn(repo) for f in sorted(trackeddirty): repo.ui.status(_('not deleting possibly dirty file %s\n') % uipathfn(f)) + for f in sorted(status.unknown): + repo.ui.status(_('not deleting unknown file %s\n') % uipathfn(f)) + for f in sorted(status.ignored): + repo.ui.status(_('not deleting ignored file %s\n') % uipathfn(f)) for f in clean + trackeddirty: ds.drop(f) diff --git a/tests/test-narrow-share.t b/tests/test-narrow-share.t --- a/tests/test-narrow-share.t +++ b/tests/test-narrow-share.t @@ -28,6 +28,9 @@ $ hg clone --narrow ssh://user@dummy/remote main -q \ > --include d1 --include d3 --include d5 --include d7 +Ignore file called "ignored" + $ echo ignored > main/.hgignore + $ hg share main share updating working directory 4 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -55,15 +58,19 @@ Narrow the share and check that the main # Make d3/f dirty $ echo x >> main/d3/f $ echo y >> main/d3/g + $ touch main/d3/ignored + $ touch main/d3/untracked $ hg add main/d3/g $ hg -R main st M d3/f A d3/g + ? d3/untracked # Make d5/f not match the dirstate timestamp even though it's clean $ sleep 2 $ hg -R main st M d3/f A d3/g + ? d3/untracked $ hg -R main debugdirstate --no-dates n 644 2 set d1/f n 644 2 set d3/f @@ -91,6 +98,8 @@ Narrow the share and check that the main not deleting possibly dirty file d3/f not deleting possibly dirty file d3/g not deleting possibly dirty file d5/f + not deleting unknown file d3/untracked + not deleting ignored file d3/ignored # d1/f, d3/f, d3/g and d5/f should no longer be reported $ hg -R main files main/d7/f @@ -99,6 +108,8 @@ Narrow the share and check that the main $ find main/d* -type f | sort main/d3/f main/d3/g + main/d3/ignored + main/d3/untracked main/d5/f main/d7/f @@ -131,6 +142,8 @@ Widen the share and check that the main $ hg -R main st --all M d3/f ? d3/g + ? d3/untracked + I d3/ignored C d1/f C d7/f