summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--lib/git/actor.py2
-rw-r--r--lib/git/diff.py2
-rw-r--r--lib/git/objects/commit.py12
-rw-r--r--lib/git/objects/tree.py4
-rw-r--r--lib/git/refs.py8
-rw-r--r--lib/git/repo.py6
-rw-r--r--lib/git/stats.py2
-rw-r--r--test/git/test_actor.py8
-rw-r--r--test/git/test_commit.py2
-rw-r--r--test/git/test_diff.py4
-rw-r--r--test/git/test_stats.py4
-rw-r--r--test/git/test_tree.py8
13 files changed, 34 insertions, 31 deletions
diff --git a/CHANGES b/CHANGES
index 69eddacc..78d02b9a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,9 @@ General
* id_abbrev method has been removed as it could not assure the returned short SHA's
where unique
* removed basename method from Objects with path's as it replicated features of os.path
+* from_string and list_from_string methods are now private and were renamed to
+ _from_string and _list_from_string respectively. As part of the private API, they
+ may change without prior notice.
objects Package
----------------
diff --git a/lib/git/actor.py b/lib/git/actor.py
index f1aeda9b..fe4a47e5 100644
--- a/lib/git/actor.py
+++ b/lib/git/actor.py
@@ -25,7 +25,7 @@ class Actor(object):
return '<git.Actor "%s <%s>">' % (self.name, self.email)
@classmethod
- def from_string(cls, string):
+ def _from_string(cls, string):
"""
Create an Actor from a string.
diff --git a/lib/git/diff.py b/lib/git/diff.py
index 4bc88bf4..0db83b4f 100644
--- a/lib/git/diff.py
+++ b/lib/git/diff.py
@@ -74,7 +74,7 @@ class Diff(object):
self.diff = diff
@classmethod
- def list_from_string(cls, repo, text):
+ def _list_from_string(cls, repo, text):
"""
Create a new diff object from the given text
``repo``
diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py
index c70b03e4..c3e97bf9 100644
--- a/lib/git/objects/commit.py
+++ b/lib/git/objects/commit.py
@@ -146,10 +146,10 @@ class Commit(base.Object):
options.update(kwargs)
output = repo.git.rev_list(ref, '--', path, **options)
- return cls.list_from_string(repo, output)
+ return cls._list_from_string(repo, output)
@classmethod
- def list_from_string(cls, repo, text):
+ def _list_from_string(cls, repo, text):
"""
Parse out commit information into a list of Commit objects
@@ -228,7 +228,7 @@ class Commit(base.Object):
paths.insert(0, b)
paths.insert(0, a)
text = repo.git.diff('-M', full_index=True, *paths)
- return diff.Diff.list_from_string(repo, text)
+ return diff.Diff._list_from_string(repo, text)
@property
def diffs(self):
@@ -240,7 +240,7 @@ class Commit(base.Object):
"""
if not self.parents:
d = self.repo.git.show(self.id, '-M', full_index=True, pretty='raw')
- return diff.Diff.list_from_string(self.repo, d)
+ return diff.Diff._list_from_string(self.repo, d)
else:
return self.diff(self.repo, self.parents[0].id, self.id)
@@ -262,7 +262,7 @@ class Commit(base.Object):
text = text2
else:
text = self.repo.git.diff(self.parents[0].id, self.id, '--', numstat=True)
- return stats.Stats.list_from_string(self.repo, text)
+ return stats.Stats._list_from_string(self.repo, text)
def __str__(self):
""" Convert commit to string which is SHA1 """
@@ -281,4 +281,4 @@ class Commit(base.Object):
"""
m = cls.re_actor_epoch.search(line)
actor, epoch = m.groups()
- return (Actor.from_string(actor), time.gmtime(int(epoch)))
+ return (Actor._from_string(actor), time.gmtime(int(epoch)))
diff --git a/lib/git/objects/tree.py b/lib/git/objects/tree.py
index 597668ae..273384a3 100644
--- a/lib/git/objects/tree.py
+++ b/lib/git/objects/tree.py
@@ -21,14 +21,14 @@ class Tree(base.IndexObject):
# Read the tree contents.
self._contents = {}
for line in self.repo.git.ls_tree(self.id).splitlines():
- obj = self.content_from_string(self.repo, line)
+ obj = self.content__from_string(self.repo, line)
if obj is not None:
self._contents[obj.path] = obj
else:
super(Tree, self)._set_cache_(attr)
@staticmethod
- def content_from_string(repo, text):
+ def content__from_string(repo, text):
"""
Parse a content item and create the appropriate object
diff --git a/lib/git/refs.py b/lib/git/refs.py
index cb730edb..820150d3 100644
--- a/lib/git/refs.py
+++ b/lib/git/refs.py
@@ -88,10 +88,10 @@ class Ref(object):
options.update(kwargs)
output = repo.git.for_each_ref(common_path, **options)
- return cls.list_from_string(repo, output)
+ return cls._list_from_string(repo, output)
@classmethod
- def list_from_string(cls, repo, text):
+ def _list_from_string(cls, repo, text):
"""
Parse out ref information into a list of Ref compatible objects
@@ -108,12 +108,12 @@ class Ref(object):
heads = []
for line in text.splitlines():
- heads.append(cls.from_string(repo, line))
+ heads.append(cls._from_string(repo, line))
return heads
@classmethod
- def from_string(cls, repo, line):
+ def _from_string(cls, repo, line):
"""
Create a new Ref instance from the given string.
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 6e23dbc6..dd5acfc3 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -179,9 +179,9 @@ class Repo(object):
c = commits.get(sha)
if c is None:
c = Commit( self, id=sha,
- author=Actor.from_string(info['author'] + ' ' + info['author_email']),
+ author=Actor._from_string(info['author'] + ' ' + info['author_email']),
authored_date=info['author_date'],
- committer=Actor.from_string(info['committer'] + ' ' + info['committer_email']),
+ committer=Actor._from_string(info['committer'] + ' ' + info['committer_email']),
committed_date=info['committer_date'],
message=info['summary'])
commits[sha] = c
@@ -357,7 +357,7 @@ class Repo(object):
if path:
arg.append(path)
commits = self.git.log(*arg, **options)
- return Commit.list_from_string(self, commits)
+ return Commit._list_from_string(self, commits)
def diff(self, a, b, *paths):
"""
diff --git a/lib/git/stats.py b/lib/git/stats.py
index 19b1591f..bda4e539 100644
--- a/lib/git/stats.py
+++ b/lib/git/stats.py
@@ -38,7 +38,7 @@ class Stats(object):
self.files = files
@classmethod
- def list_from_string(cls, repo, text):
+ def _list_from_string(cls, repo, text):
"""
Create a Stat object from output retrieved by git-diff.
diff --git a/test/git/test_actor.py b/test/git/test_actor.py
index ae4da507..b7c2af7c 100644
--- a/test/git/test_actor.py
+++ b/test/git/test_actor.py
@@ -10,19 +10,19 @@ from git import *
class TestActor(object):
def test_from_string_should_separate_name_and_email(self):
- a = Actor.from_string("Michael Trier <mtrier@example.com>")
+ a = Actor._from_string("Michael Trier <mtrier@example.com>")
assert_equal("Michael Trier", a.name)
assert_equal("mtrier@example.com", a.email)
def test_from_string_should_handle_just_name(self):
- a = Actor.from_string("Michael Trier")
+ a = Actor._from_string("Michael Trier")
assert_equal("Michael Trier", a.name)
assert_equal(None, a.email)
def test_should_display_representation(self):
- a = Actor.from_string("Michael Trier <mtrier@example.com>")
+ a = Actor._from_string("Michael Trier <mtrier@example.com>")
assert_equal('<git.Actor "Michael Trier <mtrier@example.com>">', repr(a))
def test_str_should_alias_name(self):
- a = Actor.from_string("Michael Trier <mtrier@example.com>")
+ a = Actor._from_string("Michael Trier <mtrier@example.com>")
assert_equal(a.name, str(a)) \ No newline at end of file
diff --git a/test/git/test_commit.py b/test/git/test_commit.py
index 71dad562..fa49821d 100644
--- a/test/git/test_commit.py
+++ b/test/git/test_commit.py
@@ -216,7 +216,7 @@ class TestCommit(object):
bisect_all=True)
assert_true(git.called)
- commits = Commit.list_from_string(self.repo, revs)
+ commits = Commit._list_from_string(self.repo, revs)
expected_ids = (
'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b',
'33ebe7acec14b25c5f84f35a664803fcab2f7781',
diff --git a/test/git/test_diff.py b/test/git/test_diff.py
index b9834879..b2339455 100644
--- a/test/git/test_diff.py
+++ b/test/git/test_diff.py
@@ -13,13 +13,13 @@ class TestDiff(object):
def test_list_from_string_new_mode(self):
output = fixture('diff_new_mode')
- diffs = Diff.list_from_string(self.repo, output)
+ diffs = Diff._list_from_string(self.repo, output)
assert_equal(1, len(diffs))
assert_equal(10, len(diffs[0].diff.splitlines()))
def test_diff_with_rename(self):
output = fixture('diff_rename')
- diffs = Diff.list_from_string(self.repo, output)
+ diffs = Diff._list_from_string(self.repo, output)
assert_equal(1, len(diffs))
diff --git a/test/git/test_stats.py b/test/git/test_stats.py
index 0063bb2d..706f29a4 100644
--- a/test/git/test_stats.py
+++ b/test/git/test_stats.py
@@ -11,9 +11,9 @@ class TestStats(object):
def setup(self):
self.repo = Repo(GIT_REPO)
- def test_list_from_string(self):
+ def test__list_from_string(self):
output = fixture('diff_numstat')
- stats = Stats.list_from_string(self.repo, output)
+ stats = Stats._list_from_string(self.repo, output)
assert_equal(2, stats.total['files'])
assert_equal(52, stats.total['lines'])
diff --git a/test/git/test_tree.py b/test/git/test_tree.py
index 50d34006..cb8ebb04 100644
--- a/test/git/test_tree.py
+++ b/test/git/test_tree.py
@@ -27,7 +27,7 @@ class TestTree(object):
def test_content_from_string_tree_should_return_tree(self):
text = fixture('ls_tree_a').splitlines()[-1]
- tree = Tree.content_from_string(None, text)
+ tree = Tree.content__from_string(None, text)
assert_equal(Tree, tree.__class__)
assert_equal("650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44", tree.id)
@@ -37,7 +37,7 @@ class TestTree(object):
def test_content_from_string_tree_should_return_blob(self):
text = fixture('ls_tree_b').split("\n")[0]
- tree = Tree.content_from_string(None, text)
+ tree = Tree.content__from_string(None, text)
assert_equal(Blob, tree.__class__)
assert_equal("aa94e396335d2957ca92606f909e53e7beaf3fbb", tree.id)
@@ -47,12 +47,12 @@ class TestTree(object):
def test_content_from_string_tree_should_return_commit(self):
text = fixture('ls_tree_commit').split("\n")[1]
- tree = Tree.content_from_string(None, text)
+ tree = Tree.content__from_string(None, text)
assert_none(tree)
@raises(TypeError)
def test_content_from_string_invalid_type_should_raise(self):
- Tree.content_from_string(None, "040000 bogus 650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44 test")
+ Tree.content__from_string(None, "040000 bogus 650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44 test")
@patch_object(Blob, 'size')
@patch_object(Git, '_call_process')