mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
3ba5f95b46
In the current version of repo checkout, we often get the error: error: no project has branch xyzzy ...even when the actual error was something else. This fixes it to only report the 'no project has branch' when that is actually true. This fix is very similar to one made for 'repo abandon': https://review.source.android.com/#change,22207 The repo checkout error is filed as: <http://crosbug.com/6514> TEST=manual A sample creating a case where 'git checkout' will fail: $ repo start branch1 . $ repo start branch2 . $ touch bogusfile $ git add bogusfile $ git commit -m "create bogus file" [branch2 f8b6b08] create bogus file 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 bogusfile $ echo "More" >> bogusfile $ repo checkout branch1 . error: chromite/: cannot checkout branch1 A sample case showing that we still fail if no project has a branch: $ repo checkout xyzzy . error: no project has branch xyzzy Change-Id: I48a8e258fa7a9c1f2800dafc683787204bbfcc63
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
#
|
|
# Copyright (C) 2009 The Android Open Source Project
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import sys
|
|
from command import Command
|
|
from progress import Progress
|
|
|
|
class Checkout(Command):
|
|
common = True
|
|
helpSummary = "Checkout a branch for development"
|
|
helpUsage = """
|
|
%prog <branchname> [<project>...]
|
|
"""
|
|
helpDescription = """
|
|
The '%prog' command checks out an existing branch that was previously
|
|
created by 'repo start'.
|
|
|
|
The command is equivalent to:
|
|
|
|
repo forall [<project>...] -c git checkout <branchname>
|
|
"""
|
|
|
|
def Execute(self, opt, args):
|
|
if not args:
|
|
self.Usage()
|
|
|
|
nb = args[0]
|
|
err = []
|
|
success = []
|
|
all = self.GetProjects(args[1:])
|
|
|
|
pm = Progress('Checkout %s' % nb, len(all))
|
|
for project in all:
|
|
pm.update()
|
|
|
|
status = project.CheckoutBranch(nb)
|
|
if status is not None:
|
|
if status:
|
|
success.append(project)
|
|
else:
|
|
err.append(project)
|
|
pm.end()
|
|
|
|
if err:
|
|
for p in err:
|
|
print >>sys.stderr,\
|
|
"error: %s/: cannot checkout %s" \
|
|
% (p.relpath, nb)
|
|
sys.exit(1)
|
|
elif not success:
|
|
print >>sys.stderr, 'error: no project has branch %s' % nb
|
|
sys.exit(1)
|