Patchwork [2,of,4] dirstate: introduce function to normalize just filenames

login
register
mail settings
Submitter Siddharth Agarwal
Date March 31, 2015, 4:52 p.m.
Message ID <21df72baa78f0ba8c6f7.1427820777@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8387/
State Accepted
Commit 3a8eba78803e994aed95ed07b121dcd28911b373
Headers show

Comments

Siddharth Agarwal - March 31, 2015, 4:52 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1427594034 25200
#      Sat Mar 28 18:53:54 2015 -0700
# Node ID 21df72baa78f0ba8c6f7d98f4159c48b4dffddf3
# Parent  1628a521be87f334e98a0575ebbb17153f1ed9b8
dirstate: introduce function to normalize just filenames

This will be used in upcoming patches to stop generating the set of directories
in many common cases.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -490,6 +490,17 @@ 
 
         return folded
 
+    def _normalizefile(self, path, isknown, ignoremissing=False, exists=None):
+        normed = util.normcase(path)
+        folded = self._foldmap.get(normed, None)
+        if folded is None:
+            if isknown:
+                folded = path
+            else:
+                folded = self._discoverpath(path, normed, ignoremissing, exists,
+                                            self._foldmap)
+        return folded
+
     def _normalize(self, path, isknown, ignoremissing=False, exists=None):
         normed = util.normcase(path)
         folded = self._foldmap.get(normed, None)