OLD | NEW |
1 # Copyright 2009 Google Inc. All Rights Reserved. | 1 # Copyright 2009 Google Inc. All Rights Reserved. |
2 # | 2 # |
3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
6 # | 6 # |
7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
8 # | 8 # |
9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if args: | 126 if args: |
127 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 127 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
128 | 128 |
129 url = self.url | 129 url = self.url |
130 components = url.split("@") | 130 components = url.split("@") |
131 revision = None | 131 revision = None |
132 forced_revision = False | 132 forced_revision = False |
133 if options.revision: | 133 if options.revision: |
134 # Override the revision number. | 134 # Override the revision number. |
135 url = '%s@%s' % (components[0], str(options.revision)) | 135 url = '%s@%s' % (components[0], str(options.revision)) |
136 revision = int(options.revision) | 136 revision = options.revision |
137 forced_revision = True | 137 forced_revision = True |
138 elif len(components) == 2: | 138 elif len(components) == 2: |
139 revision = int(components[1]) | 139 revision = components[1] |
140 forced_revision = True | 140 forced_revision = True |
141 | 141 |
142 rev_str = "" | 142 rev_str = "" |
143 if revision: | 143 if revision: |
144 rev_str = ' at %d' % revision | 144 rev_str = ' at %s' % revision |
145 | 145 |
146 if not os.path.exists(checkout_path): | 146 if not os.path.exists(checkout_path): |
147 # We need to checkout. | 147 # We need to checkout. |
148 command = ['checkout', url, checkout_path] | 148 command = ['checkout', url, checkout_path] |
149 if revision: | 149 if revision: |
150 command.extend(['--revision', str(revision)]) | 150 command.extend(['--revision', str(revision)]) |
151 RunSVNAndGetFileList(command, self._root_dir, file_list) | 151 RunSVNAndGetFileList(command, self._root_dir, file_list) |
152 return | 152 return |
153 | 153 |
154 # Get the existing scm url and the revision number of the current checkout. | 154 # Get the existing scm url and the revision number of the current checkout. |
155 from_info = CaptureSVNInfo(os.path.join(checkout_path, '.'), '.') | 155 from_info = CaptureSVNInfo(os.path.join(checkout_path, '.'), '.') |
156 if not from_info: | 156 if not from_info: |
157 raise gclient_utils.Error("Can't update/checkout %r if an unversioned " | 157 raise gclient_utils.Error("Can't update/checkout %r if an unversioned " |
158 "directory is present. Delete the directory " | 158 "directory is present. Delete the directory " |
159 "and try again." % | 159 "and try again." % |
160 checkout_path) | 160 checkout_path) |
161 | 161 |
162 if options.manually_grab_svn_rev: | 162 if options.manually_grab_svn_rev: |
163 # Retrieve the current HEAD version because svn is slow at null updates. | 163 # Retrieve the current HEAD version because svn is slow at null updates. |
164 if not revision: | 164 if not revision: |
165 from_info_live = CaptureSVNInfo(from_info['URL'], '.') | 165 from_info_live = CaptureSVNInfo(from_info['URL'], '.') |
166 revision = int(from_info_live['Revision']) | 166 revision = from_info_live['Revision'] |
167 rev_str = ' at %d' % revision | 167 rev_str = ' at %s' % revision |
168 | 168 |
169 if from_info['URL'] != components[0]: | 169 if from_info['URL'] != components[0]: |
170 to_info = CaptureSVNInfo(url, '.') | 170 to_info = CaptureSVNInfo(url, '.') |
171 can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) | 171 can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) |
172 and (from_info['UUID'] == to_info['UUID'])) | 172 and (from_info['UUID'] == to_info['UUID'])) |
173 if can_switch: | 173 if can_switch: |
174 print("\n_____ relocating %s to a new checkout" % self.relpath) | 174 print("\n_____ relocating %s to a new checkout" % self.relpath) |
175 # We have different roots, so check if we can switch --relocate. | 175 # We have different roots, so check if we can switch --relocate. |
176 # Subversion only permits this if the repository UUIDs match. | 176 # Subversion only permits this if the repository UUIDs match. |
177 # Perform the switch --relocate, then rewrite the from_url | 177 # Perform the switch --relocate, then rewrite the from_url |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 506 |
507 | 507 |
508 def CaptureSVNHeadRevision(url): | 508 def CaptureSVNHeadRevision(url): |
509 """Get the head revision of a SVN repository. | 509 """Get the head revision of a SVN repository. |
510 | 510 |
511 Returns: | 511 Returns: |
512 Int head revision | 512 Int head revision |
513 """ | 513 """ |
514 info = CaptureSVN(["info", "--xml", url], os.getcwd()) | 514 info = CaptureSVN(["info", "--xml", url], os.getcwd()) |
515 dom = xml.dom.minidom.parseString(info) | 515 dom = xml.dom.minidom.parseString(info) |
516 return int(dom.getElementsByTagName('entry')[0].getAttribute('revision')) | 516 return dom.getElementsByTagName('entry')[0].getAttribute('revision') |
517 | 517 |
518 | 518 |
519 def CaptureSVNStatus(files): | 519 def CaptureSVNStatus(files): |
520 """Returns the svn 1.5 svn status emulated output. | 520 """Returns the svn 1.5 svn status emulated output. |
521 | 521 |
522 @files can be a string (one file) or a list of files. | 522 @files can be a string (one file) or a list of files. |
523 | 523 |
524 Returns an array of (status, file) tuples.""" | 524 Returns an array of (status, file) tuples.""" |
525 command = ["status", "--xml"] | 525 command = ["status", "--xml"] |
526 if not files: | 526 if not files: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 # Col 3 | 585 # Col 3 |
586 if wc_status[0].getAttribute('copied') == 'true': | 586 if wc_status[0].getAttribute('copied') == 'true': |
587 statuses[3] = '+' | 587 statuses[3] = '+' |
588 # Col 4 | 588 # Col 4 |
589 if wc_status[0].getAttribute('switched') == 'true': | 589 if wc_status[0].getAttribute('switched') == 'true': |
590 statuses[4] = 'S' | 590 statuses[4] = 'S' |
591 # TODO(maruel): Col 5 and 6 | 591 # TODO(maruel): Col 5 and 6 |
592 item = (''.join(statuses), file) | 592 item = (''.join(statuses), file) |
593 results.append(item) | 593 results.append(item) |
594 return results | 594 return results |
OLD | NEW |