Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5039df3

Browse files
committed
Eliminate duplicate rmtree try-except logic
In git.util.rmtree, exceptions are caught and conditionally(depending on the value of HIDE_WINDOWS_KNOWN_ERRORS) reraisedwrapped in a unittest.SkipTest exception. Although this logic ispart of git.util.rmtree itself, two of the calls to that rmtreefunction contain this same logic.This is not quite a refactoring: because SkipTest derives fromException, and Exception rather than PermissionError is beingcaught including in the duplicated logic, duplicated logic wheregit.util.rmtree was called added another layer of indirection inthe chained exceptions leading back to the original that was raisedin an unsuccessful attempt to delete a file or directory in rmtree.However, that appeared unintended and may be considered a minorbug. The new behavior, differing only subtly, is preferable.
1 parentfba59aa commit5039df3

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

‎git/objects/submodule/base.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
unbare_repo,
3030
IterableList,
3131
)
32-
fromgit.utilimportHIDE_WINDOWS_KNOWN_ERRORS
3332

3433
importos.pathasosp
3534

@@ -1060,28 +1059,13 @@ def remove(
10601059
importgc
10611060

10621061
gc.collect()
1063-
try:
1064-
rmtree(str(wtd))
1065-
exceptExceptionasex:
1066-
ifHIDE_WINDOWS_KNOWN_ERRORS:
1067-
fromunittestimportSkipTest
1068-
1069-
raiseSkipTest("FIXME: fails with: PermissionError\n {}".format(ex))fromex
1070-
raise
1062+
rmtree(str(wtd))
10711063
# END delete tree if possible
10721064
# END handle force
10731065

10741066
ifnotdry_runandosp.isdir(git_dir):
10751067
self._clear_cache()
1076-
try:
1077-
rmtree(git_dir)
1078-
exceptExceptionasex:
1079-
ifHIDE_WINDOWS_KNOWN_ERRORS:
1080-
fromunittestimportSkipTest
1081-
1082-
raiseSkipTest(f"FIXME: fails with: PermissionError\n{ex}")fromex
1083-
else:
1084-
raise
1068+
rmtree(git_dir)
10851069
# end handle separate bare repository
10861070
# END handle module deletion
10871071

‎test/test_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def tearDown(self):
2121

2222
gc.collect()
2323

24-
# ACTUALLY skipped by git.objects.submodule.base.Submodule.remove, at the last
25-
#rmtree call (in "handle separate bare repository"), line1082.
24+
# ACTUALLY skipped by git.util.rmtree (in local onerror function), from the last call to it via
25+
#git.objects.submodule.base.Submodule.remove (at "handle separate bare repository"), line1068.
2626
#
2727
# @skipIf(HIDE_WINDOWS_KNOWN_ERRORS,
2828
# "FIXME: helper.wrapper fails with: PermissionError: [WinError 5] Access is denied: "

‎test/test_submodule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def _do_base_tests(self, rwrepo):
458458
)
459459

460460
# ACTUALLY skipped by git.util.rmtree (in local onerror function), called via
461-
# git.objects.submodule.base.Submodule.remove at "method(mp)", line1018.
461+
# git.objects.submodule.base.Submodule.remove at "method(mp)", line1017.
462462
#
463463
# @skipIf(HIDE_WINDOWS_KNOWN_ERRORS,
464464
# "FIXME: fails with: PermissionError: [WinError 32] The process cannot access the file because"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp