From 924158a7176f24d2ce149c36edf22a235ab63806 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Wed, 9 Mar 2011 01:10:45 +0000 Subject: [PATCH] Add code to correctly revert a svn add'ed file. Improve test to make sure svn status comes out clean. TEST=improved unit tests and scm.SVN.Revert() should now do the right thing BUG=none Review URL: http://codereview.chromium.org/6650011 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@77391 0039d316-1c4b-4281-b951-d872f2087c98 --- scm.py | 2 +- tests/scm_unittest.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scm.py b/scm.py index 471b9d747..aaab02c08 100644 --- a/scm.py +++ b/scm.py @@ -878,7 +878,7 @@ class SVN(object): # svn revert is really stupid. It fails on inconsistent line-endings, # on switched directories, etc. So take no chance and delete everything! - if file_status[0][0] in ('D', 'A') or file_status[0][2] != ' ': + if file_status[0][0] in ('D', 'A', '!') or file_status[0][2] != ' ': # Added, deleted file requires manual intervention and require calling # revert, like for properties. try: diff --git a/tests/scm_unittest.py b/tests/scm_unittest.py index 6fd1ecc89..31d0a7c46 100755 --- a/tests/scm_unittest.py +++ b/tests/scm_unittest.py @@ -282,11 +282,18 @@ class RealSvnTest(fake_repos.FakeReposTestBase): with open(scm.os.path.join(self.svn_root, 'faala'), 'w') as f: f.write('oh') self._capture(['add', scm.os.path.join(self.svn_root, 'faala')]) + added_and_removed = scm.os.path.join(self.svn_root, 'added_and_removed') + with open(added_and_removed, 'w') as f: + f.write('oh') + self._capture(['add', added_and_removed]) + scm.os.remove(added_and_removed) scm.SVN.Revert(self.svn_root) self._capture(['update', '--revision', 'base']) self.assertTree(self.tree, self.svn_root) + # Asserting the tree is not sufficient, svn status must come out clear too. + self.assertEquals('', self._capture(['status'])) if __name__ == '__main__':