libv8 8.4.255.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (639) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +3 -0
  5. data/.travis.yml +45 -0
  6. data/CHANGELOG.md +111 -0
  7. data/Gemfile +4 -0
  8. data/README.md +152 -0
  9. data/Rakefile +125 -0
  10. data/appveyor.yml.disabled +36 -0
  11. data/ext/libv8/arch.rb +20 -0
  12. data/ext/libv8/builder.rb +106 -0
  13. data/ext/libv8/extconf.rb +7 -0
  14. data/ext/libv8/location.rb +89 -0
  15. data/ext/libv8/paths.rb +28 -0
  16. data/lib/libv8.rb +9 -0
  17. data/lib/libv8/version.rb +3 -0
  18. data/libv8.gemspec +30 -0
  19. data/scaleway.png +0 -0
  20. data/spec/location_spec.rb +69 -0
  21. data/spec/spec_helper.rb +4 -0
  22. data/thefrontside.png +0 -0
  23. data/vendor/depot_tools/.cipd_impl.ps1 +129 -0
  24. data/vendor/depot_tools/.gitattributes +55 -0
  25. data/vendor/depot_tools/.gitignore +92 -0
  26. data/vendor/depot_tools/.style.yapf +4 -0
  27. data/vendor/depot_tools/.vpython +55 -0
  28. data/vendor/depot_tools/.vpython3 +23 -0
  29. data/vendor/depot_tools/CROS_OWNERS +7 -0
  30. data/vendor/depot_tools/GOMA_OWNERS +9 -0
  31. data/vendor/depot_tools/LICENSE +27 -0
  32. data/vendor/depot_tools/LUCI_OWNERS +5 -0
  33. data/vendor/depot_tools/OWNERS +39 -0
  34. data/vendor/depot_tools/PRESUBMIT.py +150 -0
  35. data/vendor/depot_tools/README.gclient.md +67 -0
  36. data/vendor/depot_tools/README.git-cl.md +99 -0
  37. data/vendor/depot_tools/README.md +78 -0
  38. data/vendor/depot_tools/WATCHLISTS +26 -0
  39. data/vendor/depot_tools/auth.py +163 -0
  40. data/vendor/depot_tools/autoninja +36 -0
  41. data/vendor/depot_tools/autoninja.bat +33 -0
  42. data/vendor/depot_tools/autoninja.py +148 -0
  43. data/vendor/depot_tools/bb +12 -0
  44. data/vendor/depot_tools/bb.bat +7 -0
  45. data/vendor/depot_tools/bootstrap/README.md +155 -0
  46. data/vendor/depot_tools/bootstrap/bootstrap.py +356 -0
  47. data/vendor/depot_tools/bootstrap/git-bash.template.sh +12 -0
  48. data/vendor/depot_tools/bootstrap/git.template.bat +5 -0
  49. data/vendor/depot_tools/bootstrap/manifest.txt +27 -0
  50. data/vendor/depot_tools/bootstrap/manifest_bleeding_edge.txt +27 -0
  51. data/vendor/depot_tools/bootstrap/profile.d.python.sh +20 -0
  52. data/vendor/depot_tools/bootstrap/python27.bat +46 -0
  53. data/vendor/depot_tools/bootstrap/python3.bat +46 -0
  54. data/vendor/depot_tools/bootstrap/win_tools.bat +79 -0
  55. data/vendor/depot_tools/bootstrap_python3 +35 -0
  56. data/vendor/depot_tools/breakpad.py +12 -0
  57. data/vendor/depot_tools/cbuildbot +1 -0
  58. data/vendor/depot_tools/chrome_set_ver +1 -0
  59. data/vendor/depot_tools/cipd +247 -0
  60. data/vendor/depot_tools/cipd.bat +67 -0
  61. data/vendor/depot_tools/cipd_bin_setup.bat +6 -0
  62. data/vendor/depot_tools/cipd_bin_setup.sh +22 -0
  63. data/vendor/depot_tools/cipd_client_version +1 -0
  64. data/vendor/depot_tools/cipd_client_version.digests +22 -0
  65. data/vendor/depot_tools/cipd_manifest.txt +63 -0
  66. data/vendor/depot_tools/cipd_manifest.versions +438 -0
  67. data/vendor/depot_tools/cit +8 -0
  68. data/vendor/depot_tools/cit.bat +12 -0
  69. data/vendor/depot_tools/cit.py +167 -0
  70. data/vendor/depot_tools/clang-format +8 -0
  71. data/vendor/depot_tools/clang-format.bat +12 -0
  72. data/vendor/depot_tools/clang_format.py +79 -0
  73. data/vendor/depot_tools/clang_format_merge_driver +8 -0
  74. data/vendor/depot_tools/clang_format_merge_driver.bat +12 -0
  75. data/vendor/depot_tools/clang_format_merge_driver.py +69 -0
  76. data/vendor/depot_tools/codereview.settings +6 -0
  77. data/vendor/depot_tools/compile_single_file +8 -0
  78. data/vendor/depot_tools/compile_single_file.bat +11 -0
  79. data/vendor/depot_tools/compile_single_file.py +79 -0
  80. data/vendor/depot_tools/cpplint.bat +11 -0
  81. data/vendor/depot_tools/cpplint.py +6097 -0
  82. data/vendor/depot_tools/cpplint_chromium.py +50 -0
  83. data/vendor/depot_tools/cros +87 -0
  84. data/vendor/depot_tools/cros_sdk +1 -0
  85. data/vendor/depot_tools/crosjobs +13 -0
  86. data/vendor/depot_tools/detect_host_arch.py +55 -0
  87. data/vendor/depot_tools/dirmd +12 -0
  88. data/vendor/depot_tools/dirmd.bat +7 -0
  89. data/vendor/depot_tools/download_from_google_storage +8 -0
  90. data/vendor/depot_tools/download_from_google_storage.bat +12 -0
  91. data/vendor/depot_tools/download_from_google_storage.py +634 -0
  92. data/vendor/depot_tools/ensure_bootstrap +53 -0
  93. data/vendor/depot_tools/fetch +21 -0
  94. data/vendor/depot_tools/fetch.bat +28 -0
  95. data/vendor/depot_tools/fetch.py +319 -0
  96. data/vendor/depot_tools/fetch_configs/android.py +34 -0
  97. data/vendor/depot_tools/fetch_configs/android_internal.py +34 -0
  98. data/vendor/depot_tools/fetch_configs/breakpad.py +44 -0
  99. data/vendor/depot_tools/fetch_configs/chromium.py +66 -0
  100. data/vendor/depot_tools/fetch_configs/config_util.py +52 -0
  101. data/vendor/depot_tools/fetch_configs/crashpad.py +41 -0
  102. data/vendor/depot_tools/fetch_configs/dart.py +45 -0
  103. data/vendor/depot_tools/fetch_configs/depot_tools.py +44 -0
  104. data/vendor/depot_tools/fetch_configs/devtools-frontend.py +44 -0
  105. data/vendor/depot_tools/fetch_configs/goma_client.py +41 -0
  106. data/vendor/depot_tools/fetch_configs/gyp.py +41 -0
  107. data/vendor/depot_tools/fetch_configs/infra.py +40 -0
  108. data/vendor/depot_tools/fetch_configs/infra_internal.py +45 -0
  109. data/vendor/depot_tools/fetch_configs/inspector_protocol.py +40 -0
  110. data/vendor/depot_tools/fetch_configs/ios.py +34 -0
  111. data/vendor/depot_tools/fetch_configs/ios_internal.py +39 -0
  112. data/vendor/depot_tools/fetch_configs/nacl.py +48 -0
  113. data/vendor/depot_tools/fetch_configs/naclports.py +47 -0
  114. data/vendor/depot_tools/fetch_configs/node-ci.py +41 -0
  115. data/vendor/depot_tools/fetch_configs/pdfium.py +40 -0
  116. data/vendor/depot_tools/fetch_configs/skia.py +41 -0
  117. data/vendor/depot_tools/fetch_configs/skia_buildbot.py +41 -0
  118. data/vendor/depot_tools/fetch_configs/syzygy.py +41 -0
  119. data/vendor/depot_tools/fetch_configs/v8.py +44 -0
  120. data/vendor/depot_tools/fetch_configs/webrtc.py +52 -0
  121. data/vendor/depot_tools/fetch_configs/webrtc_android.py +34 -0
  122. data/vendor/depot_tools/fetch_configs/webrtc_ios.py +34 -0
  123. data/vendor/depot_tools/fix_encoding.py +385 -0
  124. data/vendor/depot_tools/gclient +38 -0
  125. data/vendor/depot_tools/gclient-new-workdir.py +124 -0
  126. data/vendor/depot_tools/gclient.bat +32 -0
  127. data/vendor/depot_tools/gclient.py +3198 -0
  128. data/vendor/depot_tools/gclient_completion.sh +76 -0
  129. data/vendor/depot_tools/gclient_eval.py +891 -0
  130. data/vendor/depot_tools/gclient_paths.py +152 -0
  131. data/vendor/depot_tools/gclient_scm.py +1615 -0
  132. data/vendor/depot_tools/gclient_utils.py +1280 -0
  133. data/vendor/depot_tools/gerrit_client.py +151 -0
  134. data/vendor/depot_tools/gerrit_util.py +996 -0
  135. data/vendor/depot_tools/git-cache +6 -0
  136. data/vendor/depot_tools/git-cl +6 -0
  137. data/vendor/depot_tools/git-crrev-parse +53 -0
  138. data/vendor/depot_tools/git-drover +6 -0
  139. data/vendor/depot_tools/git-find-releases +6 -0
  140. data/vendor/depot_tools/git-footers +6 -0
  141. data/vendor/depot_tools/git-freeze +8 -0
  142. data/vendor/depot_tools/git-gs +9 -0
  143. data/vendor/depot_tools/git-hyper-blame +6 -0
  144. data/vendor/depot_tools/git-map +6 -0
  145. data/vendor/depot_tools/git-map-branches +6 -0
  146. data/vendor/depot_tools/git-mark-merge-base +6 -0
  147. data/vendor/depot_tools/git-nav-downstream +6 -0
  148. data/vendor/depot_tools/git-nav-upstream +6 -0
  149. data/vendor/depot_tools/git-new-branch +6 -0
  150. data/vendor/depot_tools/git-number +6 -0
  151. data/vendor/depot_tools/git-rebase-update +6 -0
  152. data/vendor/depot_tools/git-rename-branch +6 -0
  153. data/vendor/depot_tools/git-reparent-branch +6 -0
  154. data/vendor/depot_tools/git-retry +8 -0
  155. data/vendor/depot_tools/git-runhooks +23 -0
  156. data/vendor/depot_tools/git-squash-branch +6 -0
  157. data/vendor/depot_tools/git-templates/description +3 -0
  158. data/vendor/depot_tools/git-templates/hooks/applypatch-msg +4 -0
  159. data/vendor/depot_tools/git-templates/hooks/post-applypatch +4 -0
  160. data/vendor/depot_tools/git-templates/hooks/post-checkout +4 -0
  161. data/vendor/depot_tools/git-templates/hooks/post-commit +4 -0
  162. data/vendor/depot_tools/git-templates/hooks/post-merge +4 -0
  163. data/vendor/depot_tools/git-templates/hooks/post-update +4 -0
  164. data/vendor/depot_tools/git-templates/hooks/pre-applypatch +4 -0
  165. data/vendor/depot_tools/git-templates/hooks/pre-auto-gc +4 -0
  166. data/vendor/depot_tools/git-templates/hooks/pre-commit +4 -0
  167. data/vendor/depot_tools/git-templates/hooks/pre-rebase +4 -0
  168. data/vendor/depot_tools/git-templates/hooks/prepare-commit-msg +4 -0
  169. data/vendor/depot_tools/git-templates/info/exclude +6 -0
  170. data/vendor/depot_tools/git-thaw +13 -0
  171. data/vendor/depot_tools/git-upstream-diff +9 -0
  172. data/vendor/depot_tools/git_cache.py +786 -0
  173. data/vendor/depot_tools/git_cl.py +5158 -0
  174. data/vendor/depot_tools/git_cl_completion.sh +48 -0
  175. data/vendor/depot_tools/git_common.py +1101 -0
  176. data/vendor/depot_tools/git_dates.py +62 -0
  177. data/vendor/depot_tools/git_drover.py +469 -0
  178. data/vendor/depot_tools/git_find_releases.py +67 -0
  179. data/vendor/depot_tools/git_footers.py +261 -0
  180. data/vendor/depot_tools/git_freezer.py +40 -0
  181. data/vendor/depot_tools/git_hyper_blame.py +391 -0
  182. data/vendor/depot_tools/git_map.py +166 -0
  183. data/vendor/depot_tools/git_map_branches.py +354 -0
  184. data/vendor/depot_tools/git_mark_merge_base.py +73 -0
  185. data/vendor/depot_tools/git_nav_downstream.py +69 -0
  186. data/vendor/depot_tools/git_new_branch.py +82 -0
  187. data/vendor/depot_tools/git_number.py +301 -0
  188. data/vendor/depot_tools/git_rebase_update.py +351 -0
  189. data/vendor/depot_tools/git_rename_branch.py +55 -0
  190. data/vendor/depot_tools/git_reparent_branch.py +101 -0
  191. data/vendor/depot_tools/git_retry.py +181 -0
  192. data/vendor/depot_tools/git_squash_branch.py +28 -0
  193. data/vendor/depot_tools/git_upstream_diff.py +64 -0
  194. data/vendor/depot_tools/gn +8 -0
  195. data/vendor/depot_tools/gn.bat +12 -0
  196. data/vendor/depot_tools/gn.py +78 -0
  197. data/vendor/depot_tools/goma_auth +12 -0
  198. data/vendor/depot_tools/goma_auth.bat +8 -0
  199. data/vendor/depot_tools/goma_ctl +12 -0
  200. data/vendor/depot_tools/goma_ctl.bat +8 -0
  201. data/vendor/depot_tools/gsutil.py +190 -0
  202. data/vendor/depot_tools/gsutil.py.bat +23 -0
  203. data/vendor/depot_tools/gsutil.vpython +120 -0
  204. data/vendor/depot_tools/infra/README.md +1 -0
  205. data/vendor/depot_tools/infra/config/OWNERS +7 -0
  206. data/vendor/depot_tools/infra/config/README.md +1 -0
  207. data/vendor/depot_tools/infra/config/recipes.cfg +26 -0
  208. data/vendor/depot_tools/led +12 -0
  209. data/vendor/depot_tools/led.bat +7 -0
  210. data/vendor/depot_tools/lockfile.py +116 -0
  211. data/vendor/depot_tools/luci-auth +13 -0
  212. data/vendor/depot_tools/luci-auth.bat +8 -0
  213. data/vendor/depot_tools/lucicfg +12 -0
  214. data/vendor/depot_tools/lucicfg.bat +7 -0
  215. data/vendor/depot_tools/mac_toolchain +12 -0
  216. data/vendor/depot_tools/man/html/depot_tools.html +934 -0
  217. data/vendor/depot_tools/man/html/depot_tools_tutorial.html +1593 -0
  218. data/vendor/depot_tools/man/html/git-cl.html +1033 -0
  219. data/vendor/depot_tools/man/html/git-drover.html +1048 -0
  220. data/vendor/depot_tools/man/html/git-footers.html +878 -0
  221. data/vendor/depot_tools/man/html/git-freeze.html +859 -0
  222. data/vendor/depot_tools/man/html/git-hyper-blame.html +878 -0
  223. data/vendor/depot_tools/man/html/git-map-branches.html +904 -0
  224. data/vendor/depot_tools/man/html/git-map.html +887 -0
  225. data/vendor/depot_tools/man/html/git-mark-merge-base.html +826 -0
  226. data/vendor/depot_tools/man/html/git-nav-downstream.html +844 -0
  227. data/vendor/depot_tools/man/html/git-nav-upstream.html +853 -0
  228. data/vendor/depot_tools/man/html/git-new-branch.html +932 -0
  229. data/vendor/depot_tools/man/html/git-rebase-update.html +961 -0
  230. data/vendor/depot_tools/man/html/git-rename-branch.html +794 -0
  231. data/vendor/depot_tools/man/html/git-reparent-branch.html +847 -0
  232. data/vendor/depot_tools/man/html/git-retry.html +858 -0
  233. data/vendor/depot_tools/man/html/git-squash-branch.html +881 -0
  234. data/vendor/depot_tools/man/html/git-thaw.html +794 -0
  235. data/vendor/depot_tools/man/html/git-upstream-diff.html +923 -0
  236. data/vendor/depot_tools/man/man1/git-cl.1 +198 -0
  237. data/vendor/depot_tools/man/man1/git-drover.1 +330 -0
  238. data/vendor/depot_tools/man/man1/git-footers.1 +144 -0
  239. data/vendor/depot_tools/man/man1/git-freeze.1 +113 -0
  240. data/vendor/depot_tools/man/man1/git-hyper-blame.1 +128 -0
  241. data/vendor/depot_tools/man/man1/git-map-branches.1 +210 -0
  242. data/vendor/depot_tools/man/man1/git-map.1 +179 -0
  243. data/vendor/depot_tools/man/man1/git-mark-merge-base.1 +69 -0
  244. data/vendor/depot_tools/man/man1/git-nav-downstream.1 +112 -0
  245. data/vendor/depot_tools/man/man1/git-nav-upstream.1 +122 -0
  246. data/vendor/depot_tools/man/man1/git-new-branch.1 +176 -0
  247. data/vendor/depot_tools/man/man1/git-rebase-update.1 +177 -0
  248. data/vendor/depot_tools/man/man1/git-rename-branch.1 +53 -0
  249. data/vendor/depot_tools/man/man1/git-reparent-branch.1 +93 -0
  250. data/vendor/depot_tools/man/man1/git-retry.1 +108 -0
  251. data/vendor/depot_tools/man/man1/git-squash-branch.1 +129 -0
  252. data/vendor/depot_tools/man/man1/git-thaw.1 +54 -0
  253. data/vendor/depot_tools/man/man1/git-upstream-diff.1 +153 -0
  254. data/vendor/depot_tools/man/man7/depot_tools.7 +139 -0
  255. data/vendor/depot_tools/man/man7/depot_tools_tutorial.7 +1061 -0
  256. data/vendor/depot_tools/man/push_to_gs.sh +4 -0
  257. data/vendor/depot_tools/man/src/.gitignore +5 -0
  258. data/vendor/depot_tools/man/src/_aliases.txt +5 -0
  259. data/vendor/depot_tools/man/src/_footer.txt +8 -0
  260. data/vendor/depot_tools/man/src/_git-cl_desc.helper.txt +1 -0
  261. data/vendor/depot_tools/man/src/_git-drover_desc.helper.txt +2 -0
  262. data/vendor/depot_tools/man/src/_git-footers_desc.helper.txt +1 -0
  263. data/vendor/depot_tools/man/src/_git-freeze_desc.helper.txt +1 -0
  264. data/vendor/depot_tools/man/src/_git-hyper-blame_desc.helper.txt +1 -0
  265. data/vendor/depot_tools/man/src/_git-map-branches_desc.helper.txt +4 -0
  266. data/vendor/depot_tools/man/src/_git-map_desc.helper.txt +3 -0
  267. data/vendor/depot_tools/man/src/_git-mark-merge-base_desc.helper.txt +1 -0
  268. data/vendor/depot_tools/man/src/_git-nav-downstream_desc.helper.txt +1 -0
  269. data/vendor/depot_tools/man/src/_git-nav-upstream_desc.helper.txt +1 -0
  270. data/vendor/depot_tools/man/src/_git-new-branch_desc.helper.txt +1 -0
  271. data/vendor/depot_tools/man/src/_git-rebase-update_desc.helper.txt +1 -0
  272. data/vendor/depot_tools/man/src/_git-rename-branch_desc.helper.txt +1 -0
  273. data/vendor/depot_tools/man/src/_git-reparent-branch_desc.helper.txt +1 -0
  274. data/vendor/depot_tools/man/src/_git-retry_desc.helper.txt +2 -0
  275. data/vendor/depot_tools/man/src/_git-squash-branch_desc.helper.txt +1 -0
  276. data/vendor/depot_tools/man/src/_git-thaw_desc.helper.txt +2 -0
  277. data/vendor/depot_tools/man/src/_git-upstream-diff_desc.helper.txt +1 -0
  278. data/vendor/depot_tools/man/src/_helper_prefix.txt +1 -0
  279. data/vendor/depot_tools/man/src/asciidoc-override.css +7 -0
  280. data/vendor/depot_tools/man/src/common_demo_functions.sh +84 -0
  281. data/vendor/depot_tools/man/src/demo_repo.sh +43 -0
  282. data/vendor/depot_tools/man/src/depot_tools.txt +28 -0
  283. data/vendor/depot_tools/man/src/depot_tools_tutorial.demo.walkthrough.sh +155 -0
  284. data/vendor/depot_tools/man/src/depot_tools_tutorial.txt +432 -0
  285. data/vendor/depot_tools/man/src/filter_demo_output.py +141 -0
  286. data/vendor/depot_tools/man/src/git-cl.txt +119 -0
  287. data/vendor/depot_tools/man/src/git-drover.demo.1.sh +22 -0
  288. data/vendor/depot_tools/man/src/git-drover.demo.2.sh +23 -0
  289. data/vendor/depot_tools/man/src/git-drover.demo.3.sh +27 -0
  290. data/vendor/depot_tools/man/src/git-drover.demo.4.sh +39 -0
  291. data/vendor/depot_tools/man/src/git-drover.demo.common.sh +19 -0
  292. data/vendor/depot_tools/man/src/git-drover.txt +102 -0
  293. data/vendor/depot_tools/man/src/git-footers.demo.1.sh +17 -0
  294. data/vendor/depot_tools/man/src/git-footers.txt +71 -0
  295. data/vendor/depot_tools/man/src/git-freeze.demo.1.sh +23 -0
  296. data/vendor/depot_tools/man/src/git-freeze.txt +54 -0
  297. data/vendor/depot_tools/man/src/git-hyper-blame.demo.1.sh +3 -0
  298. data/vendor/depot_tools/man/src/git-hyper-blame.demo.2.sh +4 -0
  299. data/vendor/depot_tools/man/src/git-hyper-blame.demo.common.sh +57 -0
  300. data/vendor/depot_tools/man/src/git-hyper-blame.txt +85 -0
  301. data/vendor/depot_tools/man/src/git-map-branches.demo.1.sh +8 -0
  302. data/vendor/depot_tools/man/src/git-map-branches.txt +64 -0
  303. data/vendor/depot_tools/man/src/git-map.demo.1.sh +3 -0
  304. data/vendor/depot_tools/man/src/git-map.txt +67 -0
  305. data/vendor/depot_tools/man/src/git-mark-merge-base.txt +46 -0
  306. data/vendor/depot_tools/man/src/git-nav-downstream.demo.1.sh +12 -0
  307. data/vendor/depot_tools/man/src/git-nav-downstream.txt +40 -0
  308. data/vendor/depot_tools/man/src/git-nav-upstream.demo.1.sh +12 -0
  309. data/vendor/depot_tools/man/src/git-nav-upstream.txt +39 -0
  310. data/vendor/depot_tools/man/src/git-new-branch.demo.1.sh +17 -0
  311. data/vendor/depot_tools/man/src/git-new-branch.txt +82 -0
  312. data/vendor/depot_tools/man/src/git-rebase-update.txt +141 -0
  313. data/vendor/depot_tools/man/src/git-rename-branch.txt +28 -0
  314. data/vendor/depot_tools/man/src/git-reparent-branch.txt +61 -0
  315. data/vendor/depot_tools/man/src/git-retry.txt +67 -0
  316. data/vendor/depot_tools/man/src/git-squash-branch.demo.1.sh +12 -0
  317. data/vendor/depot_tools/man/src/git-squash-branch.txt +59 -0
  318. data/vendor/depot_tools/man/src/git-thaw.txt +29 -0
  319. data/vendor/depot_tools/man/src/git-upstream-diff.txt +107 -0
  320. data/vendor/depot_tools/man/src/make_docs.sh +260 -0
  321. data/vendor/depot_tools/man/src/prep_demo_repo.sh +103 -0
  322. data/vendor/depot_tools/metrics.README.md +101 -0
  323. data/vendor/depot_tools/metrics.py +297 -0
  324. data/vendor/depot_tools/metrics_utils.py +293 -0
  325. data/vendor/depot_tools/my_activity.py +971 -0
  326. data/vendor/depot_tools/ninja +44 -0
  327. data/vendor/depot_tools/ninja-linux32 +0 -0
  328. data/vendor/depot_tools/ninja-linux64 +0 -0
  329. data/vendor/depot_tools/ninja-mac +0 -0
  330. data/vendor/depot_tools/ninja.exe +0 -0
  331. data/vendor/depot_tools/ninjalog.README.md +64 -0
  332. data/vendor/depot_tools/ninjalog_uploader.py +233 -0
  333. data/vendor/depot_tools/ninjalog_uploader_wrapper.py +125 -0
  334. data/vendor/depot_tools/owners.py +641 -0
  335. data/vendor/depot_tools/owners_finder.py +385 -0
  336. data/vendor/depot_tools/post_build_ninja_summary.py +350 -0
  337. data/vendor/depot_tools/presubmit_canned_checks.py +1655 -0
  338. data/vendor/depot_tools/presubmit_support.py +1923 -0
  339. data/vendor/depot_tools/profile.xml +8 -0
  340. data/vendor/depot_tools/prpc +13 -0
  341. data/vendor/depot_tools/prpc.bat +8 -0
  342. data/vendor/depot_tools/pylint +9 -0
  343. data/vendor/depot_tools/pylint-1.5 +78 -0
  344. data/vendor/depot_tools/pylint-1.6 +78 -0
  345. data/vendor/depot_tools/pylint-1.7 +78 -0
  346. data/vendor/depot_tools/pylint-1.8 +78 -0
  347. data/vendor/depot_tools/pylint-1.9 +78 -0
  348. data/vendor/depot_tools/pylint.bat +12 -0
  349. data/vendor/depot_tools/pylint_main.py +45 -0
  350. data/vendor/depot_tools/pylintrc +349 -0
  351. data/vendor/depot_tools/python-bin/python3 +7 -0
  352. data/vendor/depot_tools/python_runner.sh +60 -0
  353. data/vendor/depot_tools/rdb +12 -0
  354. data/vendor/depot_tools/rdb.bat +7 -0
  355. data/vendor/depot_tools/recipes/OWNERS +4 -0
  356. data/vendor/depot_tools/recipes/README.recipes.md +1079 -0
  357. data/vendor/depot_tools/recipes/recipe_modules/OWNERS +1 -0
  358. data/vendor/depot_tools/recipes/recipe_modules/bot_update/OWNERS +2 -0
  359. data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +38 -0
  360. data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +516 -0
  361. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +117 -0
  362. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +117 -0
  363. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +118 -0
  364. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +211 -0
  365. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +194 -0
  366. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +211 -0
  367. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +211 -0
  368. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/input_commit_with_id_without_repo.json +210 -0
  369. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/multiple_patch_refs.json +214 -0
  370. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +265 -0
  371. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_HEAD.json +65 -0
  372. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_a_branch_head.json +65 -0
  373. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_a_specific_commit.json +65 -0
  374. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_cp_checkout_master.json +65 -0
  375. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/refs.json +212 -0
  376. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +210 -0
  377. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/resolve_chromium_fixed_version.json +117 -0
  378. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +95 -0
  379. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +209 -0
  380. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +193 -0
  381. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +265 -0
  382. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +261 -0
  383. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +261 -0
  384. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +265 -0
  385. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +265 -0
  386. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +265 -0
  387. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +265 -0
  388. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +8 -0
  389. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +211 -0
  390. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +308 -0
  391. data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/__init__.py +0 -0
  392. data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +1258 -0
  393. data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +93 -0
  394. data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py +42 -0
  395. data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +35 -0
  396. data/vendor/depot_tools/recipes/recipe_modules/cipd/__init__.py +9 -0
  397. data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +455 -0
  398. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +403 -0
  399. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +403 -0
  400. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +82 -0
  401. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +411 -0
  402. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +403 -0
  403. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +315 -0
  404. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +313 -0
  405. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +313 -0
  406. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +403 -0
  407. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.py +187 -0
  408. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +5 -0
  409. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +5 -0
  410. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +12 -0
  411. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +12 -0
  412. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +12 -0
  413. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +12 -0
  414. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +12 -0
  415. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +12 -0
  416. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +12 -0
  417. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +12 -0
  418. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.py +59 -0
  419. data/vendor/depot_tools/recipes/recipe_modules/cipd/test_api.py +93 -0
  420. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/__init__.py +9 -0
  421. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +75 -0
  422. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +83 -0
  423. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +83 -0
  424. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +83 -0
  425. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.py +55 -0
  426. data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +13 -0
  427. data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +428 -0
  428. data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +462 -0
  429. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +238 -0
  430. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +240 -0
  431. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +238 -0
  432. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +95 -0
  433. data/vendor/depot_tools/recipes/recipe_modules/gclient/resources/diff_deps.py +16 -0
  434. data/vendor/depot_tools/recipes/recipe_modules/gclient/test_api.py +36 -0
  435. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/basic.json +55 -0
  436. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/dont have revision yet.json +84 -0
  437. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/no change, exception.json +83 -0
  438. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.expected/windows.json +55 -0
  439. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/diff_deps.py +88 -0
  440. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +92 -0
  441. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/sync_failure.py +24 -0
  442. data/vendor/depot_tools/recipes/recipe_modules/gerrit/__init__.py +8 -0
  443. data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +178 -0
  444. data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +284 -0
  445. data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.py +73 -0
  446. data/vendor/depot_tools/recipes/recipe_modules/gerrit/test_api.py +53 -0
  447. data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +11 -0
  448. data/vendor/depot_tools/recipes/recipe_modules/git/api.py +405 -0
  449. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +217 -0
  450. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +217 -0
  451. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +219 -0
  452. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +216 -0
  453. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +217 -0
  454. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +218 -0
  455. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +218 -0
  456. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +164 -0
  457. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +220 -0
  458. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +239 -0
  459. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +290 -0
  460. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +220 -0
  461. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +222 -0
  462. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +111 -0
  463. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +218 -0
  464. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +265 -0
  465. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +217 -0
  466. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +221 -0
  467. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +219 -0
  468. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +218 -0
  469. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +170 -0
  470. data/vendor/depot_tools/recipes/recipe_modules/git/resources/git_setup.py +52 -0
  471. data/vendor/depot_tools/recipes/recipe_modules/git/test_api.py +18 -0
  472. data/vendor/depot_tools/recipes/recipe_modules/git_cl/__init__.py +5 -0
  473. data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +50 -0
  474. data/vendor/depot_tools/recipes/recipe_modules/git_cl/config.py +22 -0
  475. data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +105 -0
  476. data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.py +47 -0
  477. data/vendor/depot_tools/recipes/recipe_modules/gitiles/OWNERS +2 -0
  478. data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +12 -0
  479. data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +257 -0
  480. data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +596 -0
  481. data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +93 -0
  482. data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +251 -0
  483. data/vendor/depot_tools/recipes/recipe_modules/gitiles/test_api.py +95 -0
  484. data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +5 -0
  485. data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.py +49 -0
  486. data/vendor/depot_tools/recipes/recipe_modules/gsutil/__init__.py +4 -0
  487. data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +222 -0
  488. data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +247 -0
  489. data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.py +92 -0
  490. data/vendor/depot_tools/recipes/recipe_modules/gsutil/resources/gsutil_smart_retry.py +69 -0
  491. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +36 -0
  492. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +140 -0
  493. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/ancient_version.json +83 -0
  494. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/automatic_version.json +83 -0
  495. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/explicit_version.json +83 -0
  496. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +21 -0
  497. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +83 -0
  498. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +21 -0
  499. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +42 -0
  500. data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +27 -0
  501. data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +251 -0
  502. data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +27 -0
  503. data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.py +19 -0
  504. data/vendor/depot_tools/recipes/recipe_modules/presubmit/properties.proto +14 -0
  505. data/vendor/depot_tools/recipes/recipe_modules/presubmit/test_api.py +19 -0
  506. data/vendor/depot_tools/recipes/recipe_modules/presubmit/tests/execute.py +247 -0
  507. data/vendor/depot_tools/recipes/recipe_modules/presubmit/tests/prepare.py +49 -0
  508. data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +18 -0
  509. data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +264 -0
  510. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +57 -0
  511. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +190 -0
  512. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +190 -0
  513. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +21 -0
  514. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +22 -0
  515. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +95 -0
  516. data/vendor/depot_tools/recipes/recipe_modules/tryserver/test_api.py +14 -0
  517. data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_fetch_ref_timeout.py +29 -0
  518. data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_owner.expected/basic.json +5 -0
  519. data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_owner.py +22 -0
  520. data/vendor/depot_tools/recipes/recipe_modules/tryserver/tests/gerrit_change_target_ref.py +32 -0
  521. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/__init__.py +25 -0
  522. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/api.py +137 -0
  523. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +21 -0
  524. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +21 -0
  525. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +108 -0
  526. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +21 -0
  527. data/vendor/depot_tools/recipes/recipes.py +249 -0
  528. data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +175 -0
  529. data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.py +56 -0
  530. data/vendor/depot_tools/recipes/trigger_recipe_roller.txt +13 -0
  531. data/vendor/depot_tools/repo +1194 -0
  532. data/vendor/depot_tools/roll-dep +21 -0
  533. data/vendor/depot_tools/roll-dep.bat +21 -0
  534. data/vendor/depot_tools/roll_dep.py +282 -0
  535. data/vendor/depot_tools/scm.py +415 -0
  536. data/vendor/depot_tools/setup_color.py +130 -0
  537. data/vendor/depot_tools/split_cl.py +263 -0
  538. data/vendor/depot_tools/subcommand.py +261 -0
  539. data/vendor/depot_tools/subprocess2.py +258 -0
  540. data/vendor/depot_tools/third_party/__init__.py +5 -0
  541. data/vendor/depot_tools/third_party/colorama/LICENSE.txt +27 -0
  542. data/vendor/depot_tools/third_party/colorama/README.chromium +12 -0
  543. data/vendor/depot_tools/third_party/colorama/README.rst +346 -0
  544. data/vendor/depot_tools/third_party/colorama/__init__.py +6 -0
  545. data/vendor/depot_tools/third_party/colorama/ansi.py +102 -0
  546. data/vendor/depot_tools/third_party/colorama/ansitowin32.py +257 -0
  547. data/vendor/depot_tools/third_party/colorama/initialise.py +80 -0
  548. data/vendor/depot_tools/third_party/colorama/win32.py +152 -0
  549. data/vendor/depot_tools/third_party/colorama/winterm.py +169 -0
  550. data/vendor/depot_tools/third_party/coverage/AUTHORS.txt +43 -0
  551. data/vendor/depot_tools/third_party/coverage/PKG-INFO +41 -0
  552. data/vendor/depot_tools/third_party/coverage/README.chromium +13 -0
  553. data/vendor/depot_tools/third_party/coverage/__init__.py +120 -0
  554. data/vendor/depot_tools/third_party/coverage/__main__.py +4 -0
  555. data/vendor/depot_tools/third_party/coverage/annotate.py +101 -0
  556. data/vendor/depot_tools/third_party/coverage/backward.py +184 -0
  557. data/vendor/depot_tools/third_party/coverage/bytecode.py +75 -0
  558. data/vendor/depot_tools/third_party/coverage/cmdline.py +740 -0
  559. data/vendor/depot_tools/third_party/coverage/codeunit.py +145 -0
  560. data/vendor/depot_tools/third_party/coverage/collector.py +353 -0
  561. data/vendor/depot_tools/third_party/coverage/config.py +213 -0
  562. data/vendor/depot_tools/third_party/coverage/control.py +776 -0
  563. data/vendor/depot_tools/third_party/coverage/data.py +278 -0
  564. data/vendor/depot_tools/third_party/coverage/debug.py +54 -0
  565. data/vendor/depot_tools/third_party/coverage/execfile.py +171 -0
  566. data/vendor/depot_tools/third_party/coverage/files.py +309 -0
  567. data/vendor/depot_tools/third_party/coverage/fullcoverage/encodings.py +57 -0
  568. data/vendor/depot_tools/third_party/coverage/html.py +387 -0
  569. data/vendor/depot_tools/third_party/coverage/htmlfiles/coverage_html.js +376 -0
  570. data/vendor/depot_tools/third_party/coverage/htmlfiles/index.html +104 -0
  571. data/vendor/depot_tools/third_party/coverage/htmlfiles/jquery-1.4.3.min.js +166 -0
  572. data/vendor/depot_tools/third_party/coverage/htmlfiles/jquery.hotkeys.js +99 -0
  573. data/vendor/depot_tools/third_party/coverage/htmlfiles/jquery.isonscreen.js +53 -0
  574. data/vendor/depot_tools/third_party/coverage/htmlfiles/jquery.min.js +166 -0
  575. data/vendor/depot_tools/third_party/coverage/htmlfiles/jquery.tablesorter.min.js +2 -0
  576. data/vendor/depot_tools/third_party/coverage/htmlfiles/keybd_closed.png +0 -0
  577. data/vendor/depot_tools/third_party/coverage/htmlfiles/keybd_open.png +0 -0
  578. data/vendor/depot_tools/third_party/coverage/htmlfiles/pyfile.html +90 -0
  579. data/vendor/depot_tools/third_party/coverage/htmlfiles/style.css +300 -0
  580. data/vendor/depot_tools/third_party/coverage/misc.py +163 -0
  581. data/vendor/depot_tools/third_party/coverage/parser.py +666 -0
  582. data/vendor/depot_tools/third_party/coverage/phystokens.py +208 -0
  583. data/vendor/depot_tools/third_party/coverage/report.py +92 -0
  584. data/vendor/depot_tools/third_party/coverage/results.py +286 -0
  585. data/vendor/depot_tools/third_party/coverage/summary.py +86 -0
  586. data/vendor/depot_tools/third_party/coverage/templite.py +166 -0
  587. data/vendor/depot_tools/third_party/coverage/version.py +9 -0
  588. data/vendor/depot_tools/third_party/coverage/xmlreport.py +155 -0
  589. data/vendor/depot_tools/third_party/httplib2/LICENSE +1339 -0
  590. data/vendor/depot_tools/third_party/httplib2/README.chromium +15 -0
  591. data/vendor/depot_tools/third_party/httplib2/__init__.py +1780 -0
  592. data/vendor/depot_tools/third_party/httplib2/cacerts.txt +2196 -0
  593. data/vendor/depot_tools/third_party/httplib2/iri2uri.py +110 -0
  594. data/vendor/depot_tools/third_party/httplib2/socks.py +448 -0
  595. data/vendor/depot_tools/third_party/repo/COPYING +202 -0
  596. data/vendor/depot_tools/third_party/repo/README.chromium +4 -0
  597. data/vendor/depot_tools/third_party/repo/__init__.py +0 -0
  598. data/vendor/depot_tools/third_party/repo/progress.py +117 -0
  599. data/vendor/depot_tools/third_party/retry_decorator/LICENSE.google +30 -0
  600. data/vendor/depot_tools/third_party/retry_decorator/__init__.py +0 -0
  601. data/vendor/depot_tools/third_party/retry_decorator/decorators.py +45 -0
  602. data/vendor/depot_tools/third_party/schema/.editorconfig +15 -0
  603. data/vendor/depot_tools/third_party/schema/.gitignore +174 -0
  604. data/vendor/depot_tools/third_party/schema/.travis.yml +37 -0
  605. data/vendor/depot_tools/third_party/schema/LICENSE-MIT +19 -0
  606. data/vendor/depot_tools/third_party/schema/MANIFEST.in +1 -0
  607. data/vendor/depot_tools/third_party/schema/README.chromium +12 -0
  608. data/vendor/depot_tools/third_party/schema/README.rst +382 -0
  609. data/vendor/depot_tools/third_party/schema/__init__.py +1 -0
  610. data/vendor/depot_tools/third_party/schema/schema.py +338 -0
  611. data/vendor/depot_tools/third_party/schema/setup.cfg +5 -0
  612. data/vendor/depot_tools/third_party/schema/setup.py +30 -0
  613. data/vendor/depot_tools/third_party/schema/test_schema.py +556 -0
  614. data/vendor/depot_tools/third_party/schema/tox.ini +33 -0
  615. data/vendor/depot_tools/third_party/six/LICENSE.txt +18 -0
  616. data/vendor/depot_tools/third_party/six/README.chromium +10 -0
  617. data/vendor/depot_tools/third_party/six/__init__.py +762 -0
  618. data/vendor/depot_tools/update_depot_tools +138 -0
  619. data/vendor/depot_tools/update_depot_tools.bat +65 -0
  620. data/vendor/depot_tools/update_depot_tools_toggle.py +38 -0
  621. data/vendor/depot_tools/upload_metrics.py +26 -0
  622. data/vendor/depot_tools/upload_to_google_storage.py +306 -0
  623. data/vendor/depot_tools/vpython +42 -0
  624. data/vendor/depot_tools/vpython.bat +7 -0
  625. data/vendor/depot_tools/vpython3 +55 -0
  626. data/vendor/depot_tools/vpython3.bat +12 -0
  627. data/vendor/depot_tools/watchlists.py +141 -0
  628. data/vendor/depot_tools/weekly +54 -0
  629. data/vendor/depot_tools/win32imports.py +61 -0
  630. data/vendor/depot_tools/win_toolchain/OWNERS +2 -0
  631. data/vendor/depot_tools/win_toolchain/README.md +74 -0
  632. data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +599 -0
  633. data/vendor/depot_tools/win_toolchain/package_from_installed.py +524 -0
  634. data/vendor/depot_tools/wtf +81 -0
  635. data/vendor/depot_tools/yapf +21 -0
  636. data/vendor/depot_tools/yapf.bat +12 -0
  637. data/vendor/depot_tools/zsh-goodies/README +6 -0
  638. data/vendor/depot_tools/zsh-goodies/_gclient +14 -0
  639. metadata +729 -0
@@ -0,0 +1,152 @@
1
+ # Copyright 2019 The Chromium Authors. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ # This file is imported by various thin wrappers (around gn, clang-format, ...),
6
+ # so it's meant to import very quickly. To keep it that way don't add more
7
+ # code, and even more importantly don't add more toplevel import statements,
8
+ # particularly for modules that are not builtin (see sys.builtin_modules_names,
9
+ # os isn't built in, but it's essential to this file).
10
+
11
+ from __future__ import print_function
12
+
13
+ import gclient_utils
14
+ import logging
15
+ import os
16
+ import subprocess2
17
+ import sys
18
+
19
+
20
+ def FindGclientRoot(from_dir, filename='.gclient'):
21
+ """Tries to find the gclient root."""
22
+ real_from_dir = os.path.realpath(from_dir)
23
+ path = real_from_dir
24
+ while not os.path.exists(os.path.join(path, filename)):
25
+ split_path = os.path.split(path)
26
+ if not split_path[1]:
27
+ return None
28
+ path = split_path[0]
29
+
30
+ logging.info('Found gclient root at ' + path)
31
+
32
+ if path == real_from_dir:
33
+ return path
34
+
35
+ # If we did not find the file in the current directory, make sure we are in a
36
+ # sub directory that is controlled by this configuration.
37
+ entries_filename = os.path.join(path, filename + '_entries')
38
+ if not os.path.exists(entries_filename):
39
+ # If .gclient_entries does not exist, a previous call to gclient sync
40
+ # might have failed. In that case, we cannot verify that the .gclient
41
+ # is the one we want to use. In order to not to cause too much trouble,
42
+ # just issue a warning and return the path anyway.
43
+ print(
44
+ "%s missing, %s file in parent directory %s might not be the file "
45
+ "you want to use." % (entries_filename, filename, path),
46
+ file=sys.stderr)
47
+ return path
48
+
49
+ entries_content = gclient_utils.FileRead(entries_filename)
50
+ scope = {}
51
+ try:
52
+ exec(entries_content, scope)
53
+ except (SyntaxError, Exception) as e:
54
+ gclient_utils.SyntaxErrorToError(filename, e)
55
+
56
+ all_directories = scope['entries'].keys()
57
+ path_to_check = os.path.relpath(real_from_dir, path)
58
+ while path_to_check:
59
+ if path_to_check in all_directories:
60
+ return path
61
+ path_to_check = os.path.dirname(path_to_check)
62
+
63
+ return None
64
+
65
+
66
+ def GetPrimarySolutionPath():
67
+ """Returns the full path to the primary solution. (gclient_root + src)"""
68
+
69
+ gclient_root = FindGclientRoot(os.getcwd())
70
+ if gclient_root:
71
+ # Some projects' top directory is not named 'src'.
72
+ source_dir_name = GetGClientPrimarySolutionName(gclient_root) or 'src'
73
+ return os.path.join(gclient_root, source_dir_name)
74
+
75
+ # Some projects might not use .gclient. Try to see whether we're in a git
76
+ # checkout that contains a 'buildtools' subdir.
77
+ top_dir = os.getcwd()
78
+ try:
79
+ top_dir = subprocess2.check_output(
80
+ ['git', 'rev-parse', '--show-toplevel'])
81
+ if sys.version_info.major == 3:
82
+ top_dir = top_dir.decode('utf-8', 'replace')
83
+ top_dir = os.path.normpath(top_dir.strip())
84
+ except subprocess2.CalledProcessError:
85
+ pass
86
+
87
+ if os.path.exists(os.path.join(top_dir, 'buildtools')):
88
+ return top_dir
89
+ return None
90
+
91
+
92
+ def GetBuildtoolsPath():
93
+ """Returns the full path to the buildtools directory.
94
+ This is based on the root of the checkout containing the current directory."""
95
+
96
+ # Overriding the build tools path by environment is highly unsupported and may
97
+ # break without warning. Do not rely on this for anything important.
98
+ override = os.environ.get('CHROMIUM_BUILDTOOLS_PATH')
99
+ if override is not None:
100
+ return override
101
+
102
+ primary_solution = GetPrimarySolutionPath()
103
+ if not primary_solution:
104
+ return None
105
+
106
+ buildtools_path = os.path.join(primary_solution, 'buildtools')
107
+ if os.path.exists(buildtools_path):
108
+ return buildtools_path
109
+
110
+ # buildtools may be in the gclient root.
111
+ gclient_root = FindGclientRoot(os.getcwd())
112
+ buildtools_path = os.path.join(gclient_root, 'buildtools')
113
+ if os.path.exists(buildtools_path):
114
+ return buildtools_path
115
+
116
+ return None
117
+
118
+
119
+ def GetBuildtoolsPlatformBinaryPath():
120
+ """Returns the full path to the binary directory for the current platform."""
121
+ buildtools_path = GetBuildtoolsPath()
122
+ if not buildtools_path:
123
+ return None
124
+
125
+ if sys.platform.startswith(('cygwin', 'win')):
126
+ subdir = 'win'
127
+ elif sys.platform == 'darwin':
128
+ subdir = 'mac'
129
+ elif sys.platform.startswith('linux'):
130
+ subdir = 'linux64'
131
+ else:
132
+ raise gclient_utils.Error('Unknown platform: ' + sys.platform)
133
+ return os.path.join(buildtools_path, subdir)
134
+
135
+
136
+ def GetExeSuffix():
137
+ """Returns '' or '.exe' depending on how executables work on this platform."""
138
+ if sys.platform.startswith(('cygwin', 'win')):
139
+ return '.exe'
140
+ return ''
141
+
142
+
143
+ def GetGClientPrimarySolutionName(gclient_root_dir_path):
144
+ """Returns the name of the primary solution in the .gclient file specified."""
145
+ gclient_config_file = os.path.join(gclient_root_dir_path, '.gclient')
146
+ gclient_config_contents = gclient_utils.FileRead(gclient_config_file)
147
+ env = {}
148
+ exec(gclient_config_contents, env)
149
+ solutions = env.get('solutions', [])
150
+ if solutions:
151
+ return solutions[0].get('name')
152
+ return None
@@ -0,0 +1,1615 @@
1
+ # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ """Gclient-specific SCM-specific operations."""
6
+
7
+ from __future__ import print_function
8
+
9
+ import collections
10
+ import contextlib
11
+ import errno
12
+ import json
13
+ import logging
14
+ import os
15
+ import posixpath
16
+ import re
17
+ import sys
18
+ import tempfile
19
+ import threading
20
+ import traceback
21
+
22
+ try:
23
+ import urlparse
24
+ except ImportError: # For Py3 compatibility
25
+ import urllib.parse as urlparse
26
+
27
+ import gclient_utils
28
+ import git_cache
29
+ import scm
30
+ import shutil
31
+ import subprocess2
32
+
33
+
34
+ THIS_FILE_PATH = os.path.abspath(__file__)
35
+
36
+ GSUTIL_DEFAULT_PATH = os.path.join(
37
+ os.path.dirname(os.path.abspath(__file__)), 'gsutil.py')
38
+
39
+
40
+ class NoUsableRevError(gclient_utils.Error):
41
+ """Raised if requested revision isn't found in checkout."""
42
+
43
+
44
+ class DiffFiltererWrapper(object):
45
+ """Simple base class which tracks which file is being diffed and
46
+ replaces instances of its file name in the original and
47
+ working copy lines of the git diff output."""
48
+ index_string = None
49
+ original_prefix = "--- "
50
+ working_prefix = "+++ "
51
+
52
+ def __init__(self, relpath, print_func):
53
+ # Note that we always use '/' as the path separator to be
54
+ # consistent with cygwin-style output on Windows
55
+ self._relpath = relpath.replace("\\", "/")
56
+ self._current_file = None
57
+ self._print_func = print_func
58
+
59
+ def SetCurrentFile(self, current_file):
60
+ self._current_file = current_file
61
+
62
+ @property
63
+ def _replacement_file(self):
64
+ return posixpath.join(self._relpath, self._current_file)
65
+
66
+ def _Replace(self, line):
67
+ return line.replace(self._current_file, self._replacement_file)
68
+
69
+ def Filter(self, line):
70
+ if (line.startswith(self.index_string)):
71
+ self.SetCurrentFile(line[len(self.index_string):])
72
+ line = self._Replace(line)
73
+ else:
74
+ if (line.startswith(self.original_prefix) or
75
+ line.startswith(self.working_prefix)):
76
+ line = self._Replace(line)
77
+ self._print_func(line)
78
+
79
+
80
+ class GitDiffFilterer(DiffFiltererWrapper):
81
+ index_string = "diff --git "
82
+
83
+ def SetCurrentFile(self, current_file):
84
+ # Get filename by parsing "a/<filename> b/<filename>"
85
+ self._current_file = current_file[:(len(current_file)/2)][2:]
86
+
87
+ def _Replace(self, line):
88
+ return re.sub("[a|b]/" + self._current_file, self._replacement_file, line)
89
+
90
+
91
+ # SCMWrapper base class
92
+
93
+ class SCMWrapper(object):
94
+ """Add necessary glue between all the supported SCM.
95
+
96
+ This is the abstraction layer to bind to different SCM.
97
+ """
98
+ def __init__(self, url=None, root_dir=None, relpath=None, out_fh=None,
99
+ out_cb=None, print_outbuf=False):
100
+ self.url = url
101
+ self._root_dir = root_dir
102
+ if self._root_dir:
103
+ self._root_dir = self._root_dir.replace('/', os.sep)
104
+ self.relpath = relpath
105
+ if self.relpath:
106
+ self.relpath = self.relpath.replace('/', os.sep)
107
+ if self.relpath and self._root_dir:
108
+ self.checkout_path = os.path.join(self._root_dir, self.relpath)
109
+ if out_fh is None:
110
+ out_fh = sys.stdout
111
+ self.out_fh = out_fh
112
+ self.out_cb = out_cb
113
+ self.print_outbuf = print_outbuf
114
+
115
+ def Print(self, *args, **kwargs):
116
+ kwargs.setdefault('file', self.out_fh)
117
+ if kwargs.pop('timestamp', True):
118
+ self.out_fh.write('[%s] ' % gclient_utils.Elapsed())
119
+ print(*args, **kwargs)
120
+
121
+ def RunCommand(self, command, options, args, file_list=None):
122
+ commands = ['update', 'updatesingle', 'revert',
123
+ 'revinfo', 'status', 'diff', 'pack', 'runhooks']
124
+
125
+ if not command in commands:
126
+ raise gclient_utils.Error('Unknown command %s' % command)
127
+
128
+ if not command in dir(self):
129
+ raise gclient_utils.Error('Command %s not implemented in %s wrapper' % (
130
+ command, self.__class__.__name__))
131
+
132
+ return getattr(self, command)(options, args, file_list)
133
+
134
+ @staticmethod
135
+ def _get_first_remote_url(checkout_path):
136
+ log = scm.GIT.Capture(
137
+ ['config', '--local', '--get-regexp', r'remote.*.url'],
138
+ cwd=checkout_path)
139
+ # Get the second token of the first line of the log.
140
+ return log.splitlines()[0].split(' ', 1)[1]
141
+
142
+ def GetCacheMirror(self):
143
+ if getattr(self, 'cache_dir', None):
144
+ url, _ = gclient_utils.SplitUrlRevision(self.url)
145
+ return git_cache.Mirror(url)
146
+ return None
147
+
148
+ def GetActualRemoteURL(self, options):
149
+ """Attempt to determine the remote URL for this SCMWrapper."""
150
+ # Git
151
+ if os.path.exists(os.path.join(self.checkout_path, '.git')):
152
+ actual_remote_url = self._get_first_remote_url(self.checkout_path)
153
+
154
+ mirror = self.GetCacheMirror()
155
+ # If the cache is used, obtain the actual remote URL from there.
156
+ if (mirror and mirror.exists() and
157
+ mirror.mirror_path.replace('\\', '/') ==
158
+ actual_remote_url.replace('\\', '/')):
159
+ actual_remote_url = self._get_first_remote_url(mirror.mirror_path)
160
+ return actual_remote_url
161
+ return None
162
+
163
+ def DoesRemoteURLMatch(self, options):
164
+ """Determine whether the remote URL of this checkout is the expected URL."""
165
+ if not os.path.exists(self.checkout_path):
166
+ # A checkout which doesn't exist can't be broken.
167
+ return True
168
+
169
+ actual_remote_url = self.GetActualRemoteURL(options)
170
+ if actual_remote_url:
171
+ return (gclient_utils.SplitUrlRevision(actual_remote_url)[0].rstrip('/')
172
+ == gclient_utils.SplitUrlRevision(self.url)[0].rstrip('/'))
173
+ else:
174
+ # This may occur if the self.checkout_path exists but does not contain a
175
+ # valid git checkout.
176
+ return False
177
+
178
+ def _DeleteOrMove(self, force):
179
+ """Delete the checkout directory or move it out of the way.
180
+
181
+ Args:
182
+ force: bool; if True, delete the directory. Otherwise, just move it.
183
+ """
184
+ if force and os.environ.get('CHROME_HEADLESS') == '1':
185
+ self.Print('_____ Conflicting directory found in %s. Removing.'
186
+ % self.checkout_path)
187
+ gclient_utils.AddWarning('Conflicting directory %s deleted.'
188
+ % self.checkout_path)
189
+ gclient_utils.rmtree(self.checkout_path)
190
+ else:
191
+ bad_scm_dir = os.path.join(self._root_dir, '_bad_scm',
192
+ os.path.dirname(self.relpath))
193
+
194
+ try:
195
+ os.makedirs(bad_scm_dir)
196
+ except OSError as e:
197
+ if e.errno != errno.EEXIST:
198
+ raise
199
+
200
+ dest_path = tempfile.mkdtemp(
201
+ prefix=os.path.basename(self.relpath),
202
+ dir=bad_scm_dir)
203
+ self.Print('_____ Conflicting directory found in %s. Moving to %s.'
204
+ % (self.checkout_path, dest_path))
205
+ gclient_utils.AddWarning('Conflicting directory %s moved to %s.'
206
+ % (self.checkout_path, dest_path))
207
+ shutil.move(self.checkout_path, dest_path)
208
+
209
+
210
+ class GitWrapper(SCMWrapper):
211
+ """Wrapper for Git"""
212
+ name = 'git'
213
+ remote = 'origin'
214
+
215
+ @property
216
+ def cache_dir(self):
217
+ try:
218
+ return git_cache.Mirror.GetCachePath()
219
+ except RuntimeError:
220
+ return None
221
+
222
+ def __init__(self, url=None, *args, **kwargs):
223
+ """Removes 'git+' fake prefix from git URL."""
224
+ if url and (url.startswith('git+http://') or
225
+ url.startswith('git+https://')):
226
+ url = url[4:]
227
+ SCMWrapper.__init__(self, url, *args, **kwargs)
228
+ filter_kwargs = { 'time_throttle': 1, 'out_fh': self.out_fh }
229
+ if self.out_cb:
230
+ filter_kwargs['predicate'] = self.out_cb
231
+ self.filter = gclient_utils.GitFilter(**filter_kwargs)
232
+ self._running_under_rosetta = None
233
+
234
+ def GetCheckoutRoot(self):
235
+ return scm.GIT.GetCheckoutRoot(self.checkout_path)
236
+
237
+ def GetRevisionDate(self, _revision):
238
+ """Returns the given revision's date in ISO-8601 format (which contains the
239
+ time zone)."""
240
+ # TODO(floitsch): get the time-stamp of the given revision and not just the
241
+ # time-stamp of the currently checked out revision.
242
+ return self._Capture(['log', '-n', '1', '--format=%ai'])
243
+
244
+ def _GetDiffFilenames(self, base):
245
+ """Returns the names of files modified since base."""
246
+ return self._Capture(
247
+ # Filter to remove base if it is None.
248
+ list(filter(bool, ['-c', 'core.quotePath=false', 'diff', '--name-only',
249
+ base])
250
+ )).split()
251
+
252
+ def diff(self, options, _args, _file_list):
253
+ _, revision = gclient_utils.SplitUrlRevision(self.url)
254
+ if not revision:
255
+ revision = 'refs/remotes/%s/master' % self.remote
256
+ self._Run(['-c', 'core.quotePath=false', 'diff', revision], options)
257
+
258
+ def pack(self, _options, _args, _file_list):
259
+ """Generates a patch file which can be applied to the root of the
260
+ repository.
261
+
262
+ The patch file is generated from a diff of the merge base of HEAD and
263
+ its upstream branch.
264
+ """
265
+ try:
266
+ merge_base = [self._Capture(['merge-base', 'HEAD', self.remote])]
267
+ except subprocess2.CalledProcessError:
268
+ merge_base = []
269
+ gclient_utils.CheckCallAndFilter(
270
+ ['git', 'diff'] + merge_base,
271
+ cwd=self.checkout_path,
272
+ filter_fn=GitDiffFilterer(self.relpath, print_func=self.Print).Filter)
273
+
274
+ def _Scrub(self, target, options):
275
+ """Scrubs out all changes in the local repo, back to the state of target."""
276
+ quiet = []
277
+ if not options.verbose:
278
+ quiet = ['--quiet']
279
+ self._Run(['reset', '--hard', target] + quiet, options)
280
+ if options.force and options.delete_unversioned_trees:
281
+ # where `target` is a commit that contains both upper and lower case
282
+ # versions of the same file on a case insensitive filesystem, we are
283
+ # actually in a broken state here. The index will have both 'a' and 'A',
284
+ # but only one of them will exist on the disk. To progress, we delete
285
+ # everything that status thinks is modified.
286
+ output = self._Capture([
287
+ '-c', 'core.quotePath=false', 'status', '--porcelain'], strip=False)
288
+ for line in output.splitlines():
289
+ # --porcelain (v1) looks like:
290
+ # XY filename
291
+ try:
292
+ filename = line[3:]
293
+ self.Print('_____ Deleting residual after reset: %r.' % filename)
294
+ gclient_utils.rm_file_or_tree(
295
+ os.path.join(self.checkout_path, filename))
296
+ except OSError:
297
+ pass
298
+
299
+ def _FetchAndReset(self, revision, file_list, options):
300
+ """Equivalent to git fetch; git reset."""
301
+ self._SetFetchConfig(options)
302
+
303
+ self._Fetch(options, prune=True, quiet=options.verbose)
304
+ self._Scrub(revision, options)
305
+ if file_list is not None:
306
+ files = self._Capture(
307
+ ['-c', 'core.quotePath=false', 'ls-files']).splitlines()
308
+ file_list.extend(
309
+ [os.path.join(self.checkout_path, f) for f in files])
310
+
311
+ def _DisableHooks(self):
312
+ hook_dir = os.path.join(self.checkout_path, '.git', 'hooks')
313
+ if not os.path.isdir(hook_dir):
314
+ return
315
+ for f in os.listdir(hook_dir):
316
+ if not f.endswith('.sample') and not f.endswith('.disabled'):
317
+ disabled_hook_path = os.path.join(hook_dir, f + '.disabled')
318
+ if os.path.exists(disabled_hook_path):
319
+ os.remove(disabled_hook_path)
320
+ os.rename(os.path.join(hook_dir, f), disabled_hook_path)
321
+
322
+ def _maybe_break_locks(self, options):
323
+ """This removes all .lock files from this repo's .git directory, if the
324
+ user passed the --break_repo_locks command line flag.
325
+
326
+ In particular, this will cleanup index.lock files, as well as ref lock
327
+ files.
328
+ """
329
+ if options.break_repo_locks:
330
+ git_dir = os.path.join(self.checkout_path, '.git')
331
+ for path, _, filenames in os.walk(git_dir):
332
+ for filename in filenames:
333
+ if filename.endswith('.lock'):
334
+ to_break = os.path.join(path, filename)
335
+ self.Print('breaking lock: %s' % (to_break,))
336
+ try:
337
+ os.remove(to_break)
338
+ except OSError as ex:
339
+ self.Print('FAILED to break lock: %s: %s' % (to_break, ex))
340
+ raise
341
+
342
+ def apply_patch_ref(self, patch_repo, patch_rev, target_rev, options,
343
+ file_list):
344
+ """Apply a patch on top of the revision we're synced at.
345
+
346
+ The patch ref is given by |patch_repo|@|patch_rev|.
347
+ |target_rev| is usually the branch that the |patch_rev| was uploaded against
348
+ (e.g. 'refs/heads/master'), but this is not required.
349
+
350
+ We cherry-pick all commits reachable from |patch_rev| on top of the curret
351
+ HEAD, excluding those reachable from |target_rev|
352
+ (i.e. git cherry-pick target_rev..patch_rev).
353
+
354
+ Graphically, it looks like this:
355
+
356
+ ... -> o -> [possibly already landed commits] -> target_rev
357
+ \
358
+ -> [possibly not yet landed dependent CLs] -> patch_rev
359
+
360
+ The final checkout state is then:
361
+
362
+ ... -> HEAD -> [possibly not yet landed dependent CLs] -> patch_rev
363
+
364
+ After application, if |options.reset_patch_ref| is specified, we soft reset
365
+ the cherry-picked changes, keeping them in git index only.
366
+
367
+ Args:
368
+ patch_repo: The patch origin.
369
+ e.g. 'https://foo.googlesource.com/bar'
370
+ patch_rev: The revision to patch.
371
+ e.g. 'refs/changes/1234/34/1'.
372
+ target_rev: The revision to use when finding the merge base.
373
+ Typically, the branch that the patch was uploaded against.
374
+ e.g. 'refs/heads/master' or 'refs/heads/infra/config'.
375
+ options: The options passed to gclient.
376
+ file_list: A list where modified files will be appended.
377
+ """
378
+
379
+ # Abort any cherry-picks in progress.
380
+ try:
381
+ self._Capture(['cherry-pick', '--abort'])
382
+ except subprocess2.CalledProcessError:
383
+ pass
384
+
385
+ base_rev = self._Capture(['rev-parse', 'HEAD'])
386
+
387
+ if not target_rev:
388
+ raise gclient_utils.Error('A target revision for the patch must be given')
389
+ elif target_rev.startswith('refs/heads/'):
390
+ # If |target_rev| is in refs/heads/**, try first to find the corresponding
391
+ # remote ref for it, since |target_rev| might point to a local ref which
392
+ # is not up to date with the corresponding remote ref.
393
+ remote_ref = ''.join(scm.GIT.RefToRemoteRef(target_rev, self.remote))
394
+ self.Print('Trying the corresponding remote ref for %r: %r\n' % (
395
+ target_rev, remote_ref))
396
+ if scm.GIT.IsValidRevision(self.checkout_path, remote_ref):
397
+ target_rev = remote_ref
398
+ elif not scm.GIT.IsValidRevision(self.checkout_path, target_rev):
399
+ # Fetch |target_rev| if it's not already available.
400
+ url, _ = gclient_utils.SplitUrlRevision(self.url)
401
+ mirror = self._GetMirror(url, options, target_rev)
402
+ if mirror:
403
+ rev_type = 'branch' if target_rev.startswith('refs/') else 'hash'
404
+ self._UpdateMirrorIfNotContains(mirror, options, rev_type, target_rev)
405
+ self._Fetch(options, refspec=target_rev)
406
+
407
+ self.Print('===Applying patch===')
408
+ self.Print('Revision to patch is %r @ %r.' % (patch_repo, patch_rev))
409
+ self.Print('Current dir is %r' % self.checkout_path)
410
+ self._Capture(['reset', '--hard'])
411
+ self._Capture(['fetch', '--no-tags', patch_repo, patch_rev])
412
+ patch_rev = self._Capture(['rev-parse', 'FETCH_HEAD'])
413
+
414
+ if not options.rebase_patch_ref:
415
+ self._Capture(['checkout', patch_rev])
416
+ # Adjust base_rev to be the first parent of our checked out patch ref;
417
+ # This will allow us to correctly extend `file_list`, and will show the
418
+ # correct file-list to programs which do `git diff --cached` expecting to
419
+ # see the patch diff.
420
+ base_rev = self._Capture(['rev-parse', patch_rev+'~'])
421
+
422
+ else:
423
+ self.Print('Will cherrypick %r .. %r on top of %r.' % (
424
+ target_rev, patch_rev, base_rev))
425
+ try:
426
+ if scm.GIT.IsAncestor(self.checkout_path, patch_rev, target_rev):
427
+ # If |patch_rev| is an ancestor of |target_rev|, check it out.
428
+ self._Capture(['checkout', patch_rev])
429
+ else:
430
+ # If a change was uploaded on top of another change, which has already
431
+ # landed, one of the commits in the cherry-pick range will be
432
+ # redundant, since it has already landed and its changes incorporated
433
+ # in the tree.
434
+ # We pass '--keep-redundant-commits' to ignore those changes.
435
+ self._Capture(['cherry-pick', target_rev + '..' + patch_rev,
436
+ '--keep-redundant-commits'])
437
+
438
+ except subprocess2.CalledProcessError as e:
439
+ self.Print('Failed to apply patch.')
440
+ self.Print('Revision to patch was %r @ %r.' % (patch_repo, patch_rev))
441
+ self.Print('Tried to cherrypick %r .. %r on top of %r.' % (
442
+ target_rev, patch_rev, base_rev))
443
+ self.Print('Current dir is %r' % self.checkout_path)
444
+ self.Print('git returned non-zero exit status %s:\n%s' % (
445
+ e.returncode, e.stderr.decode('utf-8')))
446
+ # Print the current status so that developers know what changes caused
447
+ # the patch failure, since git cherry-pick doesn't show that
448
+ # information.
449
+ self.Print(self._Capture(['status']))
450
+ try:
451
+ self._Capture(['cherry-pick', '--abort'])
452
+ except subprocess2.CalledProcessError:
453
+ pass
454
+ raise
455
+
456
+ if file_list is not None:
457
+ file_list.extend(self._GetDiffFilenames(base_rev))
458
+
459
+ if options.reset_patch_ref:
460
+ self._Capture(['reset', '--soft', base_rev])
461
+
462
+ def update(self, options, args, file_list):
463
+ """Runs git to update or transparently checkout the working copy.
464
+
465
+ All updated files will be appended to file_list.
466
+
467
+ Raises:
468
+ Error: if can't get URL for relative path.
469
+ """
470
+ if args:
471
+ raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args))
472
+
473
+ self._CheckMinVersion("1.6.6")
474
+
475
+ # If a dependency is not pinned, track the default remote branch.
476
+ default_rev = 'refs/remotes/%s/master' % self.remote
477
+ url, deps_revision = gclient_utils.SplitUrlRevision(self.url)
478
+ revision = deps_revision
479
+ managed = True
480
+ if options.revision:
481
+ # Override the revision number.
482
+ revision = str(options.revision)
483
+ if revision == 'unmanaged':
484
+ # Check again for a revision in case an initial ref was specified
485
+ # in the url, for example bla.git@refs/heads/custombranch
486
+ revision = deps_revision
487
+ managed = False
488
+ if not revision:
489
+ revision = default_rev
490
+
491
+ if managed:
492
+ self._DisableHooks()
493
+
494
+ printed_path = False
495
+ verbose = []
496
+ if options.verbose:
497
+ self.Print('_____ %s at %s' % (self.relpath, revision), timestamp=False)
498
+ verbose = ['--verbose']
499
+ printed_path = True
500
+
501
+ revision_ref = revision
502
+ if ':' in revision:
503
+ revision_ref, _, revision = revision.partition(':')
504
+
505
+ if revision_ref.startswith('refs/branch-heads'):
506
+ options.with_branch_heads = True
507
+
508
+ mirror = self._GetMirror(url, options, revision_ref)
509
+ if mirror:
510
+ url = mirror.mirror_path
511
+
512
+ remote_ref = scm.GIT.RefToRemoteRef(revision, self.remote)
513
+ if remote_ref:
514
+ # Rewrite remote refs to their local equivalents.
515
+ revision = ''.join(remote_ref)
516
+ rev_type = "branch"
517
+ elif revision.startswith('refs/'):
518
+ # Local branch? We probably don't want to support, since DEPS should
519
+ # always specify branches as they are in the upstream repo.
520
+ rev_type = "branch"
521
+ else:
522
+ # hash is also a tag, only make a distinction at checkout
523
+ rev_type = "hash"
524
+
525
+ # If we are going to introduce a new project, there is a possibility that
526
+ # we are syncing back to a state where the project was originally a
527
+ # sub-project rolled by DEPS (realistic case: crossing the Blink merge point
528
+ # syncing backwards, when Blink was a DEPS entry and not part of src.git).
529
+ # In such case, we might have a backup of the former .git folder, which can
530
+ # be used to avoid re-fetching the entire repo again (useful for bisects).
531
+ backup_dir = self.GetGitBackupDirPath()
532
+ target_dir = os.path.join(self.checkout_path, '.git')
533
+ if os.path.exists(backup_dir) and not os.path.exists(target_dir):
534
+ gclient_utils.safe_makedirs(self.checkout_path)
535
+ os.rename(backup_dir, target_dir)
536
+ # Reset to a clean state
537
+ self._Scrub('HEAD', options)
538
+
539
+ if (not os.path.exists(self.checkout_path) or
540
+ (os.path.isdir(self.checkout_path) and
541
+ not os.path.exists(os.path.join(self.checkout_path, '.git')))):
542
+ if mirror:
543
+ self._UpdateMirrorIfNotContains(mirror, options, rev_type, revision)
544
+ try:
545
+ self._Clone(revision, url, options)
546
+ except subprocess2.CalledProcessError:
547
+ self._DeleteOrMove(options.force)
548
+ self._Clone(revision, url, options)
549
+ if file_list is not None:
550
+ files = self._Capture(
551
+ ['-c', 'core.quotePath=false', 'ls-files']).splitlines()
552
+ file_list.extend(
553
+ [os.path.join(self.checkout_path, f) for f in files])
554
+ if mirror:
555
+ self._Capture(
556
+ ['remote', 'set-url', '--push', 'origin', mirror.url])
557
+ if not verbose:
558
+ # Make the output a little prettier. It's nice to have some whitespace
559
+ # between projects when cloning.
560
+ self.Print('')
561
+ return self._Capture(['rev-parse', '--verify', 'HEAD'])
562
+
563
+ if mirror:
564
+ self._Capture(
565
+ ['remote', 'set-url', '--push', 'origin', mirror.url])
566
+
567
+ if not managed:
568
+ self._SetFetchConfig(options)
569
+ self.Print('________ unmanaged solution; skipping %s' % self.relpath)
570
+ return self._Capture(['rev-parse', '--verify', 'HEAD'])
571
+
572
+ self._maybe_break_locks(options)
573
+
574
+ if mirror:
575
+ self._UpdateMirrorIfNotContains(mirror, options, rev_type, revision)
576
+
577
+ # See if the url has changed (the unittests use git://foo for the url, let
578
+ # that through).
579
+ current_url = self._Capture(['config', 'remote.%s.url' % self.remote])
580
+ return_early = False
581
+ # TODO(maruel): Delete url != 'git://foo' since it's just to make the
582
+ # unit test pass. (and update the comment above)
583
+ # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set.
584
+ # This allows devs to use experimental repos which have a different url
585
+ # but whose branch(s) are the same as official repos.
586
+ if (current_url.rstrip('/') != url.rstrip('/') and url != 'git://foo' and
587
+ subprocess2.capture(
588
+ ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote],
589
+ cwd=self.checkout_path).strip() != 'False'):
590
+ self.Print('_____ switching %s to a new upstream' % self.relpath)
591
+ if not (options.force or options.reset):
592
+ # Make sure it's clean
593
+ self._CheckClean(revision)
594
+ # Switch over to the new upstream
595
+ self._Run(['remote', 'set-url', self.remote, url], options)
596
+ if mirror:
597
+ with open(os.path.join(
598
+ self.checkout_path, '.git', 'objects', 'info', 'alternates'),
599
+ 'w') as fh:
600
+ fh.write(os.path.join(url, 'objects'))
601
+ self._EnsureValidHeadObjectOrCheckout(revision, options, url)
602
+ self._FetchAndReset(revision, file_list, options)
603
+
604
+ return_early = True
605
+ else:
606
+ self._EnsureValidHeadObjectOrCheckout(revision, options, url)
607
+
608
+ if return_early:
609
+ return self._Capture(['rev-parse', '--verify', 'HEAD'])
610
+
611
+ cur_branch = self._GetCurrentBranch()
612
+
613
+ # Cases:
614
+ # 0) HEAD is detached. Probably from our initial clone.
615
+ # - make sure HEAD is contained by a named ref, then update.
616
+ # Cases 1-4. HEAD is a branch.
617
+ # 1) current branch is not tracking a remote branch
618
+ # - try to rebase onto the new hash or branch
619
+ # 2) current branch is tracking a remote branch with local committed
620
+ # changes, but the DEPS file switched to point to a hash
621
+ # - rebase those changes on top of the hash
622
+ # 3) current branch is tracking a remote branch w/or w/out changes, and
623
+ # no DEPS switch
624
+ # - see if we can FF, if not, prompt the user for rebase, merge, or stop
625
+ # 4) current branch is tracking a remote branch, but DEPS switches to a
626
+ # different remote branch, and
627
+ # a) current branch has no local changes, and --force:
628
+ # - checkout new branch
629
+ # b) current branch has local changes, and --force and --reset:
630
+ # - checkout new branch
631
+ # c) otherwise exit
632
+
633
+ # GetUpstreamBranch returns something like 'refs/remotes/origin/master' for
634
+ # a tracking branch
635
+ # or 'master' if not a tracking branch (it's based on a specific rev/hash)
636
+ # or it returns None if it couldn't find an upstream
637
+ if cur_branch is None:
638
+ upstream_branch = None
639
+ current_type = "detached"
640
+ logging.debug("Detached HEAD")
641
+ else:
642
+ upstream_branch = scm.GIT.GetUpstreamBranch(self.checkout_path)
643
+ if not upstream_branch or not upstream_branch.startswith('refs/remotes'):
644
+ current_type = "hash"
645
+ logging.debug("Current branch is not tracking an upstream (remote)"
646
+ " branch.")
647
+ elif upstream_branch.startswith('refs/remotes'):
648
+ current_type = "branch"
649
+ else:
650
+ raise gclient_utils.Error('Invalid Upstream: %s' % upstream_branch)
651
+
652
+ self._SetFetchConfig(options)
653
+
654
+ # Fetch upstream if we don't already have |revision|.
655
+ if not scm.GIT.IsValidRevision(self.checkout_path, revision, sha_only=True):
656
+ self._Fetch(options, prune=options.force)
657
+
658
+ if not scm.GIT.IsValidRevision(self.checkout_path, revision,
659
+ sha_only=True):
660
+ # Update the remotes first so we have all the refs.
661
+ remote_output = scm.GIT.Capture(['remote'] + verbose + ['update'],
662
+ cwd=self.checkout_path)
663
+ if verbose:
664
+ self.Print(remote_output)
665
+
666
+ revision = self._AutoFetchRef(options, revision)
667
+
668
+ # This is a big hammer, debatable if it should even be here...
669
+ if options.force or options.reset:
670
+ target = 'HEAD'
671
+ if options.upstream and upstream_branch:
672
+ target = upstream_branch
673
+ self._Scrub(target, options)
674
+
675
+ if current_type == 'detached':
676
+ # case 0
677
+ # We just did a Scrub, this is as clean as it's going to get. In
678
+ # particular if HEAD is a commit that contains two versions of the same
679
+ # file on a case-insensitive filesystem (e.g. 'a' and 'A'), there's no way
680
+ # to actually "Clean" the checkout; that commit is uncheckoutable on this
681
+ # system. The best we can do is carry forward to the checkout step.
682
+ if not (options.force or options.reset):
683
+ self._CheckClean(revision)
684
+ self._CheckDetachedHead(revision, options)
685
+ if self._Capture(['rev-list', '-n', '1', 'HEAD']) == revision:
686
+ self.Print('Up-to-date; skipping checkout.')
687
+ else:
688
+ # 'git checkout' may need to overwrite existing untracked files. Allow
689
+ # it only when nuclear options are enabled.
690
+ self._Checkout(
691
+ options,
692
+ revision,
693
+ force=(options.force and options.delete_unversioned_trees),
694
+ quiet=True,
695
+ )
696
+ if not printed_path:
697
+ self.Print('_____ %s at %s' % (self.relpath, revision), timestamp=False)
698
+ elif current_type == 'hash':
699
+ # case 1
700
+ # Can't find a merge-base since we don't know our upstream. That makes
701
+ # this command VERY likely to produce a rebase failure. For now we
702
+ # assume origin is our upstream since that's what the old behavior was.
703
+ upstream_branch = self.remote
704
+ if options.revision or deps_revision:
705
+ upstream_branch = revision
706
+ self._AttemptRebase(upstream_branch, file_list, options,
707
+ printed_path=printed_path, merge=options.merge)
708
+ printed_path = True
709
+ elif rev_type == 'hash':
710
+ # case 2
711
+ self._AttemptRebase(upstream_branch, file_list, options,
712
+ newbase=revision, printed_path=printed_path,
713
+ merge=options.merge)
714
+ printed_path = True
715
+ elif remote_ref and ''.join(remote_ref) != upstream_branch:
716
+ # case 4
717
+ new_base = ''.join(remote_ref)
718
+ if not printed_path:
719
+ self.Print('_____ %s at %s' % (self.relpath, revision), timestamp=False)
720
+ switch_error = ("Could not switch upstream branch from %s to %s\n"
721
+ % (upstream_branch, new_base) +
722
+ "Please use --force or merge or rebase manually:\n" +
723
+ "cd %s; git rebase %s\n" % (self.checkout_path, new_base) +
724
+ "OR git checkout -b <some new branch> %s" % new_base)
725
+ force_switch = False
726
+ if options.force:
727
+ try:
728
+ self._CheckClean(revision)
729
+ # case 4a
730
+ force_switch = True
731
+ except gclient_utils.Error as e:
732
+ if options.reset:
733
+ # case 4b
734
+ force_switch = True
735
+ else:
736
+ switch_error = '%s\n%s' % (e.message, switch_error)
737
+ if force_switch:
738
+ self.Print("Switching upstream branch from %s to %s" %
739
+ (upstream_branch, new_base))
740
+ switch_branch = 'gclient_' + remote_ref[1]
741
+ self._Capture(['branch', '-f', switch_branch, new_base])
742
+ self._Checkout(options, switch_branch, force=True, quiet=True)
743
+ else:
744
+ # case 4c
745
+ raise gclient_utils.Error(switch_error)
746
+ else:
747
+ # case 3 - the default case
748
+ rebase_files = self._GetDiffFilenames(upstream_branch)
749
+ if verbose:
750
+ self.Print('Trying fast-forward merge to branch : %s' % upstream_branch)
751
+ try:
752
+ merge_args = ['merge']
753
+ if options.merge:
754
+ merge_args.append('--ff')
755
+ else:
756
+ merge_args.append('--ff-only')
757
+ merge_args.append(upstream_branch)
758
+ merge_output = self._Capture(merge_args)
759
+ except subprocess2.CalledProcessError as e:
760
+ rebase_files = []
761
+ if re.match(b'fatal: Not possible to fast-forward, aborting.',
762
+ e.stderr):
763
+ if not printed_path:
764
+ self.Print('_____ %s at %s' % (self.relpath, revision),
765
+ timestamp=False)
766
+ printed_path = True
767
+ while True:
768
+ if not options.auto_rebase:
769
+ try:
770
+ action = self._AskForData(
771
+ 'Cannot %s, attempt to rebase? '
772
+ '(y)es / (q)uit / (s)kip : ' %
773
+ ('merge' if options.merge else 'fast-forward merge'),
774
+ options)
775
+ except ValueError:
776
+ raise gclient_utils.Error('Invalid Character')
777
+ if options.auto_rebase or re.match(r'yes|y', action, re.I):
778
+ self._AttemptRebase(upstream_branch, rebase_files, options,
779
+ printed_path=printed_path, merge=False)
780
+ printed_path = True
781
+ break
782
+ elif re.match(r'quit|q', action, re.I):
783
+ raise gclient_utils.Error("Can't fast-forward, please merge or "
784
+ "rebase manually.\n"
785
+ "cd %s && git " % self.checkout_path
786
+ + "rebase %s" % upstream_branch)
787
+ elif re.match(r'skip|s', action, re.I):
788
+ self.Print('Skipping %s' % self.relpath)
789
+ return
790
+ else:
791
+ self.Print('Input not recognized')
792
+ elif re.match(b"error: Your local changes to '.*' would be "
793
+ b"overwritten by merge. Aborting.\nPlease, commit your "
794
+ b"changes or stash them before you can merge.\n",
795
+ e.stderr):
796
+ if not printed_path:
797
+ self.Print('_____ %s at %s' % (self.relpath, revision),
798
+ timestamp=False)
799
+ printed_path = True
800
+ raise gclient_utils.Error(e.stderr.decode('utf-8'))
801
+ else:
802
+ # Some other problem happened with the merge
803
+ logging.error("Error during fast-forward merge in %s!" % self.relpath)
804
+ self.Print(e.stderr.decode('utf-8'))
805
+ raise
806
+ else:
807
+ # Fast-forward merge was successful
808
+ if not re.match('Already up-to-date.', merge_output) or verbose:
809
+ if not printed_path:
810
+ self.Print('_____ %s at %s' % (self.relpath, revision),
811
+ timestamp=False)
812
+ printed_path = True
813
+ self.Print(merge_output.strip())
814
+ if not verbose:
815
+ # Make the output a little prettier. It's nice to have some
816
+ # whitespace between projects when syncing.
817
+ self.Print('')
818
+
819
+ if file_list is not None:
820
+ file_list.extend(
821
+ [os.path.join(self.checkout_path, f) for f in rebase_files])
822
+
823
+ # If the rebase generated a conflict, abort and ask user to fix
824
+ if self._IsRebasing():
825
+ raise gclient_utils.Error('\n____ %s at %s\n'
826
+ '\nConflict while rebasing this branch.\n'
827
+ 'Fix the conflict and run gclient again.\n'
828
+ 'See man git-rebase for details.\n'
829
+ % (self.relpath, revision))
830
+
831
+ if verbose:
832
+ self.Print('Checked out revision %s' % self.revinfo(options, (), None),
833
+ timestamp=False)
834
+
835
+ # If --reset and --delete_unversioned_trees are specified, remove any
836
+ # untracked directories.
837
+ if options.reset and options.delete_unversioned_trees:
838
+ # GIT.CaptureStatus() uses 'dit diff' to compare to a specific SHA1 (the
839
+ # merge-base by default), so doesn't include untracked files. So we use
840
+ # 'git ls-files --directory --others --exclude-standard' here directly.
841
+ paths = scm.GIT.Capture(
842
+ ['-c', 'core.quotePath=false', 'ls-files',
843
+ '--directory', '--others', '--exclude-standard'],
844
+ self.checkout_path)
845
+ for path in (p for p in paths.splitlines() if p.endswith('/')):
846
+ full_path = os.path.join(self.checkout_path, path)
847
+ if not os.path.islink(full_path):
848
+ self.Print('_____ removing unversioned directory %s' % path)
849
+ gclient_utils.rmtree(full_path)
850
+
851
+ return self._Capture(['rev-parse', '--verify', 'HEAD'])
852
+
853
+ def revert(self, options, _args, file_list):
854
+ """Reverts local modifications.
855
+
856
+ All reverted files will be appended to file_list.
857
+ """
858
+ if not os.path.isdir(self.checkout_path):
859
+ # revert won't work if the directory doesn't exist. It needs to
860
+ # checkout instead.
861
+ self.Print('_____ %s is missing, syncing instead' % self.relpath)
862
+ # Don't reuse the args.
863
+ return self.update(options, [], file_list)
864
+
865
+ default_rev = "refs/heads/master"
866
+ if options.upstream:
867
+ if self._GetCurrentBranch():
868
+ upstream_branch = scm.GIT.GetUpstreamBranch(self.checkout_path)
869
+ default_rev = upstream_branch or default_rev
870
+ _, deps_revision = gclient_utils.SplitUrlRevision(self.url)
871
+ if not deps_revision:
872
+ deps_revision = default_rev
873
+ if deps_revision.startswith('refs/heads/'):
874
+ deps_revision = deps_revision.replace('refs/heads/', self.remote + '/')
875
+ try:
876
+ deps_revision = self.GetUsableRev(deps_revision, options)
877
+ except NoUsableRevError as e:
878
+ # If the DEPS entry's url and hash changed, try to update the origin.
879
+ # See also http://crbug.com/520067.
880
+ logging.warning(
881
+ "Couldn't find usable revision, will retrying to update instead: %s",
882
+ e.message)
883
+ return self.update(options, [], file_list)
884
+
885
+ if file_list is not None:
886
+ files = self._GetDiffFilenames(deps_revision)
887
+
888
+ self._Scrub(deps_revision, options)
889
+ self._Run(['clean', '-f', '-d'], options)
890
+
891
+ if file_list is not None:
892
+ file_list.extend([os.path.join(self.checkout_path, f) for f in files])
893
+
894
+ def revinfo(self, _options, _args, _file_list):
895
+ """Returns revision"""
896
+ return self._Capture(['rev-parse', 'HEAD'])
897
+
898
+ def runhooks(self, options, args, file_list):
899
+ self.status(options, args, file_list)
900
+
901
+ def status(self, options, _args, file_list):
902
+ """Display status information."""
903
+ if not os.path.isdir(self.checkout_path):
904
+ self.Print('________ couldn\'t run status in %s:\n'
905
+ 'The directory does not exist.' % self.checkout_path)
906
+ else:
907
+ merge_base = []
908
+ if self.url:
909
+ _, base_rev = gclient_utils.SplitUrlRevision(self.url)
910
+ if base_rev:
911
+ merge_base = [base_rev]
912
+ self._Run(
913
+ ['-c', 'core.quotePath=false', 'diff', '--name-status'] + merge_base,
914
+ options, always_show_header=options.verbose)
915
+ if file_list is not None:
916
+ files = self._GetDiffFilenames(merge_base[0] if merge_base else None)
917
+ file_list.extend([os.path.join(self.checkout_path, f) for f in files])
918
+
919
+ def GetUsableRev(self, rev, options):
920
+ """Finds a useful revision for this repository."""
921
+ sha1 = None
922
+ if not os.path.isdir(self.checkout_path):
923
+ raise NoUsableRevError(
924
+ 'This is not a git repo, so we cannot get a usable rev.')
925
+
926
+ if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
927
+ sha1 = rev
928
+ else:
929
+ # May exist in origin, but we don't have it yet, so fetch and look
930
+ # again.
931
+ self._Fetch(options)
932
+ if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
933
+ sha1 = rev
934
+
935
+ if not sha1:
936
+ raise NoUsableRevError(
937
+ 'Hash %s does not appear to be a valid hash in this repo.' % rev)
938
+
939
+ return sha1
940
+
941
+ def GetGitBackupDirPath(self):
942
+ """Returns the path where the .git folder for the current project can be
943
+ staged/restored. Use case: subproject moved from DEPS <-> outer project."""
944
+ return os.path.join(self._root_dir,
945
+ 'old_' + self.relpath.replace(os.sep, '_')) + '.git'
946
+
947
+ def _GetMirror(self, url, options, revision_ref=None):
948
+ """Get a git_cache.Mirror object for the argument url."""
949
+ if not self.cache_dir:
950
+ return None
951
+ mirror_kwargs = {
952
+ 'print_func': self.filter,
953
+ 'refs': []
954
+ }
955
+ if hasattr(options, 'with_branch_heads') and options.with_branch_heads:
956
+ mirror_kwargs['refs'].append('refs/branch-heads/*')
957
+ elif revision_ref and revision_ref.startswith('refs/branch-heads/'):
958
+ mirror_kwargs['refs'].append(revision_ref)
959
+ if hasattr(options, 'with_tags') and options.with_tags:
960
+ mirror_kwargs['refs'].append('refs/tags/*')
961
+ elif revision_ref and revision_ref.startswith('refs/tags/'):
962
+ mirror_kwargs['refs'].append(revision_ref)
963
+ return git_cache.Mirror(url, **mirror_kwargs)
964
+
965
+ def _UpdateMirrorIfNotContains(self, mirror, options, rev_type, revision):
966
+ """Update a git mirror by fetching the latest commits from the remote,
967
+ unless mirror already contains revision whose type is sha1 hash.
968
+ """
969
+ if rev_type == 'hash' and mirror.contains_revision(revision):
970
+ if options.verbose:
971
+ self.Print('skipping mirror update, it has rev=%s already' % revision,
972
+ timestamp=False)
973
+ return
974
+
975
+ if getattr(options, 'shallow', False):
976
+ # HACK(hinoka): These repositories should be super shallow.
977
+ if 'flash' in mirror.url:
978
+ depth = 10
979
+ else:
980
+ depth = 10000
981
+ else:
982
+ depth = None
983
+ mirror.populate(verbose=options.verbose,
984
+ bootstrap=not getattr(options, 'no_bootstrap', False),
985
+ depth=depth,
986
+ lock_timeout=getattr(options, 'lock_timeout', 0))
987
+
988
+ def _Clone(self, revision, url, options):
989
+ """Clone a git repository from the given URL.
990
+
991
+ Once we've cloned the repo, we checkout a working branch if the specified
992
+ revision is a branch head. If it is a tag or a specific commit, then we
993
+ leave HEAD detached as it makes future updates simpler -- in this case the
994
+ user should first create a new branch or switch to an existing branch before
995
+ making changes in the repo."""
996
+ if not options.verbose:
997
+ # git clone doesn't seem to insert a newline properly before printing
998
+ # to stdout
999
+ self.Print('')
1000
+ cfg = gclient_utils.DefaultIndexPackConfig(url)
1001
+ clone_cmd = cfg + ['clone', '--no-checkout', '--progress']
1002
+ if self.cache_dir:
1003
+ clone_cmd.append('--shared')
1004
+ if options.verbose:
1005
+ clone_cmd.append('--verbose')
1006
+ clone_cmd.append(url)
1007
+ # If the parent directory does not exist, Git clone on Windows will not
1008
+ # create it, so we need to do it manually.
1009
+ parent_dir = os.path.dirname(self.checkout_path)
1010
+ gclient_utils.safe_makedirs(parent_dir)
1011
+
1012
+ template_dir = None
1013
+ if hasattr(options, 'no_history') and options.no_history:
1014
+ if gclient_utils.IsGitSha(revision):
1015
+ # In the case of a subproject, the pinned sha is not necessarily the
1016
+ # head of the remote branch (so we can't just use --depth=N). Instead,
1017
+ # we tell git to fetch all the remote objects from SHA..HEAD by means of
1018
+ # a template git dir which has a 'shallow' file pointing to the sha.
1019
+ template_dir = tempfile.mkdtemp(
1020
+ prefix='_gclient_gittmp_%s' % os.path.basename(self.checkout_path),
1021
+ dir=parent_dir)
1022
+ self._Run(['init', '--bare', template_dir], options, cwd=self._root_dir)
1023
+ with open(os.path.join(template_dir, 'shallow'), 'w') as template_file:
1024
+ template_file.write(revision)
1025
+ clone_cmd.append('--template=' + template_dir)
1026
+ else:
1027
+ # Otherwise, we're just interested in the HEAD. Just use --depth.
1028
+ clone_cmd.append('--depth=1')
1029
+
1030
+ tmp_dir = tempfile.mkdtemp(
1031
+ prefix='_gclient_%s_' % os.path.basename(self.checkout_path),
1032
+ dir=parent_dir)
1033
+ try:
1034
+ clone_cmd.append(tmp_dir)
1035
+ if self.print_outbuf:
1036
+ print_stdout = True
1037
+ filter_fn = None
1038
+ else:
1039
+ print_stdout = False
1040
+ filter_fn = self.filter
1041
+ self._Run(clone_cmd, options, cwd=self._root_dir, retry=True,
1042
+ print_stdout=print_stdout, filter_fn=filter_fn)
1043
+ gclient_utils.safe_makedirs(self.checkout_path)
1044
+ gclient_utils.safe_rename(os.path.join(tmp_dir, '.git'),
1045
+ os.path.join(self.checkout_path, '.git'))
1046
+ except:
1047
+ traceback.print_exc(file=self.out_fh)
1048
+ raise
1049
+ finally:
1050
+ if os.listdir(tmp_dir):
1051
+ self.Print('_____ removing non-empty tmp dir %s' % tmp_dir)
1052
+ gclient_utils.rmtree(tmp_dir)
1053
+ if template_dir:
1054
+ gclient_utils.rmtree(template_dir)
1055
+ self._SetFetchConfig(options)
1056
+ self._Fetch(options, prune=options.force)
1057
+ revision = self._AutoFetchRef(options, revision)
1058
+ remote_ref = scm.GIT.RefToRemoteRef(revision, self.remote)
1059
+ self._Checkout(options, ''.join(remote_ref or revision), quiet=True)
1060
+ if self._GetCurrentBranch() is None:
1061
+ # Squelch git's very verbose detached HEAD warning and use our own
1062
+ self.Print(
1063
+ ('Checked out %s to a detached HEAD. Before making any commits\n'
1064
+ 'in this repo, you should use \'git checkout <branch>\' to switch to\n'
1065
+ 'an existing branch or use \'git checkout %s -b <branch>\' to\n'
1066
+ 'create a new branch for your work.') % (revision, self.remote))
1067
+
1068
+ def _AskForData(self, prompt, options):
1069
+ if options.jobs > 1:
1070
+ self.Print(prompt)
1071
+ raise gclient_utils.Error("Background task requires input. Rerun "
1072
+ "gclient with --jobs=1 so that\n"
1073
+ "interaction is possible.")
1074
+ return gclient_utils.AskForData(prompt)
1075
+
1076
+
1077
+ def _AttemptRebase(self, upstream, files, options, newbase=None,
1078
+ branch=None, printed_path=False, merge=False):
1079
+ """Attempt to rebase onto either upstream or, if specified, newbase."""
1080
+ if files is not None:
1081
+ files.extend(self._GetDiffFilenames(upstream))
1082
+ revision = upstream
1083
+ if newbase:
1084
+ revision = newbase
1085
+ action = 'merge' if merge else 'rebase'
1086
+ if not printed_path:
1087
+ self.Print('_____ %s : Attempting %s onto %s...' % (
1088
+ self.relpath, action, revision))
1089
+ printed_path = True
1090
+ else:
1091
+ self.Print('Attempting %s onto %s...' % (action, revision))
1092
+
1093
+ if merge:
1094
+ merge_output = self._Capture(['merge', revision])
1095
+ if options.verbose:
1096
+ self.Print(merge_output)
1097
+ return
1098
+
1099
+ # Build the rebase command here using the args
1100
+ # git rebase [options] [--onto <newbase>] <upstream> [<branch>]
1101
+ rebase_cmd = ['rebase']
1102
+ if options.verbose:
1103
+ rebase_cmd.append('--verbose')
1104
+ if newbase:
1105
+ rebase_cmd.extend(['--onto', newbase])
1106
+ rebase_cmd.append(upstream)
1107
+ if branch:
1108
+ rebase_cmd.append(branch)
1109
+
1110
+ try:
1111
+ rebase_output = scm.GIT.Capture(rebase_cmd, cwd=self.checkout_path)
1112
+ except subprocess2.CalledProcessError as e:
1113
+ if (re.match(br'cannot rebase: you have unstaged changes', e.stderr) or
1114
+ re.match(br'cannot rebase: your index contains uncommitted changes',
1115
+ e.stderr)):
1116
+ while True:
1117
+ rebase_action = self._AskForData(
1118
+ 'Cannot rebase because of unstaged changes.\n'
1119
+ '\'git reset --hard HEAD\' ?\n'
1120
+ 'WARNING: destroys any uncommitted work in your current branch!'
1121
+ ' (y)es / (q)uit / (s)how : ', options)
1122
+ if re.match(r'yes|y', rebase_action, re.I):
1123
+ self._Scrub('HEAD', options)
1124
+ # Should this be recursive?
1125
+ rebase_output = scm.GIT.Capture(rebase_cmd, cwd=self.checkout_path)
1126
+ break
1127
+ elif re.match(r'quit|q', rebase_action, re.I):
1128
+ raise gclient_utils.Error("Please merge or rebase manually\n"
1129
+ "cd %s && git " % self.checkout_path
1130
+ + "%s" % ' '.join(rebase_cmd))
1131
+ elif re.match(r'show|s', rebase_action, re.I):
1132
+ self.Print('%s' % e.stderr.decode('utf-8').strip())
1133
+ continue
1134
+ else:
1135
+ gclient_utils.Error("Input not recognized")
1136
+ continue
1137
+ elif re.search(br'^CONFLICT', e.stdout, re.M):
1138
+ raise gclient_utils.Error("Conflict while rebasing this branch.\n"
1139
+ "Fix the conflict and run gclient again.\n"
1140
+ "See 'man git-rebase' for details.\n")
1141
+ else:
1142
+ self.Print(e.stdout.decode('utf-8').strip())
1143
+ self.Print('Rebase produced error output:\n%s' %
1144
+ e.stderr.decode('utf-8').strip())
1145
+ raise gclient_utils.Error("Unrecognized error, please merge or rebase "
1146
+ "manually.\ncd %s && git " %
1147
+ self.checkout_path
1148
+ + "%s" % ' '.join(rebase_cmd))
1149
+
1150
+ self.Print(rebase_output.strip())
1151
+ if not options.verbose:
1152
+ # Make the output a little prettier. It's nice to have some
1153
+ # whitespace between projects when syncing.
1154
+ self.Print('')
1155
+
1156
+ @staticmethod
1157
+ def _CheckMinVersion(min_version):
1158
+ (ok, current_version) = scm.GIT.AssertVersion(min_version)
1159
+ if not ok:
1160
+ raise gclient_utils.Error('git version %s < minimum required %s' %
1161
+ (current_version, min_version))
1162
+
1163
+ def _EnsureValidHeadObjectOrCheckout(self, revision, options, url):
1164
+ # Special case handling if all 3 conditions are met:
1165
+ # * the mirros have recently changed, but deps destination remains same,
1166
+ # * the git histories of mirrors are conflicting.
1167
+ # * git cache is used
1168
+ # This manifests itself in current checkout having invalid HEAD commit on
1169
+ # most git operations. Since git cache is used, just deleted the .git
1170
+ # folder, and re-create it by cloning.
1171
+ try:
1172
+ self._Capture(['rev-list', '-n', '1', 'HEAD'])
1173
+ except subprocess2.CalledProcessError as e:
1174
+ if (b'fatal: bad object HEAD' in e.stderr
1175
+ and self.cache_dir and self.cache_dir in url):
1176
+ self.Print((
1177
+ 'Likely due to DEPS change with git cache_dir, '
1178
+ 'the current commit points to no longer existing object.\n'
1179
+ '%s' % e)
1180
+ )
1181
+ self._DeleteOrMove(options.force)
1182
+ self._Clone(revision, url, options)
1183
+ else:
1184
+ raise
1185
+
1186
+ def _IsRebasing(self):
1187
+ # Check for any of REBASE-i/REBASE-m/REBASE/AM. Unfortunately git doesn't
1188
+ # have a plumbing command to determine whether a rebase is in progress, so
1189
+ # for now emualate (more-or-less) git-rebase.sh / git-completion.bash
1190
+ g = os.path.join(self.checkout_path, '.git')
1191
+ return (
1192
+ os.path.isdir(os.path.join(g, "rebase-merge")) or
1193
+ os.path.isdir(os.path.join(g, "rebase-apply")))
1194
+
1195
+ def _CheckClean(self, revision, fixup=False):
1196
+ lockfile = os.path.join(self.checkout_path, ".git", "index.lock")
1197
+ if os.path.exists(lockfile):
1198
+ raise gclient_utils.Error(
1199
+ '\n____ %s at %s\n'
1200
+ '\tYour repo is locked, possibly due to a concurrent git process.\n'
1201
+ '\tIf no git executable is running, then clean up %r and try again.\n'
1202
+ % (self.relpath, revision, lockfile))
1203
+
1204
+ # Make sure the tree is clean; see git-rebase.sh for reference
1205
+ try:
1206
+ scm.GIT.Capture(['update-index', '--ignore-submodules', '--refresh'],
1207
+ cwd=self.checkout_path)
1208
+ except subprocess2.CalledProcessError:
1209
+ raise gclient_utils.Error('\n____ %s at %s\n'
1210
+ '\tYou have unstaged changes.\n'
1211
+ '\tPlease commit, stash, or reset.\n'
1212
+ % (self.relpath, revision))
1213
+ try:
1214
+ scm.GIT.Capture(['diff-index', '--cached', '--name-status', '-r',
1215
+ '--ignore-submodules', 'HEAD', '--'],
1216
+ cwd=self.checkout_path)
1217
+ except subprocess2.CalledProcessError:
1218
+ raise gclient_utils.Error('\n____ %s at %s\n'
1219
+ '\tYour index contains uncommitted changes\n'
1220
+ '\tPlease commit, stash, or reset.\n'
1221
+ % (self.relpath, revision))
1222
+
1223
+ def _CheckDetachedHead(self, revision, _options):
1224
+ # HEAD is detached. Make sure it is safe to move away from (i.e., it is
1225
+ # reference by a commit). If not, error out -- most likely a rebase is
1226
+ # in progress, try to detect so we can give a better error.
1227
+ try:
1228
+ scm.GIT.Capture(['name-rev', '--no-undefined', 'HEAD'],
1229
+ cwd=self.checkout_path)
1230
+ except subprocess2.CalledProcessError:
1231
+ # Commit is not contained by any rev. See if the user is rebasing:
1232
+ if self._IsRebasing():
1233
+ # Punt to the user
1234
+ raise gclient_utils.Error('\n____ %s at %s\n'
1235
+ '\tAlready in a conflict, i.e. (no branch).\n'
1236
+ '\tFix the conflict and run gclient again.\n'
1237
+ '\tOr to abort run:\n\t\tgit-rebase --abort\n'
1238
+ '\tSee man git-rebase for details.\n'
1239
+ % (self.relpath, revision))
1240
+ # Let's just save off the commit so we can proceed.
1241
+ name = ('saved-by-gclient-' +
1242
+ self._Capture(['rev-parse', '--short', 'HEAD']))
1243
+ self._Capture(['branch', '-f', name])
1244
+ self.Print('_____ found an unreferenced commit and saved it as \'%s\'' %
1245
+ name)
1246
+
1247
+ def _GetCurrentBranch(self):
1248
+ # Returns name of current branch or None for detached HEAD
1249
+ branch = self._Capture(['rev-parse', '--abbrev-ref=strict', 'HEAD'])
1250
+ if branch == 'HEAD':
1251
+ return None
1252
+ return branch
1253
+
1254
+ def _Capture(self, args, **kwargs):
1255
+ set_git_dir = 'cwd' not in kwargs
1256
+ kwargs.setdefault('cwd', self.checkout_path)
1257
+ kwargs.setdefault('stderr', subprocess2.PIPE)
1258
+ strip = kwargs.pop('strip', True)
1259
+ env = scm.GIT.ApplyEnvVars(kwargs)
1260
+ # If an explicit cwd isn't set, then default to the .git/ subdir so we get
1261
+ # stricter behavior. This can be useful in cases of slight corruption --
1262
+ # we don't accidentally go corrupting parent git checks too. See
1263
+ # https://crbug.com/1000825 for an example.
1264
+ if set_git_dir:
1265
+ git_dir = os.path.abspath(os.path.join(self.checkout_path, '.git'))
1266
+ # Depending on how the .gclient file was defined, self.checkout_path
1267
+ # might be set to a unicode string, not a regular string; on Windows
1268
+ # Python2, we can't set env vars to be unicode strings, so we
1269
+ # forcibly cast the value to a string before setting it.
1270
+ env.setdefault('GIT_DIR', str(git_dir))
1271
+ ret = subprocess2.check_output(
1272
+ ['git'] + args, env=env, **kwargs).decode('utf-8')
1273
+ if strip:
1274
+ ret = ret.strip()
1275
+ self.Print('Finished running: %s %s' % ('git', ' '.join(args)))
1276
+ return ret
1277
+
1278
+ def _Checkout(self, options, ref, force=False, quiet=None):
1279
+ """Performs a 'git-checkout' operation.
1280
+
1281
+ Args:
1282
+ options: The configured option set
1283
+ ref: (str) The branch/commit to checkout
1284
+ quiet: (bool/None) Whether or not the checkout should pass '--quiet'; if
1285
+ 'None', the behavior is inferred from 'options.verbose'.
1286
+ Returns: (str) The output of the checkout operation
1287
+ """
1288
+ if quiet is None:
1289
+ quiet = (not options.verbose)
1290
+ checkout_args = ['checkout']
1291
+ if force:
1292
+ checkout_args.append('--force')
1293
+ if quiet:
1294
+ checkout_args.append('--quiet')
1295
+ checkout_args.append(ref)
1296
+ return self._Capture(checkout_args)
1297
+
1298
+ def _Fetch(self, options, remote=None, prune=False, quiet=False,
1299
+ refspec=None):
1300
+ cfg = gclient_utils.DefaultIndexPackConfig(self.url)
1301
+ # When updating, the ref is modified to be a remote ref .
1302
+ # (e.g. refs/heads/NAME becomes refs/remotes/REMOTE/NAME).
1303
+ # Try to reverse that mapping.
1304
+ original_ref = scm.GIT.RemoteRefToRef(refspec, self.remote)
1305
+ if original_ref:
1306
+ refspec = original_ref + ':' + refspec
1307
+ # When a mirror is configured, it only fetches
1308
+ # refs/{heads,branch-heads,tags}/*.
1309
+ # If asked to fetch other refs, we must fetch those directly from the
1310
+ # repository, and not from the mirror.
1311
+ if not original_ref.startswith(
1312
+ ('refs/heads/', 'refs/branch-heads/', 'refs/tags/')):
1313
+ remote, _ = gclient_utils.SplitUrlRevision(self.url)
1314
+ fetch_cmd = cfg + [
1315
+ 'fetch',
1316
+ remote or self.remote,
1317
+ ]
1318
+ if refspec:
1319
+ fetch_cmd.append(refspec)
1320
+
1321
+ if prune:
1322
+ fetch_cmd.append('--prune')
1323
+ if options.verbose:
1324
+ fetch_cmd.append('--verbose')
1325
+ if not hasattr(options, 'with_tags') or not options.with_tags:
1326
+ fetch_cmd.append('--no-tags')
1327
+ elif quiet:
1328
+ fetch_cmd.append('--quiet')
1329
+ self._Run(fetch_cmd, options, show_header=options.verbose, retry=True)
1330
+
1331
+ def _SetFetchConfig(self, options):
1332
+ """Adds, and optionally fetches, "branch-heads" and "tags" refspecs
1333
+ if requested."""
1334
+ if options.force or options.reset:
1335
+ try:
1336
+ self._Run(['config', '--unset-all', 'remote.%s.fetch' % self.remote],
1337
+ options)
1338
+ self._Run(['config', 'remote.%s.fetch' % self.remote,
1339
+ '+refs/heads/*:refs/remotes/%s/*' % self.remote], options)
1340
+ except subprocess2.CalledProcessError as e:
1341
+ # If exit code was 5, it means we attempted to unset a config that
1342
+ # didn't exist. Ignore it.
1343
+ if e.returncode != 5:
1344
+ raise
1345
+ if hasattr(options, 'with_branch_heads') and options.with_branch_heads:
1346
+ config_cmd = ['config', 'remote.%s.fetch' % self.remote,
1347
+ '+refs/branch-heads/*:refs/remotes/branch-heads/*',
1348
+ '^\\+refs/branch-heads/\\*:.*$']
1349
+ self._Run(config_cmd, options)
1350
+ if hasattr(options, 'with_tags') and options.with_tags:
1351
+ config_cmd = ['config', 'remote.%s.fetch' % self.remote,
1352
+ '+refs/tags/*:refs/tags/*',
1353
+ '^\\+refs/tags/\\*:.*$']
1354
+ self._Run(config_cmd, options)
1355
+
1356
+ def _AutoFetchRef(self, options, revision):
1357
+ """Attempts to fetch |revision| if not available in local repo.
1358
+
1359
+ Returns possibly updated revision."""
1360
+ if not scm.GIT.IsValidRevision(self.checkout_path, revision):
1361
+ self._Fetch(options, refspec=revision)
1362
+ revision = self._Capture(['rev-parse', 'FETCH_HEAD'])
1363
+ return revision
1364
+
1365
+ def _IsRunningUnderRosetta(self):
1366
+ if sys.platform != 'darwin':
1367
+ return False
1368
+ if self._running_under_rosetta is None:
1369
+ # If we are running under Rosetta, platform.machine() is
1370
+ # 'x86_64'; we need to use a sysctl to see if we're being
1371
+ # translated.
1372
+ import ctypes
1373
+ libSystem = ctypes.CDLL("libSystem.dylib")
1374
+ ret = ctypes.c_int(0)
1375
+ size = ctypes.c_size_t(4)
1376
+ e = libSystem.sysctlbyname(ctypes.c_char_p(b'sysctl.proc_translated'),
1377
+ ctypes.byref(ret), ctypes.byref(size), None, 0)
1378
+ self._running_under_rosetta = e == 0 and ret.value == 1
1379
+ return self._running_under_rosetta
1380
+
1381
+ def _Run(self, args, options, **kwargs):
1382
+ # Disable 'unused options' warning | pylint: disable=unused-argument
1383
+ kwargs.setdefault('cwd', self.checkout_path)
1384
+ kwargs.setdefault('filter_fn', self.filter)
1385
+ kwargs.setdefault('show_header', True)
1386
+ env = scm.GIT.ApplyEnvVars(kwargs)
1387
+
1388
+ cmd = ['git'] + args
1389
+
1390
+ if self._IsRunningUnderRosetta():
1391
+ # We currently only ship an Intel Python binary in depot_tools.
1392
+ # Intel binaries run under Rosetta on ARM Macs, and by default
1393
+ # prefer to run their subprocesses as Intel under Rosetta too.
1394
+ # Intel git running under Rosetta has a bug where it fails to
1395
+ # clone src.git (rdar://7868319), so until we ship a native
1396
+ # ARM python3 binary, explicitly use `arch` to let git run
1397
+ # the native ARM slice instead of the Intel slice.
1398
+ # TODO(thakis): Remove this again once we ship an arm64 python3
1399
+ # binary.
1400
+ cmd = ['arch', '-arch', 'arm64'] + cmd
1401
+ gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
1402
+
1403
+
1404
+ class CipdPackage(object):
1405
+ """A representation of a single CIPD package."""
1406
+
1407
+ def __init__(self, name, version, authority_for_subdir):
1408
+ self._authority_for_subdir = authority_for_subdir
1409
+ self._name = name
1410
+ self._version = version
1411
+
1412
+ @property
1413
+ def authority_for_subdir(self):
1414
+ """Whether this package has authority to act on behalf of its subdir.
1415
+
1416
+ Some operations should only be performed once per subdirectory. A package
1417
+ that has authority for its subdirectory is the only package that should
1418
+ perform such operations.
1419
+
1420
+ Returns:
1421
+ bool; whether this package has subdir authority.
1422
+ """
1423
+ return self._authority_for_subdir
1424
+
1425
+ @property
1426
+ def name(self):
1427
+ return self._name
1428
+
1429
+ @property
1430
+ def version(self):
1431
+ return self._version
1432
+
1433
+
1434
+ class CipdRoot(object):
1435
+ """A representation of a single CIPD root."""
1436
+ def __init__(self, root_dir, service_url):
1437
+ self._all_packages = set()
1438
+ self._mutator_lock = threading.Lock()
1439
+ self._packages_by_subdir = collections.defaultdict(list)
1440
+ self._root_dir = root_dir
1441
+ self._service_url = service_url
1442
+
1443
+ def add_package(self, subdir, package, version):
1444
+ """Adds a package to this CIPD root.
1445
+
1446
+ As far as clients are concerned, this grants both root and subdir authority
1447
+ to packages arbitrarily. (The implementation grants root authority to the
1448
+ first package added and subdir authority to the first package added for that
1449
+ subdir, but clients should not depend on or expect that behavior.)
1450
+
1451
+ Args:
1452
+ subdir: str; relative path to where the package should be installed from
1453
+ the cipd root directory.
1454
+ package: str; the cipd package name.
1455
+ version: str; the cipd package version.
1456
+ Returns:
1457
+ CipdPackage; the package that was created and added to this root.
1458
+ """
1459
+ with self._mutator_lock:
1460
+ cipd_package = CipdPackage(
1461
+ package, version,
1462
+ not self._packages_by_subdir[subdir])
1463
+ self._all_packages.add(cipd_package)
1464
+ self._packages_by_subdir[subdir].append(cipd_package)
1465
+ return cipd_package
1466
+
1467
+ def packages(self, subdir):
1468
+ """Get the list of configured packages for the given subdir."""
1469
+ return list(self._packages_by_subdir[subdir])
1470
+
1471
+ def clobber(self):
1472
+ """Remove the .cipd directory.
1473
+
1474
+ This is useful for forcing ensure to redownload and reinitialize all
1475
+ packages.
1476
+ """
1477
+ with self._mutator_lock:
1478
+ cipd_cache_dir = os.path.join(self.root_dir, '.cipd')
1479
+ try:
1480
+ gclient_utils.rmtree(os.path.join(cipd_cache_dir))
1481
+ except OSError:
1482
+ if os.path.exists(cipd_cache_dir):
1483
+ raise
1484
+
1485
+ @contextlib.contextmanager
1486
+ def _create_ensure_file(self):
1487
+ try:
1488
+ contents = '$ParanoidMode CheckPresence\n\n'
1489
+ for subdir, packages in sorted(self._packages_by_subdir.items()):
1490
+ contents += '@Subdir %s\n' % subdir
1491
+ for package in sorted(packages, key=lambda p: p.name):
1492
+ contents += '%s %s\n' % (package.name, package.version)
1493
+ contents += '\n'
1494
+ ensure_file = None
1495
+ with tempfile.NamedTemporaryFile(
1496
+ suffix='.ensure', delete=False, mode='wb') as ensure_file:
1497
+ ensure_file.write(contents.encode('utf-8', 'replace'))
1498
+ yield ensure_file.name
1499
+ finally:
1500
+ if ensure_file is not None and os.path.exists(ensure_file.name):
1501
+ os.remove(ensure_file.name)
1502
+
1503
+ def ensure(self):
1504
+ """Run `cipd ensure`."""
1505
+ with self._mutator_lock:
1506
+ with self._create_ensure_file() as ensure_file:
1507
+ cmd = [
1508
+ 'cipd', 'ensure',
1509
+ '-log-level', 'error',
1510
+ '-root', self.root_dir,
1511
+ '-ensure-file', ensure_file,
1512
+ ]
1513
+ gclient_utils.CheckCallAndFilter(
1514
+ cmd, print_stdout=True, show_header=True)
1515
+
1516
+ def run(self, command):
1517
+ if command == 'update':
1518
+ self.ensure()
1519
+ elif command == 'revert':
1520
+ self.clobber()
1521
+ self.ensure()
1522
+
1523
+ def created_package(self, package):
1524
+ """Checks whether this root created the given package.
1525
+
1526
+ Args:
1527
+ package: CipdPackage; the package to check.
1528
+ Returns:
1529
+ bool; whether this root created the given package.
1530
+ """
1531
+ return package in self._all_packages
1532
+
1533
+ @property
1534
+ def root_dir(self):
1535
+ return self._root_dir
1536
+
1537
+ @property
1538
+ def service_url(self):
1539
+ return self._service_url
1540
+
1541
+
1542
+ class CipdWrapper(SCMWrapper):
1543
+ """Wrapper for CIPD.
1544
+
1545
+ Currently only supports chrome-infra-packages.appspot.com.
1546
+ """
1547
+ name = 'cipd'
1548
+
1549
+ def __init__(self, url=None, root_dir=None, relpath=None, out_fh=None,
1550
+ out_cb=None, root=None, package=None):
1551
+ super(CipdWrapper, self).__init__(
1552
+ url=url, root_dir=root_dir, relpath=relpath, out_fh=out_fh,
1553
+ out_cb=out_cb)
1554
+ assert root.created_package(package)
1555
+ self._package = package
1556
+ self._root = root
1557
+
1558
+ #override
1559
+ def GetCacheMirror(self):
1560
+ return None
1561
+
1562
+ #override
1563
+ def GetActualRemoteURL(self, options):
1564
+ return self._root.service_url
1565
+
1566
+ #override
1567
+ def DoesRemoteURLMatch(self, options):
1568
+ del options
1569
+ return True
1570
+
1571
+ def revert(self, options, args, file_list):
1572
+ """Does nothing.
1573
+
1574
+ CIPD packages should be reverted at the root by running
1575
+ `CipdRoot.run('revert')`.
1576
+ """
1577
+ pass
1578
+
1579
+ def diff(self, options, args, file_list):
1580
+ """CIPD has no notion of diffing."""
1581
+ pass
1582
+
1583
+ def pack(self, options, args, file_list):
1584
+ """CIPD has no notion of diffing."""
1585
+ pass
1586
+
1587
+ def revinfo(self, options, args, file_list):
1588
+ """Grab the instance ID."""
1589
+ try:
1590
+ tmpdir = tempfile.mkdtemp()
1591
+ describe_json_path = os.path.join(tmpdir, 'describe.json')
1592
+ cmd = [
1593
+ 'cipd', 'describe',
1594
+ self._package.name,
1595
+ '-log-level', 'error',
1596
+ '-version', self._package.version,
1597
+ '-json-output', describe_json_path
1598
+ ]
1599
+ gclient_utils.CheckCallAndFilter(cmd)
1600
+ with open(describe_json_path) as f:
1601
+ describe_json = json.load(f)
1602
+ return describe_json.get('result', {}).get('pin', {}).get('instance_id')
1603
+ finally:
1604
+ gclient_utils.rmtree(tmpdir)
1605
+
1606
+ def status(self, options, args, file_list):
1607
+ pass
1608
+
1609
+ def update(self, options, args, file_list):
1610
+ """Does nothing.
1611
+
1612
+ CIPD packages should be updated at the root by running
1613
+ `CipdRoot.run('update')`.
1614
+ """
1615
+ pass