Fix multiple confusingly escaped regex strings

Python (prior to 3.8) treats meaningless string escape sequences as if
they were a slash followed by the character. That is, '\w' == '\\w'.
Python 3.8 rejects this, and it's confusing. This change fixes seven of these
regex strings found in depot_tools (through a regex search, natch). Most of
the fixes don't actually change the value of the strings, and this was
manually verified:

>>> '(/c(/.*/\+)?)?/(\d+)(/(\d+)?/?)?$' == r'(/c(/.*/\+)?)?/(\d+)(/(\d+)?/?)?$'
True
>>> '#\s*OWNERS_STATUS\s+=\s+(.+)$' == r'#\s*OWNERS_STATUS\s+=\s+(.+)$'
True
>>> 'COM\d' == r'COM\d'
True
>>> '^\s+Change-Id:\s*(\S+)$' == r'^\s+Change-Id:\s*(\S+)$'
True
>>> 'ETag:\s+([a-z0-9]{32})' == r'ETag:\s+([a-z0-9]{32})'
True

Two exceptions were the regex expressions in filter_demo_output.py and scm.py.
These were turned into raw strings despite this changing the value of the
string passed to re. This works because re supports the \x, \d, \w, \t, and
other escape sequences needed to make this work.

TL;DR - use raw strings for regex to avoid melting your brain. If bulk changing
regex strings to raw watch out for double-slashes.

Bug: 958138
Change-Id: Ic45264cfc63e8bae9cfcffe2cd88a57c2d3dcdae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1590534
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
7 files changed
tree: ed9e0d004f8503703af0423c16b1cb9b5bf477c7
  1. bootstrap/
  2. fetch_configs/
  3. git-templates/
  4. infra/
  5. man/
  6. recipes/
  7. support/
  8. testing_support/
  9. tests/
  10. third_party/
  11. win_toolchain/
  12. zsh-goodies/
  13. .gitattributes
  14. .gitignore
  15. .style.yapf
  16. annotated_gclient.py
  17. appengine_mapper.py
  18. auth.py
  19. autoninja
  20. autoninja.bat
  21. autoninja.py
  22. bb
  23. bb.bat
  24. breakpad.py
  25. buildbucket.py
  26. checkout.py
  27. cipd
  28. cipd.bat
  29. cipd.ps1
  30. cipd_bin_setup.bat
  31. cipd_bin_setup.sh
  32. cipd_client_version
  33. cipd_client_version.digests
  34. cipd_manifest.txt
  35. cipd_manifest.versions
  36. cit
  37. cit.bat
  38. cit.py
  39. clang-format
  40. clang-format.bat
  41. clang_format.py
  42. clang_format_merge_driver
  43. clang_format_merge_driver.bat
  44. clang_format_merge_driver.py
  45. codereview.settings
  46. compile_single_file
  47. compile_single_file.bat
  48. compile_single_file.py
  49. cpplint.bat
  50. cpplint.py
  51. cpplint_chromium.py
  52. CROS_OWNERS
  53. dart_format.py
  54. depot-tools-auth
  55. depot-tools-auth.bat
  56. depot-tools-auth.py
  57. detect_host_arch.py
  58. download_from_google_storage
  59. download_from_google_storage.bat
  60. download_from_google_storage.py
  61. ensure_bootstrap
  62. fetch
  63. fetch.bat
  64. fetch.py
  65. fix_encoding.py
  66. gclient
  67. gclient-new-workdir.py
  68. gclient.bat
  69. gclient.py
  70. gclient_completion.sh
  71. gclient_eval.py
  72. gclient_paths.py
  73. gclient_scm.py
  74. gclient_utils.py
  75. gerrit_client.py
  76. gerrit_util.py
  77. git-cache
  78. git-cl
  79. git-crrev-parse
  80. git-drover
  81. git-find-releases
  82. git-footers
  83. git-freeze
  84. git-gs
  85. git-hyper-blame
  86. git-map
  87. git-map-branches
  88. git-mark-merge-base
  89. git-nav-downstream
  90. git-nav-upstream
  91. git-new-branch
  92. git-number
  93. git-rebase-update
  94. git-rename-branch
  95. git-reparent-branch
  96. git-retry
  97. git-runhooks
  98. git-squash-branch
  99. git-thaw
  100. git-upstream-diff
  101. git_cache.py
  102. git_cl.py
  103. git_cl_completion.sh
  104. git_common.py
  105. git_dates.py
  106. git_drover.py
  107. git_find_releases.py
  108. git_footers.py
  109. git_freezer.py
  110. git_hyper_blame.py
  111. git_map.py
  112. git_map_branches.py
  113. git_mark_merge_base.py
  114. git_nav_downstream.py
  115. git_new_branch.py
  116. git_number.py
  117. git_rebase_update.py
  118. git_rename_branch.py
  119. git_reparent_branch.py
  120. git_retry.py
  121. git_squash_branch.py
  122. git_upstream_diff.py
  123. gn
  124. gn.bat
  125. gn.py
  126. gsutil.py
  127. gsutil.py.bat
  128. gsutil.vpython
  129. led
  130. led.bat
  131. LICENSE
  132. luci-auth
  133. luci-auth.bat
  134. lucicfg
  135. lucicfg.bat
  136. mac_toolchain
  137. metrics.py
  138. metrics.README.md
  139. metrics_utils.py
  140. my_activity.py
  141. my_reviews.py
  142. ninja
  143. ninja-linux32
  144. ninja-linux64
  145. ninja-mac
  146. ninja.exe
  147. ninjalog.README.md
  148. ninjalog_uploader.py
  149. ninjalog_uploader_wrapper.py
  150. OWNERS
  151. owners.py
  152. owners_finder.py
  153. patch.py
  154. post_build_ninja_summary.py
  155. PRESUBMIT.py
  156. presubmit_canned_checks.py
  157. presubmit_support.py
  158. profile.xml
  159. prpc
  160. prpc.bat
  161. pylint
  162. pylint.py
  163. pylintrc
  164. python_runner.sh
  165. README.gclient.md
  166. README.git-cl.md
  167. README.md
  168. README.testing
  169. repo
  170. rietveld.py
  171. roll-dep
  172. roll-dep-svn
  173. roll-dep-svn.bat
  174. roll-dep.bat
  175. roll_dep.py
  176. roll_dep_svn.py
  177. scm.py
  178. setup_color.py
  179. split_cl.py
  180. subcommand.py
  181. subprocess2.py
  182. update_depot_tools
  183. update_depot_tools.bat
  184. update_depot_tools_toggle.py
  185. upload_metrics.py
  186. upload_to_google_storage.py
  187. vpython
  188. vpython.bat
  189. WATCHLISTS
  190. watchlists.py
  191. weekly
  192. wtf
  193. yapf
  194. yapf.bat
README.md

depot_tools

Tools for working with Chromium development. It requires python 2.7.

Tools

The most important tools are:

  • fetch: A gclient wrapper to checkout a project. Use fetch --help for more details.
  • gclient: A meta-checkout tool. Think repo or git submodules, except that it support OS-specific rules, e.g. do not checkout Windows only dependencies when checking out for Android. Use gclient help for more details and README.gclient.md.
  • git cl: A code review tool to interact with Rietveld or Gerrit. Use git cl help for more details and README.git-cl.md.
  • roll-dep: A gclient dependency management tool to submit a dep roll, updating a dependency to a newer revision.

There are a lot of git utilities included.

Updating

depot_tools updates itself automatically when running gclient tool. To disable auto update, set the environment variable DEPOT_TOOLS_UPDATE=0.

To update package manually, run update_depot_tools.bat on Windows, or ./update_depot_tools on Linux or Mac.

On Windows only, running gclient will install git and python.

Contributing

To contribute change for review:

git new-branch <somename>
# Hack
git add .
git commit -a -m "Fixes goat teleporting"
# find reviewers
git cl owners
git log -- <yourfiles>

# Request a review.
git cl upload -r reviewer1@chromium.org,reviewer2@chromium.org --send-mail

# Edit change description if needed.
git cl desc

# If change is approved, flag it to be committed.
git cl set-commit

# If change needs more work.
git rebase-update
...
git cl upload -t "Fixes goat teleporter destination to be Australia"

See also open bugs, open reviews, forum or report problems.

cpplint.py

Until 2018, our cpplint.py was a copy of the upstream version at https://github.com/google/styleguide/tree/gh-pages/cpplint. Unfortunately, that repository is not maintained any more. If you want to update cpplint.py in depot_tools, just upload a patch to do so. We will figure out a long-term strategy via issue https://crbug.com/916550.

Note that the cpplint.py here is also used by the Tricium analyzer, so if the cpplint.py here changes, we should also update the copy used there.