From c7c41681a111facd2e73c218ce9c28194c286afc Mon Sep 17 00:00:00 2001 From: "iannucci@chromium.org" Date: Sat, 23 Aug 2014 03:44:18 +0000 Subject: [PATCH] Fix gclient hook for stubborn hooks. R=szager@chromium.org BUG= Review URL: https://codereview.chromium.org/497333003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@291574 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gclient.py b/gclient.py index a92cce05c..fb9775945 100755 --- a/gclient.py +++ b/gclient.py @@ -1316,10 +1316,12 @@ been automagically updated. The previous version is available at %s.old. # Return a new GClient instance based on the new content. new_content = ast2str(a) dot_gclient_fn = os.path.join(path, options.config_filename) - os.rename(dot_gclient_fn, dot_gclient_fn + '.old') - fh = open(dot_gclient_fn, 'w') - fh.write(new_content) - fh.close() + try: + os.rename(dot_gclient_fn, dot_gclient_fn + '.old') + except OSError: + pass + with open(dot_gclient_fn, 'w') as fh: + fh.write(new_content) client = GClient(path, options) client.SetConfig(new_content) return client