Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: gclient_scm.py

Issue 6873110: Add --transitive flag. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: local switch to other directory Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient.py ('k') | gclient_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 GetRevisionDate(self, revision):
130 """Returns the given revision's date in ISO-8601 format (which contains the
131 time zone)."""
132 # TODO(floitsch): get the time-stamp of the given revision and not just the
133 # time-stamp of the currently checked out revision.
134 return self._Capture(['log', '-n', '1', '--format=%ai'])
135
129 @staticmethod 136 @staticmethod
130 def cleanup(options, args, file_list): 137 def cleanup(options, args, file_list):
131 """'Cleanup' the repo. 138 """'Cleanup' the repo.
132 139
133 There's no real git equivalent for the svn cleanup command, do a no-op. 140 There's no real git equivalent for the svn cleanup command, do a no-op.
134 """ 141 """
135 142
136 def diff(self, options, args, file_list): 143 def diff(self, options, args, file_list):
137 merge_base = self._Capture(['merge-base', 'HEAD', 'origin']) 144 merge_base = self._Capture(['merge-base', 'HEAD', 'origin'])
138 self._Run(['diff', merge_base], options) 145 self._Run(['diff', merge_base], options)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 default_rev = "refs/heads/master" 186 default_rev = "refs/heads/master"
180 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) 187 url, deps_revision = gclient_utils.SplitUrlRevision(self.url)
181 rev_str = "" 188 rev_str = ""
182 revision = deps_revision 189 revision = deps_revision
183 if options.revision: 190 if options.revision:
184 # Override the revision number. 191 # Override the revision number.
185 revision = str(options.revision) 192 revision = str(options.revision)
186 if not revision: 193 if not revision:
187 revision = default_rev 194 revision = default_rev
188 195
196 if gclient_utils.IsDateRevision(revision):
197 # Date-revisions only work on git-repositories if the reflog hasn't
198 # expired yet. Use rev-list to get the corresponding revision.
199 # git rev-list -n 1 --before='time-stamp' branchname
200 if options.transitive:
201 print('Warning: --transitive only works for SVN repositories.')
202 revision = default_rev
203
189 rev_str = ' at %s' % revision 204 rev_str = ' at %s' % revision
190 files = [] 205 files = []
191 206
192 printed_path = False 207 printed_path = False
193 verbose = [] 208 verbose = []
194 if options.verbose: 209 if options.verbose:
195 print('\n_____ %s%s' % (self.relpath, rev_str)) 210 print('\n_____ %s%s' % (self.relpath, rev_str))
196 verbose = ['--verbose'] 211 verbose = ['--verbose']
197 printed_path = True 212 printed_path = True
198 213
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 676
662 def _Run(self, args, options, **kwargs): 677 def _Run(self, args, options, **kwargs):
663 kwargs.setdefault('cwd', self.checkout_path) 678 kwargs.setdefault('cwd', self.checkout_path)
664 gclient_utils.CheckCallAndFilterAndHeader(['git'] + args, 679 gclient_utils.CheckCallAndFilterAndHeader(['git'] + args,
665 always=options.verbose, **kwargs) 680 always=options.verbose, **kwargs)
666 681
667 682
668 class SVNWrapper(SCMWrapper): 683 class SVNWrapper(SCMWrapper):
669 """ Wrapper for SVN """ 684 """ Wrapper for SVN """
670 685
686 def GetRevisionDate(self, revision):
687 """Returns the given revision's date in ISO-8601 format (which contains the
688 time zone)."""
689 date = scm.SVN.Capture(['propget', '--revprop', 'svn:date', '-r', revision,
690 os.path.join(self.checkout_path, '.')])
691 return date.strip()
692
671 def cleanup(self, options, args, file_list): 693 def cleanup(self, options, args, file_list):
672 """Cleanup working copy.""" 694 """Cleanup working copy."""
673 self._Run(['cleanup'] + args, options) 695 self._Run(['cleanup'] + args, options)
674 696
675 def diff(self, options, args, file_list): 697 def diff(self, options, args, file_list):
676 # NOTE: This function does not currently modify file_list. 698 # NOTE: This function does not currently modify file_list.
677 if not os.path.isdir(self.checkout_path): 699 if not os.path.isdir(self.checkout_path):
678 raise gclient_utils.Error('Directory %s is not present.' % 700 raise gclient_utils.Error('Directory %s is not present.' %
679 self.checkout_path) 701 self.checkout_path)
680 self._Run(['diff'] + args, options) 702 self._Run(['diff'] + args, options)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 956
935 This method returns a new list to be used as a command.""" 957 This method returns a new list to be used as a command."""
936 new_command = command[:] 958 new_command = command[:]
937 if revision: 959 if revision:
938 new_command.extend(['--revision', str(revision).strip()]) 960 new_command.extend(['--revision', str(revision).strip()])
939 # --force was added to 'svn update' in svn 1.5. 961 # --force was added to 'svn update' in svn 1.5.
940 if ((options.force or options.manually_grab_svn_rev) and 962 if ((options.force or options.manually_grab_svn_rev) and
941 scm.SVN.AssertVersion("1.5")[0]): 963 scm.SVN.AssertVersion("1.5")[0]):
942 new_command.append('--force') 964 new_command.append('--force')
943 return new_command 965 return new_command
OLDNEW
« no previous file with comments | « gclient.py ('k') | gclient_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698