| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. | 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 relpath=self.relpath) | 1138 relpath=self.relpath) |
| 1139 scm.revert(options, self.args, files_list) | 1139 scm.revert(options, self.args, files_list) |
| 1140 self.mox.VerifyAll() | 1140 self.mox.VerifyAll() |
| 1141 gclient.os.path.isdir = os.path.isdir | 1141 gclient.os.path.isdir = os.path.isdir |
| 1142 | 1142 |
| 1143 def testRevertNone(self): | 1143 def testRevertNone(self): |
| 1144 options = self.Options(verbose=True) | 1144 options = self.Options(verbose=True) |
| 1145 base_path = os.path.join(self.root_dir, self.relpath) | 1145 base_path = os.path.join(self.root_dir, self.relpath) |
| 1146 gclient.os.path.isdir = self.mox.CreateMockAnything() | 1146 gclient.os.path.isdir = self.mox.CreateMockAnything() |
| 1147 gclient.os.path.isdir(base_path).AndReturn(True) | 1147 gclient.os.path.isdir(base_path).AndReturn(True) |
| 1148 gclient.CaptureSVNStatus(options, base_path).AndReturn([]) | 1148 gclient.CaptureSVNStatus(base_path).AndReturn([]) |
| 1149 | 1149 |
| 1150 self.mox.ReplayAll() | 1150 self.mox.ReplayAll() |
| 1151 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1151 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
| 1152 relpath=self.relpath) | 1152 relpath=self.relpath) |
| 1153 file_list = [] | 1153 file_list = [] |
| 1154 scm.revert(options, self.args, file_list) | 1154 scm.revert(options, self.args, file_list) |
| 1155 self.mox.VerifyAll() | 1155 self.mox.VerifyAll() |
| 1156 gclient.os.path.isdir = os.path.isdir | 1156 gclient.os.path.isdir = os.path.isdir |
| 1157 | 1157 |
| 1158 def testRevert2Files(self): | 1158 def testRevert2Files(self): |
| 1159 options = self.Options(verbose=True) | 1159 options = self.Options(verbose=True) |
| 1160 base_path = os.path.join(self.root_dir, self.relpath) | 1160 base_path = os.path.join(self.root_dir, self.relpath) |
| 1161 gclient.os.path.isdir = self.mox.CreateMockAnything() | 1161 gclient.os.path.isdir = self.mox.CreateMockAnything() |
| 1162 gclient.os.path.isdir(base_path).AndReturn(True) | 1162 gclient.os.path.isdir(base_path).AndReturn(True) |
| 1163 items = [ | 1163 items = [ |
| 1164 gclient.FileStatus('a', 'M', ' ', ' ', ' '), | 1164 gclient.FileStatus('a', 'M', ' ', ' ', ' '), |
| 1165 gclient.FileStatus('b', 'A', ' ', ' ', ' '), | 1165 gclient.FileStatus('b', 'A', ' ', ' ', ' '), |
| 1166 ] | 1166 ] |
| 1167 gclient.CaptureSVNStatus(options, base_path).AndReturn(items) | 1167 gclient.CaptureSVNStatus(base_path).AndReturn(items) |
| 1168 | 1168 |
| 1169 print >>options.stdout, os.path.join(base_path, 'a') | 1169 print >>options.stdout, os.path.join(base_path, 'a') |
| 1170 print >>options.stdout, os.path.join(base_path, 'b') | 1170 print >>options.stdout, os.path.join(base_path, 'b') |
| 1171 gclient.RunSVN(options, ['revert', 'a', 'b'], base_path) | 1171 gclient.RunSVN(['revert', 'a', 'b'], base_path) |
| 1172 | 1172 |
| 1173 self.mox.ReplayAll() | 1173 self.mox.ReplayAll() |
| 1174 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1174 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
| 1175 relpath=self.relpath) | 1175 relpath=self.relpath) |
| 1176 file_list = [] | 1176 file_list = [] |
| 1177 scm.revert(options, self.args, file_list) | 1177 scm.revert(options, self.args, file_list) |
| 1178 self.mox.VerifyAll() | 1178 self.mox.VerifyAll() |
| 1179 gclient.os.path.isdir = os.path.isdir | 1179 gclient.os.path.isdir = os.path.isdir |
| 1180 | 1180 |
| 1181 def testStatus(self): | 1181 def testStatus(self): |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 options.force = True | 1222 options.force = True |
| 1223 file_info = { | 1223 file_info = { |
| 1224 'Repository Root': 'blah', | 1224 'Repository Root': 'blah', |
| 1225 'URL': self.url, | 1225 'URL': self.url, |
| 1226 'UUID': 'ABC', | 1226 'UUID': 'ABC', |
| 1227 'Revision': 42, | 1227 'Revision': 42, |
| 1228 } | 1228 } |
| 1229 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False) | 1229 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False) |
| 1230 # Checkout or update. | 1230 # Checkout or update. |
| 1231 options.path_exists(base_path).AndReturn(True) | 1231 options.path_exists(base_path).AndReturn(True) |
| 1232 gclient.CaptureSVNInfo(options, os.path.join(base_path, "."), '.' | 1232 gclient.CaptureSVNInfo(os.path.join(base_path, "."), '.' |
| 1233 ).AndReturn(file_info) | 1233 ).AndReturn(file_info) |
| 1234 # Cheat a bit here. | 1234 # Cheat a bit here. |
| 1235 gclient.CaptureSVNInfo(options, file_info['URL'], '.').AndReturn(file_info) | 1235 gclient.CaptureSVNInfo(file_info['URL'], '.').AndReturn(file_info) |
| 1236 additional_args = [] | 1236 additional_args = [] |
| 1237 if options.manually_grab_svn_rev: | 1237 if options.manually_grab_svn_rev: |
| 1238 additional_args = ['--revision', str(file_info['Revision'])] | 1238 additional_args = ['--revision', str(file_info['Revision'])] |
| 1239 files_list = [] | 1239 files_list = [] |
| 1240 gclient.RunSVNAndGetFileList(options, ['update', base_path] + additional_arg
s, | 1240 gclient.RunSVNAndGetFileList(options, ['update', base_path] + additional_arg
s, |
| 1241 self.root_dir, files_list) | 1241 self.root_dir, files_list) |
| 1242 | 1242 |
| 1243 self.mox.ReplayAll() | 1243 self.mox.ReplayAll() |
| 1244 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1244 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
| 1245 relpath=self.relpath) | 1245 relpath=self.relpath) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1269 <wc-info> | 1269 <wc-info> |
| 1270 <schedule>add</schedule> | 1270 <schedule>add</schedule> |
| 1271 <depth>infinity</depth> | 1271 <depth>infinity</depth> |
| 1272 <copy-from-url>http://src.chromium.org/svn/trunk/src/chrome/app/DEPS</copy-from-
url> | 1272 <copy-from-url>http://src.chromium.org/svn/trunk/src/chrome/app/DEPS</copy-from-
url> |
| 1273 <copy-from-rev>14628</copy-from-rev> | 1273 <copy-from-rev>14628</copy-from-rev> |
| 1274 <checksum>369f59057ba0e6d9017e28f8bdfb1f43</checksum> | 1274 <checksum>369f59057ba0e6d9017e28f8bdfb1f43</checksum> |
| 1275 </wc-info> | 1275 </wc-info> |
| 1276 </entry> | 1276 </entry> |
| 1277 </info> | 1277 </info> |
| 1278 """ % self.url | 1278 """ % self.url |
| 1279 options = self.Options(verbose=True) | 1279 gclient.CaptureSVN(['info', '--xml', self.url], |
| 1280 gclient.CaptureSVN(options, ['info', '--xml', self.url], | 1280 '.', True).AndReturn(xml_text) |
| 1281 '.').AndReturn(xml_text) | |
| 1282 expected = { | 1281 expected = { |
| 1283 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d', | 1282 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d', |
| 1284 'UUID': None, | 1283 'UUID': None, |
| 1285 'Repository Root': 'http://src.chromium.org/svn', | 1284 'Repository Root': 'http://src.chromium.org/svn', |
| 1286 'Schedule': 'add', | 1285 'Schedule': 'add', |
| 1287 'Copied From URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/DEPS'
, | 1286 'Copied From URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/DEPS'
, |
| 1288 'Copied From Rev': '14628', | 1287 'Copied From Rev': '14628', |
| 1289 'Path': self.url, | 1288 'Path': self.url, |
| 1290 'Revision': 14628, | 1289 'Revision': 14628, |
| 1291 'Node Kind': 'file', | 1290 'Node Kind': 'file', |
| 1292 } | 1291 } |
| 1293 self.mox.ReplayAll() | 1292 self.mox.ReplayAll() |
| 1294 file_info = self._CaptureSVNInfo(options, self.url, '.') | 1293 file_info = self._CaptureSVNInfo(self.url, '.', True) |
| 1295 self.assertEquals(sorted(file_info.items()), sorted(expected.items())) | 1294 self.assertEquals(sorted(file_info.items()), sorted(expected.items())) |
| 1296 self.mox.VerifyAll() | 1295 self.mox.VerifyAll() |
| 1297 | 1296 |
| 1298 def testCaptureSvnInfo(self): | 1297 def testCaptureSvnInfo(self): |
| 1299 xml_text = """<?xml version="1.0"?> | 1298 xml_text = """<?xml version="1.0"?> |
| 1300 <info> | 1299 <info> |
| 1301 <entry | 1300 <entry |
| 1302 kind="dir" | 1301 kind="dir" |
| 1303 path="." | 1302 path="." |
| 1304 revision="35"> | 1303 revision="35"> |
| 1305 <url>%s</url> | 1304 <url>%s</url> |
| 1306 <repository> | 1305 <repository> |
| 1307 <root>%s</root> | 1306 <root>%s</root> |
| 1308 <uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid> | 1307 <uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid> |
| 1309 </repository> | 1308 </repository> |
| 1310 <wc-info> | 1309 <wc-info> |
| 1311 <schedule>normal</schedule> | 1310 <schedule>normal</schedule> |
| 1312 <depth>infinity</depth> | 1311 <depth>infinity</depth> |
| 1313 </wc-info> | 1312 </wc-info> |
| 1314 <commit | 1313 <commit |
| 1315 revision="35"> | 1314 revision="35"> |
| 1316 <author>maruel</author> | 1315 <author>maruel</author> |
| 1317 <date>2008-12-04T20:12:19.685120Z</date> | 1316 <date>2008-12-04T20:12:19.685120Z</date> |
| 1318 </commit> | 1317 </commit> |
| 1319 </entry> | 1318 </entry> |
| 1320 </info> | 1319 </info> |
| 1321 """ % (self.url, self.root_dir) | 1320 """ % (self.url, self.root_dir) |
| 1322 options = self.Options(verbose=True) | 1321 gclient.CaptureSVN(['info', '--xml', self.url], |
| 1323 gclient.CaptureSVN(options, ['info', '--xml', self.url], | 1322 '.', True).AndReturn(xml_text) |
| 1324 '.').AndReturn(xml_text) | |
| 1325 self.mox.ReplayAll() | 1323 self.mox.ReplayAll() |
| 1326 file_info = self._CaptureSVNInfo(options, self.url, '.') | 1324 file_info = self._CaptureSVNInfo(self.url, '.', True) |
| 1327 expected = { | 1325 expected = { |
| 1328 'URL': self.url, | 1326 'URL': self.url, |
| 1329 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb', | 1327 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb', |
| 1330 'Revision': 35, | 1328 'Revision': 35, |
| 1331 'Repository Root': self.root_dir, | 1329 'Repository Root': self.root_dir, |
| 1332 'Schedule': 'normal', | 1330 'Schedule': 'normal', |
| 1333 'Copied From URL': None, | 1331 'Copied From URL': None, |
| 1334 'Copied From Rev': None, | 1332 'Copied From Rev': None, |
| 1335 'Path': '.', | 1333 'Path': '.', |
| 1336 'Node Kind': 'dir', | 1334 'Node Kind': 'dir', |
| 1337 } | 1335 } |
| 1338 self.assertEqual(file_info, expected) | 1336 self.assertEqual(file_info, expected) |
| 1339 self.mox.VerifyAll() | 1337 self.mox.VerifyAll() |
| 1340 | 1338 |
| 1341 | 1339 |
| 1342 if __name__ == '__main__': | 1340 if __name__ == '__main__': |
| 1343 unittest.main() | 1341 unittest.main() |
| 1344 | 1342 |
| 1345 # vim: ts=2:sw=2:tw=80:et: | 1343 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |