OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """SCM-specific utility classes.""" | 5 """SCM-specific utility classes.""" |
6 | 6 |
7 import cStringIO | 7 import cStringIO |
8 import glob | 8 import glob |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 @staticmethod | 614 @staticmethod |
615 def CaptureRevision(cwd): | 615 def CaptureRevision(cwd): |
616 """Get the base revision of a SVN repository. | 616 """Get the base revision of a SVN repository. |
617 | 617 |
618 Returns: | 618 Returns: |
619 Int base revision | 619 Int base revision |
620 """ | 620 """ |
621 return SVN.CaptureLocalInfo([], cwd).get('Revision') | 621 return SVN.CaptureLocalInfo([], cwd).get('Revision') |
622 | 622 |
623 @staticmethod | 623 @staticmethod |
624 def CaptureStatus(files, cwd): | 624 def CaptureStatus(files, cwd, no_ignore=False): |
625 """Returns the svn 1.5 svn status emulated output. | 625 """Returns the svn 1.5 svn status emulated output. |
626 | 626 |
627 @files can be a string (one file) or a list of files. | 627 @files can be a string (one file) or a list of files. |
628 | 628 |
629 Returns an array of (status, file) tuples.""" | 629 Returns an array of (status, file) tuples.""" |
630 command = ["status", "--xml"] | 630 command = ["status", "--xml"] |
| 631 if no_ignore: |
| 632 command.append('--no-ignore') |
631 if not files: | 633 if not files: |
632 pass | 634 pass |
633 elif isinstance(files, basestring): | 635 elif isinstance(files, basestring): |
634 command.append(files) | 636 command.append(files) |
635 else: | 637 else: |
636 command.extend(files) | 638 command.extend(files) |
637 | 639 |
638 status_letter = { | 640 status_letter = { |
639 None: ' ', | 641 None: ' ', |
640 '': ' ', | 642 '': ' ', |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 current_version_list = map(only_int, cls.current_version.split('.')) | 1002 current_version_list = map(only_int, cls.current_version.split('.')) |
1001 for min_ver in map(int, min_version.split('.')): | 1003 for min_ver in map(int, min_version.split('.')): |
1002 ver = current_version_list.pop(0) | 1004 ver = current_version_list.pop(0) |
1003 if ver < min_ver: | 1005 if ver < min_ver: |
1004 return (False, cls.current_version) | 1006 return (False, cls.current_version) |
1005 elif ver > min_ver: | 1007 elif ver > min_ver: |
1006 return (True, cls.current_version) | 1008 return (True, cls.current_version) |
1007 return (True, cls.current_version) | 1009 return (True, cls.current_version) |
1008 | 1010 |
1009 @staticmethod | 1011 @staticmethod |
1010 def Revert(cwd, callback=None, ignore_externals=False): | 1012 def Revert(cwd, callback=None, ignore_externals=False, no_ignore=False): |
1011 """Reverts all svn modifications in cwd, including properties. | 1013 """Reverts all svn modifications in cwd, including properties. |
1012 | 1014 |
1013 Deletes any modified files or directory. | 1015 Deletes any modified files or directory. |
1014 | 1016 |
1015 A "svn update --revision BASE" call is required after to revive deleted | 1017 A "svn update --revision BASE" call is required after to revive deleted |
1016 files. | 1018 files. |
1017 """ | 1019 """ |
1018 for file_status in SVN.CaptureStatus(None, cwd): | 1020 for file_status in SVN.CaptureStatus(None, cwd, no_ignore=no_ignore): |
1019 file_path = os.path.join(cwd, file_status[1]) | 1021 file_path = os.path.join(cwd, file_status[1]) |
1020 if (ignore_externals and | 1022 if (ignore_externals and |
1021 file_status[0][0] == 'X' and | 1023 file_status[0][0] == 'X' and |
1022 file_status[0][1:].isspace()): | 1024 file_status[0][1:].isspace()): |
1023 # Ignore externals. | 1025 # Ignore externals. |
1024 logging.info('Ignoring external %s' % file_status[1]) | 1026 logging.info('Ignoring external %s' % file_status[1]) |
1025 continue | 1027 continue |
1026 | 1028 |
1027 # This is the case where '! L .' is returned by 'svn status'. Just | 1029 # This is the case where '! L .' is returned by 'svn status'. Just |
1028 # strip off the '/.'. | 1030 # strip off the '/.'. |
(...skipping 26 matching lines...) Expand all Loading... |
1055 # revert, like for properties. | 1057 # revert, like for properties. |
1056 if not os.path.isdir(cwd): | 1058 if not os.path.isdir(cwd): |
1057 # '.' was deleted. It's not worth continuing. | 1059 # '.' was deleted. It's not worth continuing. |
1058 return | 1060 return |
1059 try: | 1061 try: |
1060 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1062 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
1061 except subprocess2.CalledProcessError: | 1063 except subprocess2.CalledProcessError: |
1062 if not os.path.exists(file_path): | 1064 if not os.path.exists(file_path): |
1063 continue | 1065 continue |
1064 raise | 1066 raise |
OLD | NEW |