D6265: narrow: also warn when not deleting untracked or ignored files

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Apr 17 13:59:04 EDT 2019


martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/narrowspec.py
  tests/test-narrow-share.t

CHANGE DETAILS

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 @@
 # 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
@@ -90,6 +97,8 @@
   $ hg -R main tracked --update-working-copy
   not deleting possibly dirty file d3/f
   not deleting possibly dirty file d3/g
+  not deleting ignored file d3/ignored
+  not deleting unknown file d3/untracked
   not deleting possibly dirty file d5/f
 # d1/f, d3/f, d3/g and d5/f should no longer be reported
   $ hg -R main files
@@ -99,6 +108,8 @@
   $ 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 @@
   $ hg -R main st --all
   M d3/f
   ? d3/g
+  ? d3/untracked
+  I d3/ignored
   C d1/f
   C d7/f
 
diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -293,8 +293,8 @@
     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:
@@ -304,8 +304,16 @@
         trackeddirty.extend(lookup)
     _deletecleanfiles(repo, clean)
     uipathfn = scmutil.getuipathfn(repo)
-    for f in sorted(trackeddirty):
-        repo.ui.status(_('not deleting possibly dirty file %s\n') % uipathfn(f))
+    unknownset = set(status.unknown)
+    ignoredset = set(status.ignored)
+    for f in sorted(trackeddirty + status.unknown + status.ignored):
+        if f in unknownset:
+            repo.ui.status(_('not deleting unknown file %s\n') % uipathfn(f))
+        elif f in ignoredset:
+            repo.ui.status(_('not deleting ignored file %s\n') % uipathfn(f))
+        else:
+            repo.ui.status(_('not deleting possibly dirty file %s\n') %
+                           uipathfn(f))
     for f in clean + trackeddirty:
         ds.drop(f)
 



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


More information about the Mercurial-devel mailing list