From b1e315f9e8984308a4df77e485e1096cf3efc3c9 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Wed, 11 Aug 2010 18:44:50 +0000 Subject: [PATCH] Add revinfo --actual to fetch the actual revisions, gclient revinfo alone will now not return the actual checked out revisions but simply what's in the .gclient&DEPS. BUG=none TEST=add a --snapshot test to make sure it is not broken Review URL: http://codereview.chromium.org/3130007 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@55760 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 21 +++++++++++----- tests/gclient_smoketest.py | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/gclient.py b/gclient.py index 87b1aeea54..41dc58b9c6 100644 --- a/gclient.py +++ b/gclient.py @@ -793,11 +793,16 @@ solutions = [ # Print the snapshot configuration file print(self.DEFAULT_SNAPSHOT_FILE_TEXT % {'solution_list': new_gclient}) else: - entries = sorted(self.tree(False), key=lambda i: i.name) - for d in entries: - entry_url = GetURLAndRev(d) - line = '%s: %s' % (d.name, entry_url) - if not d is entries[-1]: + entries = {} + for d in self.tree(False): + if self._options.actual: + entries[d.name] = GetURLAndRev(d) + else: + entries[d.name] = d.parsed_url + keys = sorted(entries.keys()) + for x in keys: + line = '%s: %s' % (x, entries[x]) + if x is not keys[-1]: line += ';' print line logging.info(str(self)) @@ -1110,9 +1115,13 @@ def CMDrevinfo(parser, args): help='override deps for the specified (comma-separated) ' 'platform(s); \'all\' will process all deps_os ' 'references') + parser.add_option('-a', '--actual', action='store_true', + help='gets the actual checked out revisions instead of the ' + 'ones specified in the DEPS and .gclient files') parser.add_option('-s', '--snapshot', action='store_true', help='creates a snapshot .gclient file of the current ' - 'version of all repositories to reproduce the tree') + 'version of all repositories to reproduce the tree, ' + 'implies -a') (options, args) = parser.parse_args(args) client = GClient.LoadCurrentConfig(options) if not client: diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index d86f67250c..b830350161 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -429,12 +429,37 @@ class GClientSmokeSVN(GClientSmokeBase): self.gclient(['config', self.svn_base + 'trunk/src/']) self.gclient(['sync', '--deps', 'mac']) results = self.gclient(['revinfo', '--deps', 'mac']) + out = ('src: %(base)s/src;\n' + 'src/file/other: File("%(base)s/other/DEPS");\n' + 'src/other: %(base)s/other;\n' + 'src/third_party/foo: %(base)s/third_party/foo@1\n' % + { 'base': self.svn_base + 'trunk' }) + self.check((out, '', 0), results) + results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) out = ('src: %(base)s/src@2;\n' 'src/file/other: %(base)s/other/DEPS@2;\n' 'src/other: %(base)s/other@2;\n' 'src/third_party/foo: %(base)s/third_party/foo@1\n' % { 'base': self.svn_base + 'trunk' }) self.check((out, '', 0), results) + results = self.gclient(['revinfo', '--deps', 'mac', '--snapshot']) + out = ('# Snapshot generated with gclient revinfo --snapshot\n' + 'solutions = [\n' + ' { "name" : "src",\n' + ' "url" : "%(base)s/src",\n' + ' "custom_deps" : {\n' + ' "foo/bar": None,\n' + ' "invalid": None,\n' + ' "src/file/other": \'%(base)s/other/DEPS@2\',\n' + ' "src/other": \'%(base)s/other@2\',\n' + ' "src/third_party/foo": ' + '\'%(base)s/third_party/foo@1\',\n' + ' },\n' + ' "safesync_url": "",\n' + ' },\n' + ']\n\n' % + { 'base': self.svn_base + 'trunk' }) + self.check((out, '', 0), results) class GClientSmokeGIT(GClientSmokeBase): @@ -608,6 +633,17 @@ class GClientSmokeGIT(GClientSmokeBase): self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) self.gclient(['sync', '--deps', 'mac']) results = self.gclient(['revinfo', '--deps', 'mac']) + out = ('src: %(base)srepo_1;\n' + 'src/repo2: %(base)srepo_2@%(hash2)s;\n' + 'src/repo2/repo_renamed: %(base)srepo_3\n' % + { + 'base': self.git_base, + 'hash1': self.githash('repo_1', 2)[:7], + 'hash2': self.githash('repo_2', 1)[:7], + 'hash3': self.githash('repo_3', 2)[:7], + }) + self.check((out, '', 0), results) + results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) out = ('src: %(base)srepo_1@%(hash1)s;\n' 'src/repo2: %(base)srepo_2@%(hash2)s;\n' 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % @@ -700,6 +736,21 @@ class GClientSmokeBoth(GClientSmokeBase): '"url": "' + self.git_base + 'repo_1"}]']) self.gclient(['sync', '--deps', 'mac']) results = self.gclient(['revinfo', '--deps', 'mac']) + out = ('src: %(svn_base)s/src/;\n' + 'src-git: %(git_base)srepo_1;\n' + 'src/file/other: File("%(svn_base)s/other/DEPS");\n' + 'src/other: %(svn_base)s/other;\n' + 'src/repo2: %(git_base)srepo_2@%(hash2)s;\n' + 'src/repo2/repo_renamed: %(git_base)srepo_3;\n' + 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { + 'svn_base': self.svn_base + 'trunk', + 'git_base': self.git_base, + 'hash1': self.githash('repo_1', 2)[:7], + 'hash2': self.githash('repo_2', 1)[:7], + 'hash3': self.githash('repo_3', 2)[:7], + } + self.check((out, '', 0), results) + results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) out = ('src: %(svn_base)s/src/@2;\n' 'src-git: %(git_base)srepo_1@%(hash1)s;\n' 'src/file/other: %(svn_base)s/other/DEPS@2;\n'