Skip to content

Commit 95bb489

Browse files
committed
test_tree works
1 parent 4cfc682 commit 95bb489

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

doc/source/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Changelog
77
* Internally, hexadecimal SHA1 are treated as ascii encoded strings. Binary SHA1 are treated as bytes.
88
* Id attribute of Commit objects is now `hexsha`, instead of `binsha`. The latter makes no sense in python 3 and I see no application of it anyway besides its artificial usage in test cases.
99
* **IMPORTANT**: If you were using the config_writer(), you implicitly relied on __del__ to work as expected to flush changes. To be sure changes are flushed under PY3, you will have to call the new `release()` method to trigger a flush. For some reason, __del__ is not called necessarily anymore when a symbol goes out of scope.
10+
* The `Tree` now has a `.join('name')` method which is equivalent to `tree / 'name'`
1011

1112
0.3.3
1213
=====

git/objects/tree.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _iter_convert_to_object(self, iterable):
159159
raise TypeError("Unknown mode %o found in tree data for path '%s'" % (mode, path))
160160
# END for each item
161161

162-
def __div__(self, file):
162+
def join(self, file):
163163
"""Find the named object in this tree's contents
164164
:return: ``git.Blob`` or ``git.Tree`` or ``git.Submodule``
165165
@@ -192,6 +192,14 @@ def __div__(self, file):
192192
raise KeyError(msg % file)
193193
# END handle long paths
194194

195+
def __div__(self, file):
196+
"""For PY2 only"""
197+
return self.join(file)
198+
199+
def __truediv__(self, file):
200+
"""For PY3 only"""
201+
return self.join(file)
202+
195203
@property
196204
def trees(self):
197205
""":return: list(Tree, ...) list of trees directly below this tree"""
@@ -235,7 +243,7 @@ def __getitem__(self, item):
235243

236244
if isinstance(item, string_types):
237245
# compatability
238-
return self.__div__(item)
246+
return self.join(item)
239247
# END index is basestring
240248

241249
raise TypeError("Invalid index type: %r" % item)

git/test/test_tree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def test_traverse(self):
138138
# END check for slash
139139

140140
# slashes in paths are supported as well
141+
# NOTE: on py3, / doesn't work with strings anymore ...
141142
assert root[item.path] == item == root / item.path
142143
# END for each item
143144
assert found_slash

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy