summaryrefslogtreecommitdiffstats
path: root/subcmds
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-04-18 15:04:41 -0700
committerShawn O. Pearce <sop@google.com>2009-04-18 15:04:41 -0700
commit89e717d9481c0c69292a39f85599f5df8277b004 (patch)
tree1fc613edd34eb349b673505b872be21a416ab52f /subcmds
parent0f0dfa3930bc16078ef0b1a00ff6849333038fc7 (diff)
downloadgit-repo-89e717d9481c0c69292a39f85599f5df8277b004.tar.gz
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>
Diffstat (limited to 'subcmds')
-rw-r--r--subcmds/checkout.py31
-rw-r--r--subcmds/start.py5
2 files changed, 24 insertions, 12 deletions
diff --git a/subcmds/checkout.py b/subcmds/checkout.py
index 07644c95..4198acd1 100644
--- a/subcmds/checkout.py
+++ b/subcmds/checkout.py
@@ -15,6 +15,7 @@
15 15
16import sys 16import sys
17from command import Command 17from command import Command
18from progress import Progress
18 19
19class Checkout(Command): 20class Checkout(Command):
20 common = True 21 common = True
@@ -35,13 +36,23 @@ The command is equivalent to:
35 if not args: 36 if not args:
36 self.Usage() 37 self.Usage()
37 38
38 retValue = 0; 39 nb = args[0]
39 40 err = []
40 branch = args[0] 41 all = self.GetProjects(args[1:])
41 for project in self.GetProjects(args[1:]): 42
42 if not project.CheckoutBranch(branch): 43 pm = Progress('Checkout %s' % nb, len(all))
43 retValue = 1; 44 for project in all:
44 print >>sys.stderr, "error: checking out branch '%s' in %s failed" % (branch, project.name) 45 pm.update()
45 46 if not project.CheckoutBranch(nb):
46 if (retValue != 0): 47 err.append(project)
47 sys.exit(retValue); 48 pm.end()
49
50 if err:
51 if len(err) == len(all):
52 print >>sys.stderr, 'error: no project has branch %s' % nb
53 else:
54 for p in err:
55 print >>sys.stderr,\
56 "error: %s/: cannot checkout %s" \
57 % (p.relpath, nb)
58 sys.exit(1)
diff --git a/subcmds/start.py b/subcmds/start.py
index 49bb0e1a..8c74625f 100644
--- a/subcmds/start.py
+++ b/subcmds/start.py
@@ -49,7 +49,8 @@ revision specified in the manifest.
49 pm.end() 49 pm.end()
50 50
51 if err: 51 if err:
52 err.sort()
53 for p in err: 52 for p in err:
54 print >>sys.stderr, "error: cannot start in %s" % p.relpath 53 print >>sys.stderr,\
54 "error: %s/: cannot start %s" \
55 % (p.relpath, nb)
55 sys.exit(1) 56 sys.exit(1)