Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 if not command in dir(self): | 119 if not command in dir(self): |
| 120 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( | 120 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( |
| 121 command, self.__class__.__name__)) | 121 command, self.__class__.__name__)) |
| 122 | 122 |
| 123 return getattr(self, command)(options, args, file_list) | 123 return getattr(self, command)(options, args, file_list) |
| 124 | 124 |
| 125 | 125 |
| 126 class GitWrapper(SCMWrapper): | 126 class GitWrapper(SCMWrapper): |
| 127 """Wrapper for Git""" | 127 """Wrapper for Git""" |
| 128 | 128 |
| 129 def GetDateRevision(self, revision): | |
| 130 """Returns the current revision's date in the form "{<date>}""""" | |
|
M-A Ruel
2011/04/20 15:43:28
Document the time zone used, local or UTC?
Also,
Florian Loitsch
2011/04/20 18:32:01
changed to GetRevisionDate.
added helper function
| |
| 131 # return "{" + self._Capture(['log', '-n', '1', '--format=%ai', | |
| 132 # revision + "^.." + revision]) + "}" | |
| 133 return "{" + self._Capture(['log', '-n', '1', '--format=%ai']) + "}" | |
| 134 | |
| 129 @staticmethod | 135 @staticmethod |
| 130 def cleanup(options, args, file_list): | 136 def cleanup(options, args, file_list): |
| 131 """'Cleanup' the repo. | 137 """'Cleanup' the repo. |
| 132 | 138 |
| 133 There's no real git equivalent for the svn cleanup command, do a no-op. | 139 There's no real git equivalent for the svn cleanup command, do a no-op. |
| 134 """ | 140 """ |
| 135 | 141 |
| 136 def diff(self, options, args, file_list): | 142 def diff(self, options, args, file_list): |
| 137 merge_base = self._Capture(['merge-base', 'HEAD', 'origin']) | 143 merge_base = self._Capture(['merge-base', 'HEAD', 'origin']) |
| 138 self._Run(['diff', merge_base], options) | 144 self._Run(['diff', merge_base], options) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 default_rev = "refs/heads/master" | 185 default_rev = "refs/heads/master" |
| 180 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) | 186 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) |
| 181 rev_str = "" | 187 rev_str = "" |
| 182 revision = deps_revision | 188 revision = deps_revision |
| 183 if options.revision: | 189 if options.revision: |
| 184 # Override the revision number. | 190 # Override the revision number. |
| 185 revision = str(options.revision) | 191 revision = str(options.revision) |
| 186 if not revision: | 192 if not revision: |
| 187 revision = default_rev | 193 revision = default_rev |
| 188 | 194 |
| 195 if gclient_utils.IsDateRevision(revision): | |
| 196 # Date-revisions only work on git-repositories if the reflog hasn't | |
| 197 # expired yet. Use rev-list to get the corresponding revision. | |
| 198 revision = self._Capture(['rev-list', '-n 1', | |
| 199 '--before="' + revision[1:-1] + '"', | |
| 200 self._GetCurrentBranch()]) | |
| 189 rev_str = ' at %s' % revision | 201 rev_str = ' at %s' % revision |
| 190 files = [] | 202 files = [] |
| 191 | 203 |
| 192 printed_path = False | 204 printed_path = False |
| 193 verbose = [] | 205 verbose = [] |
| 194 if options.verbose: | 206 if options.verbose: |
| 195 print('\n_____ %s%s' % (self.relpath, rev_str)) | 207 print('\n_____ %s%s' % (self.relpath, rev_str)) |
| 196 verbose = ['--verbose'] | 208 verbose = ['--verbose'] |
| 197 printed_path = True | 209 printed_path = True |
| 198 | 210 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 661 | 673 |
| 662 def _Run(self, args, options, **kwargs): | 674 def _Run(self, args, options, **kwargs): |
| 663 kwargs.setdefault('cwd', self.checkout_path) | 675 kwargs.setdefault('cwd', self.checkout_path) |
| 664 gclient_utils.CheckCallAndFilterAndHeader(['git'] + args, | 676 gclient_utils.CheckCallAndFilterAndHeader(['git'] + args, |
| 665 always=options.verbose, **kwargs) | 677 always=options.verbose, **kwargs) |
| 666 | 678 |
| 667 | 679 |
| 668 class SVNWrapper(SCMWrapper): | 680 class SVNWrapper(SCMWrapper): |
| 669 """ Wrapper for SVN """ | 681 """ Wrapper for SVN """ |
| 670 | 682 |
| 683 def GetDateRevision(self, revision): | |
| 684 """Returns the given revision's date in the form "{<date>}""""" | |
| 685 date = scm.SVN.Capture(['propget', '--revprop', 'svn:date', '-r', revision, | |
| 686 os.path.join(self.checkout_path, '.')]) | |
| 687 return "{" + date.strip() + "}" | |
|
M-A Ruel
2011/04/20 15:43:28
Same as 133.
Florian Loitsch
2011/04/20 18:32:01
same as 133.
| |
| 688 | |
| 671 def cleanup(self, options, args, file_list): | 689 def cleanup(self, options, args, file_list): |
| 672 """Cleanup working copy.""" | 690 """Cleanup working copy.""" |
| 673 self._Run(['cleanup'] + args, options) | 691 self._Run(['cleanup'] + args, options) |
| 674 | 692 |
| 675 def diff(self, options, args, file_list): | 693 def diff(self, options, args, file_list): |
| 676 # NOTE: This function does not currently modify file_list. | 694 # NOTE: This function does not currently modify file_list. |
| 677 if not os.path.isdir(self.checkout_path): | 695 if not os.path.isdir(self.checkout_path): |
| 678 raise gclient_utils.Error('Directory %s is not present.' % | 696 raise gclient_utils.Error('Directory %s is not present.' % |
| 679 self.checkout_path) | 697 self.checkout_path) |
| 680 self._Run(['diff'] + args, options) | 698 self._Run(['diff'] + args, options) |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 | 952 |
| 935 This method returns a new list to be used as a command.""" | 953 This method returns a new list to be used as a command.""" |
| 936 new_command = command[:] | 954 new_command = command[:] |
| 937 if revision: | 955 if revision: |
| 938 new_command.extend(['--revision', str(revision).strip()]) | 956 new_command.extend(['--revision', str(revision).strip()]) |
| 939 # --force was added to 'svn update' in svn 1.5. | 957 # --force was added to 'svn update' in svn 1.5. |
| 940 if ((options.force or options.manually_grab_svn_rev) and | 958 if ((options.force or options.manually_grab_svn_rev) and |
| 941 scm.SVN.AssertVersion("1.5")[0]): | 959 scm.SVN.AssertVersion("1.5")[0]): |
| 942 new_command.append('--force') | 960 new_command.append('--force') |
| 943 return new_command | 961 return new_command |
| OLD | NEW |