diff options
author | Johannes Berg <johannes.berg@intel.com> | 2013-05-08 09:42:38 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-05-08 09:45:51 +0200 |
commit | 29078ef058f964ba61deceac755915871f4668c6 (patch) | |
tree | b5780ccc57caa45c38e5028ef008d7c9a6cc1dcd /lib | |
parent | b0b3200b9489c2629686c367c1344055a5316e77 (diff) |
gentree: use git library to speed up --git-revision
If the git library is available (on many distros, just
install python-git or similar) then use it to read the
git blobs from disk if --git-revision is used.
On my system (with an SSD) this speeds up the entire
backport generation process significantly (when using
--git-revision):
before:
real 0m39.280s
user 0m13.464s
sys 0m16.644s
after:
real 0m22.554s
user 0m16.404s
sys 0m5.724s
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bpgit.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/bpgit.py b/lib/bpgit.py index d61d90a8..31b7de36 100644 --- a/lib/bpgit.py +++ b/lib/bpgit.py @@ -81,10 +81,16 @@ def ls_tree(rev, files, tree=None): return ret def get_blob(blob, outf, tree=None): - process = subprocess.Popen(['git', 'show', blob], - stdout=outf, close_fds=True, cwd=tree) - process.wait() - _check(process) + try: + import git, gitdb + r = git.Repo(path=tree) + b = r.rev_parse(blob + '^{blob}') + b.stream_data(outf) + except ImportError: + process = subprocess.Popen(['git', 'show', blob], + stdout=outf, close_fds=True, cwd=tree) + process.wait() + _check(process) def clone(gittree, outputdir, options=[]): process = subprocess.Popen(['git', 'clone'] + options + [gittree, outputdir]) |