Explorar o código

depot_tools: Make git_cache Python 3 compatible.

Bug: 984182
Change-Id: Ia413435af80d03dcfa01bb2ab7480cd6a37b4161
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1717496
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Edward Lemur %!s(int64=6) %!d(string=hai) anos
pai
achega
df746d0e6f
Modificáronse 3 ficheiros con 6 adicións e 4 borrados
  1. 1 0
      gclient_utils.py
  2. 2 1
      git_cache.py
  3. 3 3
      tests/git_cache_test.py

+ 1 - 0
gclient_utils.py

@@ -597,6 +597,7 @@ def CheckCallAndFilter(args, stdout=None, filter_fn=None,
         if len(in_line):
           filter_fn(in_line)
       rv = kid.wait()
+      kid.stdout.close()
 
       # Don't put this in a 'finally,' since the child may still run if we get
       # an exception.

+ 2 - 1
git_cache.py

@@ -537,6 +537,7 @@ class Mirror(object):
         [self.git_exe, 'config', '--get-all', 'remote.origin.fetch'],
         cwd=rundir).strip().splitlines()
     for spec in fetch_specs:
+      spec = spec.decode()
       try:
         self.print('Fetching %s' % spec)
         with self.print_duration_of('fetch %s' % spec):
@@ -885,4 +886,4 @@ if __name__ == '__main__':
     sys.exit(main(sys.argv[1:]))
   except KeyboardInterrupt:
     sys.stderr.write('interrupted\n')
-    sys.exit(1)
+    sys.exit(1)

+ 3 - 3
tests/git_cache_test.py

@@ -52,7 +52,7 @@ class GitCacheTest(unittest.TestCase):
     mirror = git_cache.Mirror('test://phony.example.biz')
     for fetch_specs, expected in testData:
       mirror = git_cache.Mirror('test://phony.example.biz', refs=fetch_specs)
-      self.assertItemsEqual(mirror.fetch_specs, expected)
+      self.assertEqual(mirror.fetch_specs, set(expected))
 
   def testPopulate(self):
     self.git(['init', '-q'])
@@ -115,13 +115,13 @@ class GitCacheDirTest(unittest.TestCase):
     old = git_cache.Mirror._GIT_CONFIG_LOCATION
     try:
       try:
-        os.write(fd, '[cache]\n  cachepath="hello world"\n')
+        os.write(fd, b'[cache]\n  cachepath="hello world"\n')
       finally:
         os.close(fd)
 
       git_cache.Mirror._GIT_CONFIG_LOCATION = ['-f', tmpFile]
 
-      self.assertEqual(git_cache.Mirror.GetCachePath(), 'hello world')
+      self.assertEqual(git_cache.Mirror.GetCachePath(), b'hello world')
     finally:
       git_cache.Mirror._GIT_CONFIG_LOCATION = old
       os.remove(tmpFile)