Fix hook disable logic in gclient_scm (non-atomic os.rename on Windows)

crrev.com/348703002 has introduced some code into gclient_scm.py which
disables the .git/hooks when gclient is running in managed mode.
The disabling logic renames the individual hook files to hook.disabled
using os.rename. Conversely to what happen on Posix OSs, on Windows
os.rename does not have atomic rename semantics [1] and it fails if the
destination file already exists.
This change improves the hook disable logic.

[1] See https://bugs.python.org/issue8828 and os.replace in Python 3

BUG=474218

Review URL: https://codereview.chromium.org/1063973002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294715 0039d316-1c4b-4281-b951-d872f2087c98
1 file changed
tree: 530164487db93608ba80d81d2f886f87ce56288d
  1. bootstrap/
  2. git-templates/
  3. git_utils/
  4. man/
  5. recipes/
  6. support/
  7. testing_support/
  8. tests/
  9. third_party/
  10. win_toolchain/
  11. zsh-goodies/
  12. .gitignore
  13. annotated_gclient.py
  14. apply_issue
  15. apply_issue.bat
  16. apply_issue.py
  17. breakpad.py
  18. checkout.py
  19. chrome-update-create-task.bat
  20. chrome-update.bat
  21. chrome-update.py
  22. clang-format
  23. clang-format.bat
  24. clang_format.py
  25. codereview.settings
  26. commit_queue.py
  27. cpplint.bat
  28. cpplint.py
  29. cpplint_chromium.py
  30. create-chromium-git-src
  31. create-ntfs-junction.c
  32. create-ntfs-junction.exe
  33. dart_format.py
  34. download_from_google_storage
  35. download_from_google_storage.bat
  36. download_from_google_storage.py
  37. drover
  38. drover.bat
  39. drover.py
  40. fetch
  41. fetch.bat
  42. fetch.py
  43. fix_encoding.py
  44. gcl
  45. gcl.bat
  46. gcl.py
  47. gclient
  48. gclient-new-workdir.py
  49. gclient.bat
  50. gclient.py
  51. gclient_completion.sh
  52. gclient_scm.py
  53. gclient_utils.py
  54. gerrit_util.py
  55. git-auto-svn
  56. git-cache
  57. git-cherry-pick-upload
  58. git-cl
  59. git-cl-upload-hook
  60. git-crrev-parse
  61. git-crsync
  62. git-crup
  63. git-footers
  64. git-freeze
  65. git-gs
  66. git-lkgr
  67. git-map
  68. git-map-branches
  69. git-mark-merge-base
  70. git-nav-downstream
  71. git-nav-upstream
  72. git-new-branch
  73. git-number
  74. git-rebase-update
  75. git-rename-branch
  76. git-reparent-branch
  77. git-retry
  78. git-runhooks
  79. git-squash-branch
  80. git-thaw
  81. git-try
  82. git-upstream-diff
  83. git_auto_svn.py
  84. git_cache.py
  85. git_cherry_pick_upload.py
  86. git_cl.py
  87. git_common.py
  88. git_footers.py
  89. git_freezer.py
  90. git_map.py
  91. git_map_branches.py
  92. git_mark_merge_base.py
  93. git_nav_downstream.py
  94. git_new_branch.py
  95. git_number.py
  96. git_rebase_update.py
  97. git_rename_branch.py
  98. git_reparent_branch.py
  99. git_retry.py
  100. git_squash_branch.py
  101. git_try.py
  102. git_upstream_diff.py
  103. gn
  104. gn.bat
  105. gn.py
  106. gsutil.py
  107. hammer
  108. hammer.bat
  109. LICENSE
  110. my_activity.py
  111. my_reviews.py
  112. ninja
  113. ninja-linux32
  114. ninja-linux64
  115. ninja-mac
  116. ninja.exe
  117. oauth2.py
  118. OWNERS
  119. owners.py
  120. owners_finder.py
  121. patch.py
  122. PRESUBMIT.py
  123. presubmit_canned_checks.py
  124. presubmit_support.py
  125. profile.xml
  126. pylint
  127. pylint.py
  128. pylintrc
  129. python_git_runner.sh
  130. README
  131. README.codereview
  132. README.gclient
  133. README.git-cl
  134. README.testing
  135. repo
  136. rietveld.py
  137. roll-dep
  138. roll-dep.bat
  139. roll_dep.py
  140. scm.py
  141. subcommand.py
  142. subprocess2.py
  143. trychange.py
  144. update_depot_tools
  145. update_depot_tools.bat
  146. upload_to_google_storage.py
  147. WATCHLISTS
  148. watchlists.py
  149. weekly
  150. wtf