OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
6 | 6 |
7 from __future__ import print_function | 7 from __future__ import print_function |
8 | 8 |
9 import errno | 9 import errno |
10 import logging | 10 import logging |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 self._UpdateBranchHeads(options, fetch=False) | 301 self._UpdateBranchHeads(options, fetch=False) |
302 | 302 |
303 cfg = gclient_utils.DefaultIndexPackConfig(self.url) | 303 cfg = gclient_utils.DefaultIndexPackConfig(self.url) |
304 fetch_cmd = cfg + ['fetch', self.remote, '--prune'] | 304 fetch_cmd = cfg + ['fetch', self.remote, '--prune'] |
305 self._Run(fetch_cmd + quiet, options, retry=True) | 305 self._Run(fetch_cmd + quiet, options, retry=True) |
306 self._Run(['reset', '--hard', revision] + quiet, options) | 306 self._Run(['reset', '--hard', revision] + quiet, options) |
307 if file_list is not None: | 307 if file_list is not None: |
308 files = self._Capture(['ls-files']).splitlines() | 308 files = self._Capture(['ls-files']).splitlines() |
309 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 309 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
310 | 310 |
311 def _DisableHooks(self): | |
312 hook_dir = os.path.join(self.checkout_path, '.git', 'hooks') | |
313 if not os.path.isdir(hook_dir): | |
314 return | |
315 for f in os.listdir(hook_dir): | |
316 if not f.endswith('.sample'): | |
317 os.remove(os.path.join(hook_dir, f)) | |
318 | |
311 def update(self, options, args, file_list): | 319 def update(self, options, args, file_list): |
312 """Runs git to update or transparently checkout the working copy. | 320 """Runs git to update or transparently checkout the working copy. |
313 | 321 |
314 All updated files will be appended to file_list. | 322 All updated files will be appended to file_list. |
315 | 323 |
316 Raises: | 324 Raises: |
317 Error: if can't get URL for relative path. | 325 Error: if can't get URL for relative path. |
318 """ | 326 """ |
319 if args: | 327 if args: |
320 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 328 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
321 | 329 |
322 self._CheckMinVersion("1.6.6") | 330 self._CheckMinVersion("1.6.6") |
323 | 331 |
332 self._DisableHooks() | |
333 | |
324 # If a dependency is not pinned, track the default remote branch. | 334 # If a dependency is not pinned, track the default remote branch. |
325 default_rev = 'refs/remotes/%s/master' % self.remote | 335 default_rev = 'refs/remotes/%s/master' % self.remote |
326 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) | 336 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) |
327 rev_str = "" | 337 rev_str = "" |
328 revision = deps_revision | 338 revision = deps_revision |
329 managed = True | 339 managed = True |
330 if options.revision: | 340 if options.revision: |
331 # Override the revision number. | 341 # Override the revision number. |
332 revision = str(options.revision) | 342 revision = str(options.revision) |
333 if revision == 'unmanaged': | 343 if revision == 'unmanaged': |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 mirror = self._GetMirror(url, options) | 379 mirror = self._GetMirror(url, options) |
370 if mirror: | 380 if mirror: |
371 url = mirror.mirror_path | 381 url = mirror.mirror_path |
372 | 382 |
373 if (not os.path.exists(self.checkout_path) or | 383 if (not os.path.exists(self.checkout_path) or |
374 (os.path.isdir(self.checkout_path) and | 384 (os.path.isdir(self.checkout_path) and |
375 not os.path.exists(os.path.join(self.checkout_path, '.git')))): | 385 not os.path.exists(os.path.join(self.checkout_path, '.git')))): |
376 if mirror: | 386 if mirror: |
377 self._UpdateMirror(mirror, options) | 387 self._UpdateMirror(mirror, options) |
378 try: | 388 try: |
379 self._Clone(revision, url, options) | 389 self._Clone(revision, url, options) |
Ryan Tseng
2014/06/19 23:22:17
This will still drop hooks on the first run.
| |
380 except subprocess2.CalledProcessError: | 390 except subprocess2.CalledProcessError: |
381 self._DeleteOrMove(options.force) | 391 self._DeleteOrMove(options.force) |
382 self._Clone(revision, url, options) | 392 self._Clone(revision, url, options) |
383 if deps_revision and deps_revision.startswith('branch-heads/'): | 393 if deps_revision and deps_revision.startswith('branch-heads/'): |
384 deps_branch = deps_revision.replace('branch-heads/', '') | 394 deps_branch = deps_revision.replace('branch-heads/', '') |
385 self._Capture(['branch', deps_branch, deps_revision]) | 395 self._Capture(['branch', deps_branch, deps_revision]) |
386 self._Capture(['checkout', '--quiet', deps_branch]) | 396 self._Capture(['checkout', '--quiet', deps_branch]) |
387 if file_list is not None: | 397 if file_list is not None: |
388 files = self._Capture(['ls-files']).splitlines() | 398 files = self._Capture(['ls-files']).splitlines() |
389 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 399 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1489 new_command.append('--force') | 1499 new_command.append('--force') |
1490 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1500 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1491 new_command.extend(('--accept', 'theirs-conflict')) | 1501 new_command.extend(('--accept', 'theirs-conflict')) |
1492 elif options.manually_grab_svn_rev: | 1502 elif options.manually_grab_svn_rev: |
1493 new_command.append('--force') | 1503 new_command.append('--force') |
1494 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1504 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1495 new_command.extend(('--accept', 'postpone')) | 1505 new_command.extend(('--accept', 'postpone')) |
1496 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1506 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1497 new_command.extend(('--accept', 'postpone')) | 1507 new_command.extend(('--accept', 'postpone')) |
1498 return new_command | 1508 return new_command |
OLD | NEW |