diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-16 11:48:20 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-16 11:48:20 +0200 |
commit | 05d2687afcc78cd192714ee3d71fdf36a37d110f (patch) | |
tree | 3e3760e5b46095458cf75446330ba2fc25fa23e5 /lib/git/objects/utils.py | |
parent | 6226720b0e6a5f7cb9223fc50363def487831315 (diff) | |
parent | f2df1f56cccab13d5c92abbc6b18be725e7b4833 (diff) | |
download | gitpython-05d2687afcc78cd192714ee3d71fdf36a37d110f.tar.gz |
Merging latest improvements including a revamped Repo interface before more changes are to be done on the way diffing is handled
Merge branch 'improvements'
* improvements:
Improved archive function by allowing it to directly write to an output stream - previously it would cache everything to memory and try to provide zipping functionality itself
repo: made init and clone methods less specific, previously they wanted to do it 'barely' only. New method names closely follow the default git command names
repo.commit_delta_base: removed
Object can now create objects of the proper type in case one attempts to create an object directly - this feature is used in several places now, allowing for additional type-checking
repo: removed commits_between but added a note about how this can be achieved using the iter_commits method; reorganized methods within the type as a start for more interface changes
Added Commit.iter_parents to iterate all parents
repo: removed a few methods because of redundancy or because it will be obsolete once the interface overhaul is finished. This commit is just intermediate
All times are not stored as time_struct, but as simple int to consume less memory
Diffstat (limited to 'lib/git/objects/utils.py')
-rw-r--r-- | lib/git/objects/utils.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/git/objects/utils.py b/lib/git/objects/utils.py index 15c1d114..367ed2b7 100644 --- a/lib/git/objects/utils.py +++ b/lib/git/objects/utils.py @@ -6,7 +6,8 @@ """ Module for general utility functions """ -import commit, tag, blob, tree +import re +from git.actor import Actor def get_object_type_by_name(object_type_name): """ @@ -34,3 +35,20 @@ def get_object_type_by_name(object_type_name): return tree.Tree else: raise ValueError("Cannot handle unknown object type: %s" % object_type_name) + + +# precompiled regex +_re_actor_epoch = re.compile(r'^.+? (.*) (\d+) .*$') + +def parse_actor_and_date(line): + """ + Parse out the actor (author or committer) info from a line like:: + + author Tom Preston-Werner <tom@mojombo.com> 1191999972 -0700 + + Returns + [Actor, int_seconds_since_epoch] + """ + m = _re_actor_epoch.search(line) + actor, epoch = m.groups() + return (Actor._from_string(actor), int(epoch)) |