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 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 continue | 423 continue |
424 raise | 424 raise |
425 | 425 |
426 if verbose: | 426 if verbose: |
427 print(remote_output.strip()) | 427 print(remote_output.strip()) |
428 | 428 |
429 self._UpdateBranchHeads(options, fetch=True) | 429 self._UpdateBranchHeads(options, fetch=True) |
430 | 430 |
431 # This is a big hammer, debatable if it should even be here... | 431 # This is a big hammer, debatable if it should even be here... |
432 if options.force or options.reset: | 432 if options.force or options.reset: |
433 self._Run(['reset', '--hard', 'HEAD'], options) | 433 target = 'HEAD' |
| 434 if options.upstream and upstream_branch: |
| 435 target = upstream_branch |
| 436 self._Run(['reset', '--hard', target], options) |
434 | 437 |
435 if current_type == 'detached': | 438 if current_type == 'detached': |
436 # case 0 | 439 # case 0 |
437 self._CheckClean(rev_str) | 440 self._CheckClean(rev_str) |
438 self._CheckDetachedHead(rev_str, options) | 441 self._CheckDetachedHead(rev_str, options) |
439 self._Capture(['checkout', '--quiet', '%s' % revision]) | 442 self._Capture(['checkout', '--quiet', '%s' % revision]) |
440 if not printed_path: | 443 if not printed_path: |
441 print('\n_____ %s%s' % (self.relpath, rev_str)) | 444 print('\n_____ %s%s' % (self.relpath, rev_str)) |
442 elif current_type == 'hash': | 445 elif current_type == 'hash': |
443 # case 1 | 446 # case 1 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 All reverted files will be appended to file_list. | 574 All reverted files will be appended to file_list. |
572 """ | 575 """ |
573 if not os.path.isdir(self.checkout_path): | 576 if not os.path.isdir(self.checkout_path): |
574 # revert won't work if the directory doesn't exist. It needs to | 577 # revert won't work if the directory doesn't exist. It needs to |
575 # checkout instead. | 578 # checkout instead. |
576 print('\n_____ %s is missing, synching instead' % self.relpath) | 579 print('\n_____ %s is missing, synching instead' % self.relpath) |
577 # Don't reuse the args. | 580 # Don't reuse the args. |
578 return self.update(options, [], file_list) | 581 return self.update(options, [], file_list) |
579 | 582 |
580 default_rev = "refs/heads/master" | 583 default_rev = "refs/heads/master" |
| 584 if options.upstream: |
| 585 if self._GetCurrentBranch(): |
| 586 upstream_branch = scm.GIT.GetUpstreamBranch(self.checkout_path) |
| 587 default_rev = upstream_branch or default_rev |
581 _, deps_revision = gclient_utils.SplitUrlRevision(self.url) | 588 _, deps_revision = gclient_utils.SplitUrlRevision(self.url) |
582 if not deps_revision: | 589 if not deps_revision: |
583 deps_revision = default_rev | 590 deps_revision = default_rev |
584 if deps_revision.startswith('refs/heads/'): | 591 if deps_revision.startswith('refs/heads/'): |
585 deps_revision = deps_revision.replace('refs/heads/', 'origin/') | 592 deps_revision = deps_revision.replace('refs/heads/', 'origin/') |
586 | 593 |
587 files = self._Capture(['diff', deps_revision, '--name-only']).split() | 594 files = self._Capture(['diff', deps_revision, '--name-only']).split() |
588 self._Run(['reset', '--hard', deps_revision], options) | 595 self._Run(['reset', '--hard', deps_revision], options) |
589 self._Run(['clean', '-f', '-d'], options) | 596 self._Run(['clean', '-f', '-d'], options) |
590 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 597 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 new_command.append('--force') | 1336 new_command.append('--force') |
1330 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1337 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1331 new_command.extend(('--accept', 'theirs-conflict')) | 1338 new_command.extend(('--accept', 'theirs-conflict')) |
1332 elif options.manually_grab_svn_rev: | 1339 elif options.manually_grab_svn_rev: |
1333 new_command.append('--force') | 1340 new_command.append('--force') |
1334 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1341 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1335 new_command.extend(('--accept', 'postpone')) | 1342 new_command.extend(('--accept', 'postpone')) |
1336 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1343 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1337 new_command.extend(('--accept', 'postpone')) | 1344 new_command.extend(('--accept', 'postpone')) |
1338 return new_command | 1345 return new_command |
OLD | NEW |