diff options
| author | Shawn O. Pearce <sop@google.com> | 2009-04-18 15:04:41 -0700 |
|---|---|---|
| committer | Shawn O. Pearce <sop@google.com> | 2009-04-18 15:04:41 -0700 |
| commit | 89e717d9481c0c69292a39f85599f5df8277b004 (patch) | |
| tree | 1fc613edd34eb349b673505b872be21a416ab52f /subcmds/checkout.py | |
| parent | 0f0dfa3930bc16078ef0b1a00ff6849333038fc7 (diff) | |
| download | git-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/checkout.py')
| -rw-r--r-- | subcmds/checkout.py | 31 |
1 files changed, 21 insertions, 10 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 | ||
| 16 | import sys | 16 | import sys |
| 17 | from command import Command | 17 | from command import Command |
| 18 | from progress import Progress | ||
| 18 | 19 | ||
| 19 | class Checkout(Command): | 20 | class 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) | ||
