| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A wrapper script to manage a set of client modules in different SCM. | 6 """A wrapper script to manage a set of client modules in different SCM. |
| 7 | 7 |
| 8 This script is intended to be used to help basic management of client | 8 This script is intended to be used to help basic management of client |
| 9 program sources residing in one or more Subversion modules and Git | 9 program sources residing in one or more Subversion modules and Git |
| 10 repositories, along with other modules it depends on, also in Subversion or Git, | 10 repositories, along with other modules it depends on, also in Subversion or Git, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 """Runs hooks for files that have been modified in the local working copy, | 241 """Runs hooks for files that have been modified in the local working copy, |
| 242 according to 'svn status'. Implies --force. | 242 according to 'svn status'. Implies --force. |
| 243 | 243 |
| 244 usage: runhooks [options] | 244 usage: runhooks [options] |
| 245 | 245 |
| 246 Valid options: | 246 Valid options: |
| 247 --verbose : output additional diagnostics | 247 --verbose : output additional diagnostics |
| 248 """, | 248 """, |
| 249 "revinfo": | 249 "revinfo": |
| 250 """Outputs source path, server URL and revision information for every | 250 """Outputs source path, server URL and revision information for every |
| 251 dependency in all solutions (no local checkout required). | 251 dependency in all solutions. |
| 252 | 252 |
| 253 usage: revinfo [options] | 253 usage: revinfo [options] |
| 254 """, | 254 """, |
| 255 } | 255 } |
| 256 | 256 |
| 257 DEFAULT_CLIENT_FILE_TEXT = ("""\ | 257 DEFAULT_CLIENT_FILE_TEXT = ("""\ |
| 258 # An element of this array (a "solution") describes a repository directory | 258 # An element of this array (a "solution") describes a repository directory |
| 259 # that will be checked out into your working copy. Each solution may | 259 # that will be checked out into your working copy. Each solution may |
| 260 # optionally define additional dependencies (via its DEPS file) to be | 260 # optionally define additional dependencies (via its DEPS file) to be |
| 261 # checked out alongside the solution's directory. A solution may also | 261 # checked out alongside the solution's directory. A solution may also |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 entry_fixed) | 791 entry_fixed) |
| 792 else: | 792 else: |
| 793 # Delete the entry | 793 # Delete the entry |
| 794 print("\n________ deleting \'%s\' " + | 794 print("\n________ deleting \'%s\' " + |
| 795 "in \'%s\'") % (entry_fixed, self._root_dir) | 795 "in \'%s\'") % (entry_fixed, self._root_dir) |
| 796 gclient_utils.RemoveDirectory(e_dir) | 796 gclient_utils.RemoveDirectory(e_dir) |
| 797 # record the current list of entries for next time | 797 # record the current list of entries for next time |
| 798 self._SaveEntries(entries) | 798 self._SaveEntries(entries) |
| 799 | 799 |
| 800 def PrintRevInfo(self): | 800 def PrintRevInfo(self): |
| 801 """Output revision info mapping for the client and its dependencies. This | 801 """Output revision info mapping for the client and its dependencies. |
| 802 allows the capture of an overall "revision" for the source tree that can | 802 |
| 803 be used to reproduce the same tree in the future. The actual output | 803 This allows the capture of an overall "revision" for the source tree that |
| 804 can be used to reproduce the same tree in the future. The actual output |
| 804 contains enough information (source paths, svn server urls and revisions) | 805 contains enough information (source paths, svn server urls and revisions) |
| 805 that it can be used either to generate external svn commands (without | 806 that it can be used either to generate external svn/git commands (without |
| 806 gclient) or as input to gclient's --rev option (with some massaging of | 807 gclient) or as input to gclient's --rev option (with some massaging of |
| 807 the data). | 808 the data). |
| 808 | 809 |
| 810 Since we care about the revision of the current source tree, for git |
| 811 repositories this command uses the revision of the HEAD. For subversion we |
| 812 use BASE. |
| 813 |
| 814 The --snapshot option allows creating a .gclient file to reproduce the tree. |
| 815 |
| 809 Raises: | 816 Raises: |
| 810 Error: If the client has conflicting entries. | 817 Error: If the client has conflicting entries. |
| 811 """ | 818 """ |
| 812 # Check for revision overrides. | 819 # Check for revision overrides. |
| 813 revision_overrides = {} | 820 revision_overrides = {} |
| 814 for revision in self._options.revisions: | 821 for revision in self._options.revisions: |
| 815 if revision.find("@") < 0: | 822 if revision.find("@") < 0: |
| 816 raise gclient_utils.Error( | 823 raise gclient_utils.Error( |
| 817 "Specify the full dependency when specifying a revision number.") | 824 "Specify the full dependency when specifying a revision number.") |
| 818 revision_elem = revision.split("@") | 825 revision_elem = revision.split("@") |
| 819 # Disallow conflicting revs | 826 # Disallow conflicting revs |
| 820 if revision_overrides.has_key(revision_elem[0]) and \ | 827 if revision_overrides.has_key(revision_elem[0]) and \ |
| 821 revision_overrides[revision_elem[0]] != revision_elem[1]: | 828 revision_overrides[revision_elem[0]] != revision_elem[1]: |
| 822 raise gclient_utils.Error( | 829 raise gclient_utils.Error( |
| 823 "Conflicting revision numbers specified.") | 830 "Conflicting revision numbers specified.") |
| 824 revision_overrides[revision_elem[0]] = revision_elem[1] | 831 revision_overrides[revision_elem[0]] = revision_elem[1] |
| 825 | 832 |
| 826 solutions = self.GetVar("solutions") | 833 solutions = self.GetVar("solutions") |
| 827 if not solutions: | 834 if not solutions: |
| 828 raise gclient_utils.Error("No solution specified") | 835 raise gclient_utils.Error("No solution specified") |
| 829 | 836 |
| 830 # Inner helper to generate base url and rev tuple (including honoring | 837 # Inner helper to generate base url and rev tuple |
| 831 # |revision_overrides|) | |
| 832 def GetURLAndRev(name, original_url): | 838 def GetURLAndRev(name, original_url): |
| 833 url, revision = gclient_utils.SplitUrlRevision(original_url) | 839 url, _ = gclient_utils.SplitUrlRevision(original_url) |
| 834 if not revision: | 840 scm = gclient_scm.CreateSCM(original_url, self._root_dir, name) |
| 835 if revision_overrides.has_key(name): | 841 return (url, scm.revinfo(self._options, [], None)) |
| 836 return (url, revision_overrides[name]) | |
| 837 else: | |
| 838 scm = gclient_scm.CreateSCM(solution["url"], self._root_dir, name) | |
| 839 return (url, scm.revinfo(self._options, [], None)) | |
| 840 else: | |
| 841 if revision_overrides.has_key(name): | |
| 842 return (url, revision_overrides[name]) | |
| 843 else: | |
| 844 return (url, revision) | |
| 845 | 842 |
| 846 # text of the snapshot gclient file | 843 # text of the snapshot gclient file |
| 847 new_gclient = "" | 844 new_gclient = "" |
| 848 # Dictionary of { path : SCM url } to ensure no duplicate solutions | 845 # Dictionary of { path : SCM url } to ensure no duplicate solutions |
| 849 solution_names = {} | 846 solution_names = {} |
| 850 entries = {} | 847 entries = {} |
| 851 entries_deps_content = {} | 848 entries_deps_content = {} |
| 852 # Run on the base solutions first. | 849 # Run on the base solutions first. |
| 853 for solution in solutions: | 850 for solution in solutions: |
| 854 # Dictionary of { path : SCM url } to describe the gclient checkout | 851 # Dictionary of { path : SCM url } to describe the gclient checkout |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 | 1244 |
| 1248 if "__main__" == __name__: | 1245 if "__main__" == __name__: |
| 1249 try: | 1246 try: |
| 1250 result = Main(sys.argv) | 1247 result = Main(sys.argv) |
| 1251 except gclient_utils.Error, e: | 1248 except gclient_utils.Error, e: |
| 1252 print >> sys.stderr, "Error: %s" % str(e) | 1249 print >> sys.stderr, "Error: %s" % str(e) |
| 1253 result = 1 | 1250 result = 1 |
| 1254 sys.exit(result) | 1251 sys.exit(result) |
| 1255 | 1252 |
| 1256 # vim: ts=2:sw=2:tw=80:et: | 1253 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |