Try harder to detect an existing checkout before 'fetch'ing.

BUG=230693
R=agable@chromium.org

Review URL: https://codereview.chromium.org/1169403002.

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295611 0039d316-1c4b-4281-b951-d872f2087c98
changes/01/332501/1
mmoss@chromium.org 11 years ago
parent f0e4152061
commit 5a44776411

@ -63,7 +63,7 @@ class Checkout(object):
print 'Running: %s' % (' '.join(pipes.quote(x) for x in cmd)) print 'Running: %s' % (' '.join(pipes.quote(x) for x in cmd))
if self.options.dry_run: if self.options.dry_run:
return 0 return 0
return subprocess.check_call(cmd, **kwargs) return subprocess.check_output(cmd, **kwargs)
class GclientCheckout(Checkout): class GclientCheckout(Checkout):
@ -75,6 +75,15 @@ class GclientCheckout(Checkout):
cmd_prefix = ('gclient',) cmd_prefix = ('gclient',)
return self.run(cmd_prefix + cmd, **kwargs) return self.run(cmd_prefix + cmd, **kwargs)
def exists(self):
try:
gclient_root = self.run_gclient('root').strip()
return (os.path.exists(os.path.join(gclient_root, '.gclient')) or
os.path.exists(os.path.join(os.getcwd(), self.root)))
except subprocess.CalledProcessError:
pass
return os.path.exists(os.path.join(os.getcwd(), self.root))
class GitCheckout(Checkout): class GitCheckout(Checkout):
@ -120,9 +129,6 @@ class GclientGitCheckout(GclientCheckout, GitCheckout):
for key in extra_keys if key in self.spec) for key in extra_keys if key in self.spec)
return gclient_spec return gclient_spec
def exists(self):
return os.path.exists(os.path.join(os.getcwd(), self.root))
def init(self): def init(self):
# Configure and do the gclient checkout. # Configure and do the gclient checkout.
self.run_gclient('config', '--spec', self._format_spec()) self.run_gclient('config', '--spec', self._format_spec())
@ -315,8 +321,9 @@ def run(options, spec, root):
except KeyError: except KeyError:
return 1 return 1
if checkout.exists(): if checkout.exists():
print 'You appear to already have a checkout. "fetch" is used only' print 'Your current directory appears to already contain, or be part of, '
print 'to get new checkouts. Use "gclient sync" to update the checkout.' print 'a checkout. "fetch" is used only to get new checkouts. Use '
print '"gclient sync" to update existing checkouts.'
print print
print 'Fetch also does not yet deal with partial checkouts, so if fetch' print 'Fetch also does not yet deal with partial checkouts, so if fetch'
print 'failed, delete the checkout and start over (crbug.com/230691).' print 'failed, delete the checkout and start over (crbug.com/230691).'

Loading…
Cancel
Save