OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 | 61 |
62 ### SCM abstraction layer | 62 ### SCM abstraction layer |
63 | 63 |
64 # Factory Method for SCM wrapper creation | 64 # Factory Method for SCM wrapper creation |
65 | 65 |
66 def GetScmName(url): | 66 def GetScmName(url): |
67 if url: | 67 if url: |
68 url, _ = gclient_utils.SplitUrlRevision(url) | 68 url, _ = gclient_utils.SplitUrlRevision(url) |
69 if (url.startswith('git://') or url.startswith('ssh://') or | 69 if (url.startswith('git://') or url.startswith('ssh://') or |
| 70 url.startswith('git+http://') or url.startswith('git+https://') or |
70 url.endswith('.git')): | 71 url.endswith('.git')): |
71 return 'git' | 72 return 'git' |
72 elif (url.startswith('http://') or url.startswith('https://') or | 73 elif (url.startswith('http://') or url.startswith('https://') or |
73 url.startswith('svn://') or url.startswith('svn+ssh://')): | 74 url.startswith('svn://') or url.startswith('svn+ssh://')): |
74 return 'svn' | 75 return 'svn' |
75 return None | 76 return None |
76 | 77 |
77 | 78 |
78 def CreateSCM(url, root_dir=None, relpath=None): | 79 def CreateSCM(url, root_dir=None, relpath=None): |
79 SCM_MAP = { | 80 SCM_MAP = { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if not command in dir(self): | 120 if not command in dir(self): |
120 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( | 121 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( |
121 command, self.__class__.__name__)) | 122 command, self.__class__.__name__)) |
122 | 123 |
123 return getattr(self, command)(options, args, file_list) | 124 return getattr(self, command)(options, args, file_list) |
124 | 125 |
125 | 126 |
126 class GitWrapper(SCMWrapper): | 127 class GitWrapper(SCMWrapper): |
127 """Wrapper for Git""" | 128 """Wrapper for Git""" |
128 | 129 |
| 130 def __init__(self, url=None, root_dir=None, relpath=None): |
| 131 """Removes 'git+' fake prefix from git URL.""" |
| 132 if url.startswith('git+http://') or url.startswith('git+https://'): |
| 133 url = url[4:] |
| 134 SCMWrapper.__init__(self, url, root_dir, relpath) |
| 135 |
129 def GetRevisionDate(self, revision): | 136 def GetRevisionDate(self, revision): |
130 """Returns the given revision's date in ISO-8601 format (which contains the | 137 """Returns the given revision's date in ISO-8601 format (which contains the |
131 time zone).""" | 138 time zone).""" |
132 # TODO(floitsch): get the time-stamp of the given revision and not just the | 139 # TODO(floitsch): get the time-stamp of the given revision and not just the |
133 # time-stamp of the currently checked out revision. | 140 # time-stamp of the currently checked out revision. |
134 return self._Capture(['log', '-n', '1', '--format=%ai']) | 141 return self._Capture(['log', '-n', '1', '--format=%ai']) |
135 | 142 |
136 @staticmethod | 143 @staticmethod |
137 def cleanup(options, args, file_list): | 144 def cleanup(options, args, file_list): |
138 """'Cleanup' the repo. | 145 """'Cleanup' the repo. |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 new_command.append('--force') | 1040 new_command.append('--force') |
1034 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1041 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1035 new_command.extend(('--accept', 'theirs-conflict')) | 1042 new_command.extend(('--accept', 'theirs-conflict')) |
1036 elif options.manually_grab_svn_rev: | 1043 elif options.manually_grab_svn_rev: |
1037 new_command.append('--force') | 1044 new_command.append('--force') |
1038 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1045 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1039 new_command.extend(('--accept', 'postpone')) | 1046 new_command.extend(('--accept', 'postpone')) |
1040 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1047 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1041 new_command.extend(('--accept', 'postpone')) | 1048 new_command.extend(('--accept', 'postpone')) |
1042 return new_command | 1049 return new_command |
OLD | NEW |