From 6b1d00b0d0ea4bbd18fa361bffd78ec480b6d413 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Wed, 26 May 2010 20:11:08 +0000 Subject: [PATCH] Add --deps support for revert, status and runhooks. Fix gclient status. This may not make sense in practice but is necessary for testing. Add regression test. TBR=msb TEST=smoke test BUG=23328 Review URL: http://codereview.chromium.org/2238004 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@48317 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 11 ++++++-- tests/gclient_smoketest.py | 51 +++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/gclient.py b/gclient.py index 68d4c2399..2d57204e0 100644 --- a/gclient.py +++ b/gclient.py @@ -901,6 +901,9 @@ checked out tree via 'patch -p0 < patchfile'. def CMDstatus(parser, args): """Show modification status for every dependencies.""" + parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", + help="sync deps for the specified (comma-separated) " + "platform(s); 'all' will sync all platforms") (options, args) = parser.parse_args(args) client = GClient.LoadCurrentConfig(options) if not client: @@ -999,12 +1002,14 @@ def CMDdiff(parser, args): def CMDrevert(parser, args): """Revert all modifications in every dependencies.""" + parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", + help="sync deps for the specified (comma-separated) " + "platform(s); 'all' will sync all platforms") parser.add_option("--nohooks", action="store_true", help="don't run hooks after the revert is complete") (options, args) = parser.parse_args(args) # --force is implied. options.force = True - options.deps_os = None client = GClient.LoadCurrentConfig(options) if not client: raise gclient_utils.Error("client not configured; see 'gclient config'") @@ -1013,6 +1018,9 @@ def CMDrevert(parser, args): def CMDrunhooks(parser, args): """Runs hooks for files that have been modified in the local working copy.""" + parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", + help="sync deps for the specified (comma-separated) " + "platform(s); 'all' will sync all platforms") parser.add_option("--force", action="store_true", default=True, help="Deprecated. No effect.") (options, args) = parser.parse_args(args) @@ -1025,7 +1033,6 @@ def CMDrunhooks(parser, args): print(client.ConfigContent()) options.force = True options.nohooks = False - options.deps_os = None return client.RunOnDeps('runhooks', args) diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index b0b74a5ea..2895a5ff6 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -274,7 +274,7 @@ class GClientSmokeSVN(GClientSmokeBase): self.gclient(['config', self.svn_base + 'trunk/src/']) # Tested in testSync. self.gclient(['sync', '--deps', 'mac']) - write(join(self.root_dir, 'src', 'third_party', 'foo', 'hi'), 'Hey!') + write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') results = self.gclient(['status']) out = results[0].splitlines(False) @@ -319,6 +319,55 @@ class GClientSmokeSVN(GClientSmokeBase): self.checkString('', results[1]) self.assertEquals(0, results[2]) + def testRevertAndStatusDepsOs(self): + self.gclient(['config', self.svn_base + 'trunk/src/']) + # Tested in testSync. + self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) + write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') + + results = self.gclient(['status', '--deps', 'mac']) + out = results[0].splitlines(False) + self.assertEquals(out[0], '') + self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) + self.assertEquals(out[2], '? other') + self.assertEquals(out[3], '? third_party/fpp') + self.assertEquals(out[4], '? third_party/prout') + self.assertEquals(out[5], '') + self.assertTrue(out[6].startswith('________ running \'svn status\' in \'')) + self.assertEquals(out[7], '? hi') + self.assertEquals(8, len(out)) + self.assertEquals('', results[1]) + self.assertEquals(0, results[2]) + + # Revert implies --force implies running hooks without looking at pattern + # matching. + results = self.gclient(['revert', '--deps', 'mac']) + out = results[0].splitlines(False) + self.assertEquals(24, len(out)) + self.checkString('', results[1]) + self.assertEquals(0, results[2]) + tree = mangle_svn_tree( + (join('trunk', 'src'), 'src', FAKE.svn_revs[1]), + (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), + FAKE.svn_revs[2]), + (join('trunk', 'other'), join('src', 'other'), FAKE.svn_revs[2]), + (join('trunk', 'third_party', 'prout'), + join('src', 'third_party', 'prout'), + FAKE.svn_revs[2]), + ) + self.assertTree(tree) + + results = self.gclient(['status', '--deps', 'mac']) + out = results[0].splitlines(False) + self.assertEquals(out[0], '') + self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) + self.assertEquals(out[2], '? other') + self.assertEquals(out[3], '? third_party/fpp') + self.assertEquals(out[4], '? third_party/prout') + self.assertEquals(5, len(out)) + self.checkString('', results[1]) + self.assertEquals(0, results[2]) + def testRunHooks(self): self.gclient(['config', self.svn_base + 'trunk/src/']) self.gclient(['sync', '--deps', 'mac'])