Forráskód Böngészése

Make graftpoints methods private for the moment.

Jelmer Vernooij 11 éve
szülő
commit
62b5fed273
2 módosított fájl, 13 hozzáadás és 22 törlés
  1. 7 7
      dulwich/repo.py
  2. 6 15
      dulwich/tests/test_grafts.py

+ 7 - 7
dulwich/repo.py

@@ -169,7 +169,7 @@ class BaseRepo(object):
         self.object_store = object_store
         self.refs = refs
 
-        self.graftpoints = {}
+        self._graftpoints = {}
         self.hooks = {}
 
     def _init_files(self, bare):
@@ -330,7 +330,7 @@ class BaseRepo(object):
         """
 
         try:
-            return self.graftpoints[sha]
+            return self._graftpoints[sha]
         except KeyError:
             return self[sha].parents
 
@@ -540,7 +540,7 @@ class BaseRepo(object):
             config.get(("user", ), "name"),
             config.get(("user", ), "email"))
 
-    def add_graftpoints(self, updated_graftpoints):
+    def _add_graftpoints(self, updated_graftpoints):
         """Add or modify graftpoints
 
         :param updated_graftpoints: Dict of commit shas to list of parent shas
@@ -551,15 +551,15 @@ class BaseRepo(object):
             for sha in [commit] + parents:
                 check_hexsha(sha, 'Invalid graftpoint')
 
-        self.graftpoints.update(updated_graftpoints)
+        self._graftpoints.update(updated_graftpoints)
 
-    def remove_graftpoints(self, to_remove=[]):
+    def _remove_graftpoints(self, to_remove=[]):
         """Remove graftpoints
 
         :param to_remove: List of commit shas
         """
         for sha in to_remove:
-            del self.graftpoints[sha]
+            del self._graftpoints[sha]
 
     def do_commit(self, message=None, committer=None,
                   author=None, commit_timestamp=None,
@@ -705,7 +705,7 @@ class Repo(BaseRepo):
 
         graft_file = self.get_named_file(os.path.join("info", "grafts"))
         if graft_file:
-            self.graftpoints = parse_graftpoints(graft_file)
+            self._graftpoints = parse_graftpoints(graft_file)
 
         self.hooks['pre-commit'] = PreCommitShellHook(self.controldir())
         self.hooks['commit-msg'] = CommitMsgShellHook(self.controldir())

+ 6 - 15
dulwich/tests/test_grafts.py

@@ -20,27 +20,18 @@
 import os
 import tempfile
 import shutil
-import warnings
 
 from dulwich.errors import ObjectFormatException
 from dulwich.tests import TestCase
 from dulwich.objects import (
-    Commit,
     Tree,
-)
-from dulwich.object_store import (
-    MemoryObjectStore,
-)
+    )
 from dulwich.repo import (
     parse_graftpoints,
     serialize_graftpoints,
     MemoryRepo,
     Repo,
 )
-from dulwich.tests.utils import (
-    make_commit,
-    setup_warning_catcher
-)
 
 
 def makesha(digit):
@@ -107,7 +98,7 @@ class GraftsInRepositoryBase(object):
 
     def get_repo_with_grafts(self, grafts):
         r = self._repo
-        r.add_graftpoints(grafts)
+        r._add_graftpoints(grafts)
         return r
 
     def test_no_grafts(self):
@@ -130,7 +121,7 @@ class GraftsInRepositoryBase(object):
 
     def test_remove_graft(self):
         r = self.get_repo_with_grafts({self._repo.head(): []})
-        r.remove_graftpoints([self._repo.head()])
+        r._remove_graftpoints([self._repo.head()])
 
         self.assertEqual([e.commit.id for e in r.get_walker()],
                          self._shas[::-1])
@@ -140,7 +131,7 @@ class GraftsInRepositoryBase(object):
 
         self.assertRaises(
             ObjectFormatException,
-            r.add_graftpoints,
+            r._add_graftpoints,
             {self._shas[-1]: ['1']})
 
 
@@ -175,7 +166,7 @@ class GraftsInRepoTests(GraftsInRepositoryBase, TestCase):
         r._put_named_file(os.path.join('info', 'grafts'), '')
 
         r = Repo(self._repo_dir)
-        self.assertEqual({}, r.graftpoints)
+        self.assertEqual({}, r._graftpoints)
 
     def test_init_with_info_grafts(self):
         r = self._repo
@@ -184,7 +175,7 @@ class GraftsInRepoTests(GraftsInRepositoryBase, TestCase):
             "%s %s" % (self._shas[-1], self._shas[0]))
 
         r = Repo(self._repo_dir)
-        self.assertEqual({self._shas[-1]: [self._shas[0]]}, r.graftpoints)
+        self.assertEqual({self._shas[-1]: [self._shas[0]]}, r._graftpoints)
 
 
 class GraftsInMemoryRepoTests(GraftsInRepositoryBase, TestCase):