From e407c9ae282c8592396e4d3c0599aa2d11c9d2d7 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Mon, 9 Aug 2010 19:11:37 +0000 Subject: [PATCH] Add code to automatically svn cleanup during svn update. BUG=36135 TEST=gclient sync on a svn lock'ed directory will work automatically Review URL: http://codereview.chromium.org/3028053 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@55438 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 6 ++++++ tests/gclient_scm_test.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/gclient_scm.py b/gclient_scm.py index a76d2d0c2..925789db6 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -752,6 +752,12 @@ class SVNWrapper(SCMWrapper): "and try again." % checkout_path) + # Look for locked directories. + dir_info = scm.SVN.CaptureStatus(os.path.join(checkout_path, '.')) + if [True for d in dir_info if d[0][2] == 'L' and d[1] == checkout_path]: + # The current directory is locked, clean it up. + scm.SVN.Run(['cleanup'], checkout_path) + if options.manually_grab_svn_rev: # Retrieve the current HEAD version because svn is slow at null updates. if not revision: diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 4f971b282..92ea2be91 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -255,6 +255,11 @@ class SVNWrapperTestCase(BaseTestCase): } gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git') ).AndReturn(False) + + # Verify no locked files. + gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') + ).AndReturn([]) + # Checkout or update. gclient_scm.os.path.exists(base_path).AndReturn(True) gclient_scm.scm.SVN.CaptureInfo( @@ -295,6 +300,10 @@ class SVNWrapperTestCase(BaseTestCase): gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, 'DEPS') ).AndReturn(False) + # Verify no locked files. + gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') + ).AndReturn([]) + # When checking out a single file, we issue an svn checkout and svn update. files_list = self.mox.CreateMockAnything() gclient_scm.scm.SVN.Run( @@ -363,6 +372,10 @@ class SVNWrapperTestCase(BaseTestCase): ).AndReturn(True) gclient_scm.os.remove(gclient_scm.os.path.join(base_path, 'DEPS')) + # Verify no locked files. + gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') + ).AndReturn([]) + # When checking out a single file, we issue an svn checkout and svn update. files_list = self.mox.CreateMockAnything() gclient_scm.scm.SVN.Run( @@ -399,6 +412,10 @@ class SVNWrapperTestCase(BaseTestCase): gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.svn') ).AndReturn(True) + # Verify no locked files. + gclient_scm.scm.SVN.CaptureStatus(gclient_scm.os.path.join(base_path, '.') + ).AndReturn([]) + # Now we fall back on scm.update(). files_list = self.mox.CreateMockAnything() gclient_scm.os.path.exists(gclient_scm.os.path.join(base_path, '.git')