Skip to content

Commit b295c13

Browse files
committed
fix(tree): remove Tree.cache - use IndexFile.write_tree() instead
For more information, see CHANGES.rst Fixes #369
1 parent 4f1110b commit b295c13

File tree

2 files changed

+66
-150
lines changed

2 files changed

+66
-150
lines changed

Diff for: doc/source/changes.rst

+66-65
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ Changelog
99
used previously usually fails to release its resources (i.e. file handles), which can lead to problems when working
1010
with large repositories.
1111
* CRITICAL: fixed incorrect `Commit` object serialization when authored or commit date had timezones which were not
12-
divisable by 3600 seconds. This would happen if the timezone was something like `+0530` for instance.
12+
divisiblej by 3600 seconds. This would happen if the timezone was something like `+0530` for instance.
1313
* A list of all additional fixes can be found `on github <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v1.0.2+-+Fixes%22+is%3Aclosed>`_
14+
* CRITICAL: `Tree.cache` was removed without replacement. It is technically impossible to change individual trees and expect their serialization results to be consistent with what *git* expects. Instead, use the `IndexFile` facilities to adjust the content of the staging area, and write it out to the respective tree objects using `IndexFile.write_tree()` instead.
1415

1516
1.0.1 - Fixes
1617
=============
1718

18-
* A list of all issues can be found `on github <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v1.0.1+-+Fixes%22+is%3Aclosed>`_
19+
* A list of all issues can be found `on github <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v1.0.1+-+Fixes%22+is%3Aclosed>`_
1920

2021
1.0.0 - Notes
2122
=============
@@ -29,18 +30,18 @@ It follows the `semantic version scheme <http://semver.org>`_, and thus will not
2930
* `IndexFile.add()` will now write the index without any extension data by default. However, you may override this behaviour with the new `write_extension_data` keyword argument.
3031

3132
- Renamed `ignore_tree_extension_data` keyword argument in `IndexFile.write(...)` to `ignore_extension_data`
32-
* If the git command executed during `Remote.push(...)|fetch(...)` returns with an non-zero exit code and GitPython didn't
33+
* If the git command executed during `Remote.push(...)|fetch(...)` returns with an non-zero exit code and GitPython didn't
3334
obtain any head-information, the corresponding `GitCommandError` will be raised. This may break previous code which expected
34-
these operations to never raise. However, that behavious is undesirable as it would effectively hide the fact that there
35+
these operations to never raise. However, that behavious is undesirable as it would effectively hide the fact that there
3536
was an error. See `this issue <https://github.com/gitpython-developers/GitPython/issues/271>`_ for more information.
3637

3738
* If the git executable can't be found in the PATH or at the path provided by `GIT_PYTHON_GIT_EXECUTABLE`, this is made
3839
obvious by throwing `GitCommandNotFound`, both on unix and on windows.
3940

4041
- Those who support **GUI on windows** will now have to set `git.Git.USE_SHELL = True` to get the previous behaviour.
41-
42-
* A list of all issues can be found `on github <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v0.3.7+-+Fixes%22+is%3Aclosed>`_
43-
42+
43+
* A list of all issues can be found `on github <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v0.3.7+-+Fixes%22+is%3Aclosed>`_
44+
4445

4546
0.3.6 - Features
4647
================
@@ -54,7 +55,7 @@ It follows the `semantic version scheme <http://semver.org>`_, and thus will not
5455
* As `rev_parse` will now throw `BadName` as well as `BadObject`, client code will have to catch both exception types.
5556
* Repo.working_tree_dir now returns None if it is bare. Previously it raised AssertionError.
5657
* IndexFile.add() previously raised AssertionError when paths where used with bare repository, now it raises InvalidGitRepositoryError
57-
58+
5859
* Added `Repo.merge_base()` implementation. See the `respective issue on github <https://github.com/gitpython-developers/GitPython/issues/169>`_
5960
* `[include]` sections in git configuration files are now respected
6061
* Added `GitConfigParser.rename_section()`
@@ -89,7 +90,7 @@ It follows the `semantic version scheme <http://semver.org>`_, and thus will not
8990
=======
9091
* `Fix for #207 <https://github.com/gitpython-developers/GitPython/issues/207>`_
9192

92-
0.3.2
93+
0.3.2
9394
=====
9495

9596
* Release of most recent version as non-RC build, just to allow pip to install the latest version right away.
@@ -100,13 +101,13 @@ It follows the `semantic version scheme <http://semver.org>`_, and thus will not
100101
* **git** command wrapper
101102

102103
* Added ``version_info`` property which returns a tuple of integers representing the installed git version.
103-
104+
104105
* Added GIT_PYTHON_GIT_EXECUTABLE environment variable, which can be used to set the desired git executable to be used. despite of what would be found in the path.
105-
106+
106107
* **Blob** Type
107108

108109
* Added mode constants to ease the manual creation of blobs
109-
110+
110111
* **IterableList**
111112

112113
* Added __contains__ and __delitem__ methods
@@ -118,8 +119,8 @@ It follows the `semantic version scheme <http://semver.org>`_, and thus will not
118119
* Parsing of tags was improved. Previously some parts of the name could not be parsed properly.
119120
* The rev-parse pure python implementation now handles branches correctly if they look like hexadecimal sha's.
120121
* GIT_PYTHON_TRACE is now set on class level of the Git type, previously it was a module level global variable.
121-
* GIT_PYTHON_GIT_EXECUTABLE is a class level variable as well.
122-
122+
* GIT_PYTHON_GIT_EXECUTABLE is a class level variable as well.
123+
123124

124125
0.3.1 Beta 2
125126
============
@@ -128,7 +129,7 @@ It follows the `semantic version scheme <http://semver.org>`_, and thus will not
128129
* New types: ``RefLog`` and ``RefLogEntry``
129130
* Reflog is maintained automatically when creating references and deleting them
130131
* Non-intrusive changes to ``SymbolicReference``, these don't require your code to change. They allow to append messages to the reflog.
131-
132+
132133
* ``abspath`` property added, similar to ``abspath`` of Object instances
133134
* ``log()`` method added
134135
* ``log_append(...)`` method added
@@ -137,19 +138,19 @@ It follows the `semantic version scheme <http://semver.org>`_, and thus will not
137138
* ``set_object(...)`` method added (reflog support)
138139

139140
* **Intrusive Changes** to ``Head`` type
140-
141+
141142
* ``create(...)`` method now supports the reflog, but will not raise ``GitCommandError`` anymore as it is a pure python implementation now. Instead, it raises ``OSError``.
142-
143+
143144
* **Intrusive Changes** to ``Repo`` type
144-
145+
145146
* ``create_head(...)`` method does not support kwargs anymore, instead it supports a logmsg parameter
146-
147+
147148
* Repo.rev_parse now supports the [ref]@{n} syntax, where *n* is the number of steps to look into the reference's past
148149

149150
* **BugFixes**
150151

151152
* Removed incorrect ORIG_HEAD handling
152-
153+
153154
* **Flattened directory** structure to make development more convenient.
154155

155156
* .. note:: This alters the way projects using git-python as a submodule have to adjust their sys.path to be able to import git-python successfully.
@@ -178,7 +179,7 @@ Renamed Modules
178179
* git.utils -> git.util
179180
* git.errors -> git.exc
180181
* git.objects.utils -> git.objects.util
181-
182+
182183
General
183184
-------
184185
* Object instances, and everything derived from it, now use binary sha's internally. The 'sha' member was removed, in favor of the 'binsha' member. An 'hexsha' property is available for convenient conversions. They may only be initialized using their binary shas, reference names or revision specs are not allowed anymore.
@@ -189,7 +190,7 @@ General
189190
* IndexFile.get_entries_key was renamed to entry_key
190191
* IndexFile.write_tree: removed missing_ok keyword, its always True now. Instead of raising GitCommandError it raises UnmergedEntriesError. This is required as the pure-python implementation doesn't support the missing_ok keyword yet.
191192
* diff.Diff.null_hex_sha renamed to NULL_HEX_SHA, to be conforming with the naming in the Object base class
192-
193+
193194

194195
0.2 Beta 2
195196
===========
@@ -200,56 +201,56 @@ General
200201
=====
201202
General
202203
-------
203-
* file mode in Tree, Blob and Diff objects now is an int compatible to definintiions
204-
in the stat module, allowing you to query whether individual user, group and other
204+
* file mode in Tree, Blob and Diff objects now is an int compatible to definintiions
205+
in the stat module, allowing you to query whether individual user, group and other
205206
read, write and execute bits are set.
206207
* Adjusted class hierarchy to generally allow comparison and hash for Objects and Refs
207-
* Improved Tag object which now is a Ref that may contain a tag object with additional
208+
* Improved Tag object which now is a Ref that may contain a tag object with additional
208209
Information
209-
* id_abbrev method has been removed as it could not assure the returned short SHA's
210+
* id_abbrev method has been removed as it could not assure the returned short SHA's
210211
where unique
211212
* removed basename method from Objects with path's as it replicated features of os.path
212-
* from_string and list_from_string methods are now private and were renamed to
213-
_from_string and _list_from_string respectively. As part of the private API, they
213+
* from_string and list_from_string methods are now private and were renamed to
214+
_from_string and _list_from_string respectively. As part of the private API, they
214215
may change without prior notice.
215216
* Renamed all find_all methods to list_items - this method is part of the Iterable interface
216217
that also provides a more efficients and more responsive iter_items method
217218
* All dates, like authored_date and committer_date, are stored as seconds since epoc
218-
to consume less memory - they can be converted using time.gmtime in a more suitable
219+
to consume less memory - they can be converted using time.gmtime in a more suitable
219220
presentation format if needed.
220-
* Named method parameters changed on a wide scale to unify their use. Now git specific
221+
* Named method parameters changed on a wide scale to unify their use. Now git specific
221222
terms are used everywhere, such as "Reference" ( ref ) and "Revision" ( rev ).
222223
Prevously multiple terms where used making it harder to know which type was allowed
223224
or not.
224225
* Unified diff interface to allow easy diffing between trees, trees and index, trees
225226
and working tree, index and working tree, trees and index. This closely follows
226227
the git-diff capabilities.
227-
* Git.execute does not take the with_raw_output option anymore. It was not used
228+
* Git.execute does not take the with_raw_output option anymore. It was not used
228229
by anyone within the project and False by default.
229-
230+
230231

231232
Item Iteration
232233
--------------
233-
* Previously one would return and process multiple items as list only which can
234-
hurt performance and memory consumption and reduce response times.
235-
iter_items method provide an iterator that will return items on demand as parsed
234+
* Previously one would return and process multiple items as list only which can
235+
hurt performance and memory consumption and reduce response times.
236+
iter_items method provide an iterator that will return items on demand as parsed
236237
from a stream. This way any amount of objects can be handled.
237238
* list_items method returns IterableList allowing to access list members by name
238-
239+
239240
objects Package
240241
----------------
241-
* blob, tree, tag and commit module have been moved to new objects package. This should
242-
not affect you though unless you explicitly imported individual objects. If you just
242+
* blob, tree, tag and commit module have been moved to new objects package. This should
243+
not affect you though unless you explicitly imported individual objects. If you just
243244
used the git package, names did not change.
244-
245+
245246
Blob
246247
----
247248
* former 'name' member renamed to path as it suits the actual data better
248249

249250
GitCommand
250251
-----------
251-
* git.subcommand call scheme now prunes out None from the argument list, allowing
252-
to be called more confortably as None can never be a valid to the git command
252+
* git.subcommand call scheme now prunes out None from the argument list, allowing
253+
to be called more confortably as None can never be a valid to the git command
253254
if converted to a string.
254255
* Renamed 'git_dir' attribute to 'working_dir' which is exactly how it is used
255256

@@ -263,43 +264,43 @@ Config
263264
* The git configuration can now be read and manipulated directly from within python
264265
using the GitConfigParser
265266
* Repo.config_reader() returns a read-only parser
266-
* Repo.config_writer() returns a read-write parser
267-
267+
* Repo.config_writer() returns a read-write parser
268+
268269
Diff
269270
----
270271
* Members a a_commit and b_commit renamed to a_blob and b_blob - they are populated
271272
with Blob objects if possible
272273
* Members a_path and b_path removed as this information is kept in the blobs
273-
* Diffs are now returned as DiffIndex allowing to more quickly find the kind of
274+
* Diffs are now returned as DiffIndex allowing to more quickly find the kind of
274275
diffs you are interested in
275-
276+
276277
Diffing
277278
-------
278-
* Commit and Tree objects now support diffing natively with a common interface to
279+
* Commit and Tree objects now support diffing natively with a common interface to
279280
compare agains other Commits or Trees, against the working tree or against the index.
280281

281282
Index
282283
-----
283284
* A new Index class allows to read and write index files directly, and to perform
284285
simple two and three way merges based on an arbitrary index.
285-
286+
286287
Referernces
287288
------------
288289
* References are object that point to a Commit
289290
* SymbolicReference are a pointer to a Reference Object, which itself points to a specific
290291
Commit
291-
* They will dynmically retrieve their object at the time of query to assure the information
292-
is actual. Recently objects would be cached, hence ref object not be safely kept
292+
* They will dynmically retrieve their object at the time of query to assure the information
293+
is actual. Recently objects would be cached, hence ref object not be safely kept
293294
persistent.
294-
295+
295296
Repo
296297
----
297298
* Moved blame method from Blob to repo as it appeared to belong there much more.
298-
* active_branch method now returns a Head object instead of a string with the name
299+
* active_branch method now returns a Head object instead of a string with the name
299300
of the active branch.
300301
* tree method now requires a Ref instance as input and defaults to the active_branche
301302
instead of master
302-
* is_dirty now takes additional arguments allowing fine-grained control about what is
303+
* is_dirty now takes additional arguments allowing fine-grained control about what is
303304
considered dirty
304305
* Removed the following methods:
305306

@@ -311,15 +312,15 @@ Repo
311312
- 'create' method which equals the 'init' method's functionality
312313
- 'diff' - it returned a mere string which still had to be parsed
313314
- 'commit_diff' - moved to Commit, Tree and Diff types respectively
314-
315+
315316
* Renamed the following methods:
316317

317318
- commits to iter_commits to improve the performance, adjusted signature
318319
- init_bare to init, implying less about the options to be used
319320
- fork_bare to clone, as it was to represent general clone functionality, but implied
320321
a bare clone to be more versatile
321322
- archive_tar_gz and archive_tar and replaced by archive method with different signature
322-
323+
323324
* 'commits' method has no max-count of returned commits anymore, it now behaves like git-rev-list
324325
* The following methods and properties were added
325326

@@ -330,16 +331,16 @@ Repo
330331
- 'config_reader' method
331332
- 'config_writer' method
332333
- 'bare' property, previously it was a simple attribute that could be written
333-
334+
334335
* Renamed the following attributes
335336

336337
- 'path' is now 'git_dir'
337338
- 'wd' is now 'working_dir'
338-
339+
339340
* Added attribute
340341

341342
- 'working_tree_dir' which may be None in case of bare repositories
342-
343+
343344
Remote
344345
------
345346
* Added Remote object allowing easy access to remotes
@@ -349,15 +350,15 @@ Remote
349350
Test Framework
350351
--------------
351352
* Added support for common TestCase base class that provides additional functionality
352-
to receive repositories tests can also write to. This way, more aspects can be
353+
to receive repositories tests can also write to. This way, more aspects can be
353354
tested under real-world ( un-mocked ) conditions.
354355

355356
Tree
356357
----
357358
* former 'name' member renamed to path as it suits the actual data better
358359
* added traverse method allowing to recursively traverse tree items
359360
* deleted blob method
360-
* added blobs and trees properties allowing to query the respective items in the
361+
* added blobs and trees properties allowing to query the respective items in the
361362
tree
362363
* now mimics behaviour of a read-only list instead of a dict to maintain order.
363364
* content_from_string method is now private and not part of the public API anymore
@@ -496,14 +497,14 @@ Git
496497

497498
* Added support for ``stderr``, ``stdin``, and ``with_status``.
498499

499-
* ``git_dir`` is now optional in the constructor for ``git.Git``. Git now
500+
* ``git_dir`` is now optional in the constructor for ``git.Git``. Git now
500501
falls back to ``os.getcwd()`` when git_dir is not specified.
501502

502-
* add a ``with_exceptions`` keyword argument to git commands.
503+
* add a ``with_exceptions`` keyword argument to git commands.
503504
``GitCommandError`` is raised when the exit status is non-zero.
504505

505-
* add support for a ``GIT_PYTHON_TRACE`` environment variable.
506-
``GIT_PYTHON_TRACE`` allows us to debug GitPython's usage of git through
506+
* add support for a ``GIT_PYTHON_TRACE`` environment variable.
507+
``GIT_PYTHON_TRACE`` allows us to debug GitPython's usage of git through
507508
the use of an environment variable.
508509

509510
Tree
@@ -519,8 +520,8 @@ Repo
519520

520521
Tree
521522
----
522-
* Corrected problem with ``Tree.__div__`` not working with zero length files.
523-
Removed ``__len__`` override and replaced with size instead. Also made size
523+
* Corrected problem with ``Tree.__div__`` not working with zero length files.
524+
Removed ``__len__`` override and replaced with size instead. Also made size
524525
cach properly. This is a breaking change.
525526

526527
0.1.1

0 commit comments

Comments
 (0)