mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-19 12:34:17 +00:00
Improve checkout performance for the common unmodified case
Most projects will have their branch heads matching in all branches, so switching between them should be just a matter of updating the work tree's HEAD symref. This can be done in pure Python, saving quite a bit of time over forking 'git checkout'. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
|
||||
import sys
|
||||
from command import Command
|
||||
from progress import Progress
|
||||
|
||||
class Checkout(Command):
|
||||
common = True
|
||||
@ -35,13 +36,23 @@ The command is equivalent to:
|
||||
if not args:
|
||||
self.Usage()
|
||||
|
||||
retValue = 0;
|
||||
nb = args[0]
|
||||
err = []
|
||||
all = self.GetProjects(args[1:])
|
||||
|
||||
branch = args[0]
|
||||
for project in self.GetProjects(args[1:]):
|
||||
if not project.CheckoutBranch(branch):
|
||||
retValue = 1;
|
||||
print >>sys.stderr, "error: checking out branch '%s' in %s failed" % (branch, project.name)
|
||||
pm = Progress('Checkout %s' % nb, len(all))
|
||||
for project in all:
|
||||
pm.update()
|
||||
if not project.CheckoutBranch(nb):
|
||||
err.append(project)
|
||||
pm.end()
|
||||
|
||||
if (retValue != 0):
|
||||
sys.exit(retValue);
|
||||
if err:
|
||||
if len(err) == len(all):
|
||||
print >>sys.stderr, 'error: no project has branch %s' % nb
|
||||
else:
|
||||
for p in err:
|
||||
print >>sys.stderr,\
|
||||
"error: %s/: cannot checkout %s" \
|
||||
% (p.relpath, nb)
|
||||
sys.exit(1)
|
||||
|
@ -49,7 +49,8 @@ revision specified in the manifest.
|
||||
pm.end()
|
||||
|
||||
if err:
|
||||
err.sort()
|
||||
for p in err:
|
||||
print >>sys.stderr, "error: cannot start in %s" % p.relpath
|
||||
print >>sys.stderr,\
|
||||
"error: %s/: cannot start %s" \
|
||||
% (p.relpath, nb)
|
||||
sys.exit(1)
|
||||
|
Reference in New Issue
Block a user