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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 self.mox.ReplayAll() | 1213 self.mox.ReplayAll() |
1214 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1214 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
1215 relpath=self.relpath) | 1215 relpath=self.relpath) |
1216 scm.update(options, (), files_list) | 1216 scm.update(options, (), files_list) |
1217 self.mox.VerifyAll() | 1217 self.mox.VerifyAll() |
1218 | 1218 |
1219 def testUpdateUpdate(self): | 1219 def testUpdateUpdate(self): |
1220 options = self.Options(verbose=True) | 1220 options = self.Options(verbose=True) |
1221 base_path = os.path.join(self.root_dir, self.relpath) | 1221 base_path = os.path.join(self.root_dir, self.relpath) |
1222 options.force = True | 1222 options.force = True |
1223 file_info = gclient.PrintableObject() | 1223 file_info = { |
1224 file_info.root = 'blah' | 1224 'Repository Root': 'blah', |
1225 file_info.url = self.url | 1225 'URL': self.url, |
1226 file_info.uuid = 'ABC' | 1226 'UUID': 'ABC', |
1227 file_info.revision = 42 | 1227 'Revision': 42, |
| 1228 } |
1228 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False) | 1229 options.path_exists(os.path.join(base_path, '.git')).AndReturn(False) |
1229 # Checkout or update. | 1230 # Checkout or update. |
1230 options.path_exists(base_path).AndReturn(True) | 1231 options.path_exists(base_path).AndReturn(True) |
1231 gclient.CaptureSVNInfo(options, os.path.join(base_path, "."), '.' | 1232 gclient.CaptureSVNInfo(options, os.path.join(base_path, "."), '.' |
1232 ).AndReturn(file_info) | 1233 ).AndReturn(file_info) |
1233 # Cheat a bit here. | 1234 # Cheat a bit here. |
1234 gclient.CaptureSVNInfo(options, file_info.url, '.').AndReturn(file_info) | 1235 gclient.CaptureSVNInfo(options, file_info['URL'], '.').AndReturn(file_info) |
1235 additional_args = [] | 1236 additional_args = [] |
1236 if options.manually_grab_svn_rev: | 1237 if options.manually_grab_svn_rev: |
1237 additional_args = ['--revision', str(file_info.revision)] | 1238 additional_args = ['--revision', str(file_info['Revision'])] |
1238 files_list = [] | 1239 files_list = [] |
1239 gclient.RunSVNAndGetFileList(options, ['update', base_path] + additional_arg
s, | 1240 gclient.RunSVNAndGetFileList(options, ['update', base_path] + additional_arg
s, |
1240 self.root_dir, files_list) | 1241 self.root_dir, files_list) |
1241 | 1242 |
1242 self.mox.ReplayAll() | 1243 self.mox.ReplayAll() |
1243 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1244 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
1244 relpath=self.relpath) | 1245 relpath=self.relpath) |
1245 scm.update(options, (), files_list) | 1246 scm.update(options, (), files_list) |
1246 self.mox.VerifyAll() | 1247 self.mox.VerifyAll() |
1247 | 1248 |
1248 def testUpdateGit(self): | 1249 def testUpdateGit(self): |
1249 options = self.Options(verbose=True) | 1250 options = self.Options(verbose=True) |
1250 options.path_exists(os.path.join(self.root_dir, self.relpath, '.git') | 1251 options.path_exists(os.path.join(self.root_dir, self.relpath, '.git') |
1251 ).AndReturn(True) | 1252 ).AndReturn(True) |
1252 print >> options.stdout, ( | 1253 print >> options.stdout, ( |
1253 "________ found .git directory; skipping %s" % self.relpath) | 1254 "________ found .git directory; skipping %s" % self.relpath) |
1254 | 1255 |
1255 self.mox.ReplayAll() | 1256 self.mox.ReplayAll() |
1256 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, | 1257 scm = gclient.SCMWrapper(url=self.url, root_dir=self.root_dir, |
1257 relpath=self.relpath) | 1258 relpath=self.relpath) |
1258 file_list = [] | 1259 file_list = [] |
1259 scm.update(options, self.args, file_list) | 1260 scm.update(options, self.args, file_list) |
1260 self.mox.VerifyAll() | 1261 self.mox.VerifyAll() |
1261 | 1262 |
| 1263 def testGetSVNFileInfo(self): |
| 1264 xml_text = r"""<?xml version="1.0"?> |
| 1265 <info> |
| 1266 <entry kind="file" path="%s" revision="14628"> |
| 1267 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url> |
| 1268 <repository><root>http://src.chromium.org/svn</root></repository> |
| 1269 <wc-info> |
| 1270 <schedule>add</schedule> |
| 1271 <depth>infinity</depth> |
| 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> |
| 1274 <checksum>369f59057ba0e6d9017e28f8bdfb1f43</checksum> |
| 1275 </wc-info> |
| 1276 </entry> |
| 1277 </info> |
| 1278 """ % self.url |
| 1279 options = self.Options(verbose=True) |
| 1280 gclient.CaptureSVN(options, ['info', '--xml', self.url], |
| 1281 '.').AndReturn(xml_text) |
| 1282 expected = { |
| 1283 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d', |
| 1284 'UUID': None, |
| 1285 'Repository Root': 'http://src.chromium.org/svn', |
| 1286 'Schedule': 'add', |
| 1287 'Copied From URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/DEPS'
, |
| 1288 'Copied From Rev': '14628', |
| 1289 'Path': self.url, |
| 1290 'Revision': 14628, |
| 1291 'Node Kind': 'file', |
| 1292 } |
| 1293 self.mox.ReplayAll() |
| 1294 file_info = self._CaptureSVNInfo(options, self.url, '.') |
| 1295 self.assertEquals(sorted(file_info.items()), sorted(expected.items())) |
| 1296 self.mox.VerifyAll() |
| 1297 |
1262 def testCaptureSvnInfo(self): | 1298 def testCaptureSvnInfo(self): |
1263 xml_text = """<?xml version="1.0"?> | 1299 xml_text = """<?xml version="1.0"?> |
1264 <info> | 1300 <info> |
1265 <entry | 1301 <entry |
1266 kind="dir" | 1302 kind="dir" |
1267 path="." | 1303 path="." |
1268 revision="35"> | 1304 revision="35"> |
1269 <url>%s</url> | 1305 <url>%s</url> |
1270 <repository> | 1306 <repository> |
1271 <root>%s</root> | 1307 <root>%s</root> |
1272 <uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid> | 1308 <uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid> |
1273 </repository> | 1309 </repository> |
1274 <wc-info> | 1310 <wc-info> |
1275 <schedule>normal</schedule> | 1311 <schedule>normal</schedule> |
1276 <depth>infinity</depth> | 1312 <depth>infinity</depth> |
1277 </wc-info> | 1313 </wc-info> |
1278 <commit | 1314 <commit |
1279 revision="35"> | 1315 revision="35"> |
1280 <author>maruel</author> | 1316 <author>maruel</author> |
1281 <date>2008-12-04T20:12:19.685120Z</date> | 1317 <date>2008-12-04T20:12:19.685120Z</date> |
1282 </commit> | 1318 </commit> |
1283 </entry> | 1319 </entry> |
1284 </info> | 1320 </info> |
1285 """ % (self.url, self.root_dir) | 1321 """ % (self.url, self.root_dir) |
1286 options = self.Options(verbose=True) | 1322 options = self.Options(verbose=True) |
1287 gclient.CaptureSVN(options, ['info', '--xml', self.url], | 1323 gclient.CaptureSVN(options, ['info', '--xml', self.url], |
1288 '.').AndReturn(xml_text) | 1324 '.').AndReturn(xml_text) |
1289 self.mox.ReplayAll() | 1325 self.mox.ReplayAll() |
1290 file_info = self._CaptureSVNInfo(options, self.url, '.') | 1326 file_info = self._CaptureSVNInfo(options, self.url, '.') |
1291 self.failUnless(file_info.root == self.root_dir) | 1327 expected = { |
1292 self.failUnless(file_info.url == self.url) | 1328 'URL': self.url, |
1293 self.failUnless(file_info.uuid == '7b9385f5-0452-0410-af26-ad4892b7a1fb') | 1329 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb', |
1294 self.failUnless(file_info.revision == 35) | 1330 'Revision': 35, |
| 1331 'Repository Root': self.root_dir, |
| 1332 'Schedule': 'normal', |
| 1333 'Copied From URL': None, |
| 1334 'Copied From Rev': None, |
| 1335 'Path': '.', |
| 1336 'Node Kind': 'dir', |
| 1337 } |
| 1338 self.assertEqual(file_info, expected) |
1295 self.mox.VerifyAll() | 1339 self.mox.VerifyAll() |
1296 | 1340 |
1297 | 1341 |
1298 if __name__ == '__main__': | 1342 if __name__ == '__main__': |
1299 unittest.main() | 1343 unittest.main() |
1300 | 1344 |
1301 # vim: ts=2:sw=2:tw=80:et: | 1345 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |