Make tree_to_fs_path and fs_to_tree_path private.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 21 May 2015 01:52:53 +0000 (01:52 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 21 May 2015 01:52:53 +0000 (01:52 +0000)
dulwich/index.py
dulwich/repo.py
dulwich/tests/test_index.py

index b8e200e8775c9bef2631ef7a29ec4abcc8188b64..a250994989965154bb8bffe19e9ac23680dc8e38 100644 (file)
@@ -21,7 +21,6 @@
 import collections
 import errno
 import os
-import platform
 import stat
 import struct
 import sys
@@ -488,7 +487,7 @@ def build_index_from_tree(root_path, index_path, object_store, tree_id,
     for entry in object_store.iter_tree_contents(tree_id):
         if not validate_path(entry.path, validate_path_element):
             continue
-        fs_path = tree_to_fs_path(entry.path)
+        fs_path = _tree_to_fs_path(entry.path)
         full_path = os.path.join(root_path, fs_path)
 
         if not os.path.exists(os.path.dirname(full_path)):
@@ -534,7 +533,7 @@ def get_unstaged_changes(index, root_path):
         root_path = root_path.encode(sys.getfilesystemencoding())
 
     for tree_path, entry in index.iteritems():
-        fs_path = tree_to_fs_path(tree_path)
+        fs_path = _tree_to_fs_path(tree_path)
         full_path = os.path.join(root_path, fs_path)
         blob = blob_from_path_and_stat(full_path, os.lstat(full_path))
         if blob.id != entry.sha:
@@ -544,7 +543,7 @@ def get_unstaged_changes(index, root_path):
 os_sep_bytes = os.sep.encode('ascii')
 
 
-def tree_to_fs_path(tree_path):
+def _tree_to_fs_path(tree_path):
     """Convert a git tree path to a file system path.
 
     :param tree_path: Git tree path as bytes
@@ -559,7 +558,7 @@ def tree_to_fs_path(tree_path):
     return sep_corrected_path
 
 
-def fs_to_tree_path(fs_path):
+def _fs_to_tree_path(fs_path):
     """Convert a file system path to a git tree path.
 
     :param fs_path: File system path.
index 2e5625c94510f39ca75c944c737cd5753f93479e..0988d80097a568211e75552fa6b38b432c46fe12 100644 (file)
@@ -743,13 +743,13 @@ class Repo(BaseRepo):
         from dulwich.index import (
             blob_from_path_and_stat,
             index_entry_from_stat,
-            fs_to_tree_path,
+            _fs_to_tree_path,
             )
         index = self.open_index()
         for fs_path in fs_paths:
             if not isinstance(fs_path, bytes):
                 fs_path = fs_path.encode(sys.getfilesystemencoding())
-            tree_path = fs_to_tree_path(fs_path)
+            tree_path = _fs_to_tree_path(fs_path)
             full_path = os.path.join(root_path_bytes, fs_path)
             try:
                 st = os.lstat(full_path)
index 8a1d85175a7e8fa2b7e6c832ea7bc3fbd9ef3856..b62f0419ec388e4a0195746fd5dbcaaccd532c35 100644 (file)
@@ -44,8 +44,8 @@ from dulwich.index import (
     write_cache_time,
     write_index,
     write_index_dict,
-    tree_to_fs_path,
-    fs_to_tree_path,
+    _tree_to_fs_path,
+    _fs_to_tree_path,
     )
 from dulwich.object_store import (
     MemoryObjectStore,
@@ -484,15 +484,15 @@ class TestTreeFSPathConversion(TestCase):
 
     def test_tree_to_fs_path(self):
         tree_path = u'délwíçh/foo'.encode('utf8')
-        fs_path = tree_to_fs_path(tree_path)
+        fs_path = _tree_to_fs_path(tree_path)
         self.assertEqual(fs_path, os.path.join(u'délwíçh', u'foo').encode('utf8'))
 
     def test_fs_to_tree_path_str(self):
         fs_path = os.path.join(os.path.join(u'délwíçh', u'foo'))
-        tree_path = fs_to_tree_path(fs_path)
+        tree_path = _fs_to_tree_path(fs_path)
         self.assertEqual(tree_path, u'délwíçh/foo'.encode(sys.getfilesystemencoding()))
 
     def test_fs_to_tree_path_bytes(self):
         fs_path = os.path.join(os.path.join(u'délwíçh', u'foo').encode('utf8'))
-        tree_path = fs_to_tree_path(fs_path)
+        tree_path = _fs_to_tree_path(fs_path)
         self.assertEqual(tree_path, u'délwíçh/foo'.encode('utf8'))