diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2016-03-03 15:56:40 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2016-03-03 17:11:25 +0000 |
commit | 014a029ade9a045a839ca86c35690b218098ea33 (patch) | |
tree | 4806d6cc1f0572604a4d027bf7a7141e381f85d6 /morphlib/git.py | |
parent | e8a67a7d12d2defbf975d707e7513837403d93a2 (diff) | |
download | morph-014a029ade9a045a839ca86c35690b218098ea33.tar.gz |
Get rid of the CachedRepo class (almost)
For a long time the CachedRepo class has basically been a wrapper around
the GitDir class, but with a few extra methods that don't really even
belong there.
It is now a tiny class in the localrepocache module which just keeps
track of a few extra attributes. All other functionality is provided
by the gitdir module.
This commit also removes the `git clone` approach for copying repos out
of the cache. The alternative approach implemented by
git.copy_repository() was slightly faster when I tested, so for now we
should use that everywhere. Longer term we should find out why this is
quicker than `git clone`, and fix Git itself to be fast.
Change-Id: I1686ab43253d44c3903d9a0bad8bb75528e9cf75
Diffstat (limited to 'morphlib/git.py')
-rw-r--r-- | morphlib/git.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/morphlib/git.py b/morphlib/git.py index b6f54d02..190544ac 100644 --- a/morphlib/git.py +++ b/morphlib/git.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2015 Codethink Limited +# Copyright (C) 2011-2016 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -226,6 +226,10 @@ def copy_repository(runcmd, repo, destdir, is_mirror=True): This also fixes up the repository afterwards, so that it can contain code etc. It does not leave any given branch ready for use. + This is slightly faster than `git clone` for large repositories, + as of Git 2.3.0. Long term, we should fix `git clone` to be as fast + as possible, and use that. + ''' if is_mirror == False: runcmd(['cp', '-a', os.path.join(repo, '.git'), @@ -272,21 +276,6 @@ def reset_workdir(runcmd, gitdir): gitcmd(runcmd, 'reset', '--hard', 'HEAD', cwd=gitdir) -def clone_into(runcmd, srcpath, targetpath, ref=None): - '''Clones a repo in srcpath into targetpath, optionally directly at ref.''' - - if ref is None: - gitcmd(runcmd, 'clone', srcpath, targetpath) - elif is_valid_sha1(ref): - gitcmd(runcmd, 'clone', srcpath, targetpath) - gitcmd(runcmd, 'checkout', ref, cwd=targetpath) - else: - gitcmd(runcmd, 'clone', '-b', ref, srcpath, targetpath) - gd = morphlib.gitdir.GitDirectory(targetpath) - if gd.has_fat(): - gd.fat_init() - gd.fat_pull() - def is_valid_sha1(ref): '''Checks whether a string is a valid SHA1.''' |