39 Commits

Author SHA1 Message Date
Brodie Rao
78d134c016 repository: add listall_reference_objects() method
This allows for efficient reading of many references and their targets,
without incurring the overhead of lookup_reference() (which stats for
a loose ref and then reads packed-refs) which can be expensive on NFS
with thousands of refs.
2014-01-08 15:14:27 -08:00
J. David Ibáñez
70edbf256a Update copyright years 2015-10-11 18:48:59 +02:00
Carlos Martín Nieto
81520c9c62 Update to libgit2 v0.23 2015-07-06 18:49:20 +02:00
Carlos Martín Nieto
b98e9e85de Reference: implement peel()
This makes both objects and references peelable via the same interface,
simplifying how to get to the wanted type.
2014-10-07 20:27:01 +02:00
Carlos Martín Nieto
4d053cf066 Get rid of a settable Reference.target
Updating the target of a reference is not like setting a property. It
involves appending to the reflog under the same lock, so we must do it
all the same time. Thus setting the target becomes a function which
takes the new target and what the use would like to add to the reflog.
2014-08-28 01:25:21 +02:00
J. David Ibáñez
d7071b88cd Update copyright year 2014-02-04 08:02:12 +01:00
Carlos Martín Nieto
500a6793c4 Object: move to use an 'id' attribute instead of 'oid'
This looks like a left-over from the libgit2 misnaming. The current
consensus is that 'oid' is the data type and 'id' is the name of the
attribute.
2014-01-24 11:04:34 +01:00
Carlos Martín Nieto
9da4d4fb9f reference: add a shorthand property
Add Reference.shorthand to make it simpler to present a human-readable
name for a particular reference.
2013-11-02 15:45:55 +01:00
J. David Ibáñez
9a78ddafa3 Upgrading to libgit2 0.19 (wip) 2013-06-29 12:38:41 +02:00
Nico von Geyso
6866a3aac5 Added: Reference.get_object() method
get_object() retrieves the object the current reference is pointing to
2013-05-28 11:23:26 +02:00
J. David Ibáñez
0c86307eb5 Coding style: Silent pep8 2013-05-26 14:39:12 +02:00
J. David Ibáñez
74a1fdab60 Fixing coding style with the help of pep8 (wip) 2013-05-26 10:32:05 +02:00
J. David Ibáñez
67417c7f56 create_reference, drop the symbolic param (#213)
Now we figure out whether it is a direct or symbolic reference based on
the type and value of the target. This guessing will fail in very very
rare situations, for that we still have the explicit lower level API.
2013-04-27 11:39:37 +02:00
J. David Ibáñez
979cda9a9a refs: improve API (#213)
Changes:

- Reference.oid and Reference.hex removed
- Now Reference.target can be assigned an oid
2013-04-21 10:46:04 +02:00
J. David Ibáñez
a3a928a513 Now Reference.target returns an Oid, not hex
If the reference is direct, of course.
2013-04-20 09:03:13 +02:00
J. David Ibáñez
27aba1f3c8 Update to changes in libgit2 concerning refs
Two methods have been drop:

- Repository.packall_references
- Reference.reload

The unit tests have been commented until we wrap the new reference
database from libgit2.
2013-03-09 12:36:58 +01:00
J. David Ibáñez
29ce23c0d5 Update copyright 2013-03-02 12:16:16 +01:00
J. David Ibáñez
a96d494747 Coding style
Including:

- Lines longer than 79 chars
- Spaces at the end of line
- Wrong indentation
- Comma not followed by an space
- C++ style comments: //
2013-03-02 11:40:42 +01:00
Nico von Geyso
a511f299bb fixex api changes of libgit2 in 64c5112 2012-11-28 18:10:07 +01:00
J. David Ibáñez
40751b62b3 style: remove tabs and trailing white-space 2012-11-14 18:08:08 +01:00
Nico von Geyso
e1acdb48bc use latest development of libgit2 - changed GitError to ValueError
For already existing references a ValueError is raised (see sry/pygit2/error.c:41)
2012-10-12 11:51:08 +02:00
Nico von Geyso
682fb1fd13 merged create_reference and create_reference_symbolic and added force-Option
To be more pythonic: merged methods create_reference and create_reference_symbolic
and added force-Option. To make a new symbolic reference you have provide symbolic=True
as an additional parameter. If force=True references will although be overridden.
Otherwise an exception is raised if the references exists.

Examples:

  # normal reference
    repo.create_reference('refs/heads/foo', repo.head.hex)

  # override reference with new value
    repo.create_reference('refs/heads/foo', repo.head.hex, force=True)

  # symbolic reference
    repo.create_reference('refs/tags/foo', 'refs/heads/master', symbolic = True)
2012-10-09 13:13:36 +02:00
J. David Ibáñez
ad8103bc48 Fix reference test case
Now git_reference_lookup says "foo" is an invalid reference name
(returns GITERR_REFERENCE instead of GIT_ENOTFOUND).
2012-10-03 14:08:27 +02:00
J. David Ibáñez
edcd803e7e Remove the __authors__ var from py files 2012-07-18 12:12:04 +02:00
J. David Ibáñez
6195491596 Add/update copyright header of each file
And update my email address.
2012-07-18 12:07:17 +02:00
J. David Ibáñez
ec8047a8c5 Fix errors detected by pyflakes 2012-06-18 11:36:27 -03:00
Nico von Geyso
e402d0e9eb added head-getter for Repository
You do not have to lookup and resolve the HEAD reference anymore if you simply want
the last commit. Repository has now a head-getter which combines all these steps.

example:
  repo = Repository('.')
  head = repo.head
  print(head.message)
2012-05-28 12:41:43 +02:00
Carlos Martín Nieto
7137f8217e Add tests for the short OID support 2012-03-15 05:33:13 +01:00
J. David Ibáñez
4a33c7f806 refs: implement reference reload 2011-12-25 10:46:38 +01:00
J. David Ibáñez
73a4a3a649 refs: resolving a direct ref returns the same object
When resolving a direct reference the same Python object is returned,
with the refcount incremented by one. The reference is reloaded.
2011-12-24 17:04:24 +01:00
J. David Ibáñez
5986688197 refs: fix segfault when using a deleted reference
Before this patch the code below produced a segfault:

  >>> reference.delete()
  >>> reference.name

Now an exception is raised.
2011-12-19 23:40:27 +01:00
J. David Ibáñez
83642a6954 Rename '.sha' to '.hex' 2011-09-02 16:53:17 +02:00
J. David Ibáñez
9f2e61cd8f Add TreeEntry.oid, IndexEntry.oid, Reference.oid 2011-09-02 16:48:35 +02:00
J. David Ibáñez
f09a02a2ee Use UTF-8 encoding in all Python files 2011-08-24 07:42:05 +02:00
J. David Ibáñez
b84b79acd8 Fix running the tests with Python 3
Now "python3 setup.py test" works.
2011-08-24 00:07:20 +02:00
J. David Ibáñez
7950ee1116 Use Python 3 string literals for the unit tests
Now unit tests are broken.
2011-08-13 22:48:23 +02:00
Sebastian Thiel
84cb4616b7 Fixed reference tests, they were dependent on the order of the file-system, which in fact is undetermined. Sorting them to assure order 2011-07-08 11:04:28 +02:00
David Versmisse
858adab759 Implement the References (part II) 2011-04-28 10:25:37 +02:00
David Versmisse
aac4cf1b86 Implement the References (part I) 2011-04-15 11:09:20 +02:00