OLD | NEW |
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2009 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 All reverted files will be appended to file_list. | 396 All reverted files will be appended to file_list. |
397 """ | 397 """ |
398 __pychecker__ = 'unusednames=args' | 398 __pychecker__ = 'unusednames=args' |
399 path = os.path.join(self._root_dir, self.relpath) | 399 path = os.path.join(self._root_dir, self.relpath) |
400 if not os.path.isdir(path): | 400 if not os.path.isdir(path): |
401 # revert won't work if the directory doesn't exist. It needs to | 401 # revert won't work if the directory doesn't exist. It needs to |
402 # checkout instead. | 402 # checkout instead. |
403 print("\n_____ %s is missing, synching instead" % self.relpath) | 403 print("\n_____ %s is missing, synching instead" % self.relpath) |
404 # Don't reuse the args. | 404 # Don't reuse the args. |
405 return self.update(options, [], file_list) | 405 return self.update(options, [], file_list) |
406 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) | 406 |
407 files = self._Run(['diff', merge_base, '--name-only']).split() | 407 default_rev = "refs/heads/master" |
408 self._Run(['reset', '--hard', merge_base], redirect_stdout=False) | 408 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) |
| 409 if not deps_revision: |
| 410 deps_revision = default_rev |
| 411 if deps_revision.startswith('refs/heads/'): |
| 412 deps_revision = deps_revision.replace('refs/heads/', 'origin/') |
| 413 |
| 414 files = self._Run(['diff', deps_revision, '--name-only']).split() |
| 415 self._Run(['reset', '--hard', deps_revision], redirect_stdout=False) |
409 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 416 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
410 | 417 |
411 def revinfo(self, options, args, file_list): | 418 def revinfo(self, options, args, file_list): |
412 """Display revision""" | 419 """Display revision""" |
413 __pychecker__ = 'unusednames=options,args,file_list' | 420 __pychecker__ = 'unusednames=options,args,file_list' |
414 return self._Run(['rev-parse', 'HEAD']) | 421 return self._Run(['rev-parse', 'HEAD']) |
415 | 422 |
416 def runhooks(self, options, args, file_list): | 423 def runhooks(self, options, args, file_list): |
417 self.status(options, args, file_list) | 424 self.status(options, args, file_list) |
418 | 425 |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " | 859 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " |
853 "does not exist." | 860 "does not exist." |
854 % (' '.join(command), path)) | 861 % (' '.join(command), path)) |
855 # There's no file list to retrieve. | 862 # There's no file list to retrieve. |
856 else: | 863 else: |
857 scm.SVN.RunAndGetFileList(options, command, path, file_list) | 864 scm.SVN.RunAndGetFileList(options, command, path, file_list) |
858 | 865 |
859 def FullUrlForRelativeUrl(self, url): | 866 def FullUrlForRelativeUrl(self, url): |
860 # Find the forth '/' and strip from there. A bit hackish. | 867 # Find the forth '/' and strip from there. A bit hackish. |
861 return '/'.join(self.url.split('/')[:4]) + url | 868 return '/'.join(self.url.split('/')[:4]) + url |
OLD | NEW |