[Updated] D10706: dirstate-tree: Remove newly-empty nodes after removing a `DirstateEntry`

SimonSapin phabricator at mercurial-scm.org
Sat May 15 23:23:12 UTC 2021


Closed by commit rHG47ccab19bf9f: dirstate-tree: Remove newly-empty nodes after removing a `DirstateEntry` (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10706?vs=27913&id=27930

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10706/new/

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

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.rs
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -711,6 +711,9 @@
   $ hg rm b
   $ hg status a
   R a
+  $ hg commit -qm '#1'
+  $ hg status a
+  a: $ENOENT$
 
 Check using include flag with pattern when status does not need to traverse
 the working directory (issue6483)
diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -379,9 +379,14 @@
                     had_entry: node.entry.take().is_some(),
                     had_copy_source: node.copy_source.take().is_some(),
                 };
-                // TODO: this leaves in the tree a "non-file" node. Should we
-                // remove the node instead, together with ancestor nodes for
-                // directories that become empty?
+            }
+            // After recursion, for both leaf (rest_of_path is None) nodes and
+            // parent nodes, remove a node if it just became empty.
+            if node.entry.is_none()
+                && node.copy_source.is_none()
+                && node.children.is_empty()
+            {
+                nodes.remove(first_path_component);
             }
             Some(dropped)
         }



To: SimonSapin, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210515/c2168ac8/attachment-0002.html>


More information about the Mercurial-patches mailing list