##// END OF EJS Templates
shadow-repos: use safer way to destroy shadow repositories....
marcink -
r2777:f1cc2e3d default
parent child Browse files
Show More
@@ -31,6 +31,7 b' import os'
31 import re
31 import re
32 import time
32 import time
33 import warnings
33 import warnings
34 import shutil
34
35
35 from zope.cachedescriptors.property import Lazy as LazyProperty
36 from zope.cachedescriptors.property import Lazy as LazyProperty
36
37
@@ -521,6 +522,9 b' class BaseRepository(object):'
521 """
522 """
522 raise NotImplementedError
523 raise NotImplementedError
523
524
525 def _get_shadow_repository_path(self, workspace_id):
526 raise NotImplementedError
527
524 def cleanup_merge_workspace(self, workspace_id):
528 def cleanup_merge_workspace(self, workspace_id):
525 """
529 """
526 Remove merge workspace.
530 Remove merge workspace.
@@ -530,7 +534,23 b' class BaseRepository(object):'
530
534
531 :param workspace_id: `workspace_id` unique identifier.
535 :param workspace_id: `workspace_id` unique identifier.
532 """
536 """
533 raise NotImplementedError
537 shadow_repository_path = self._get_shadow_repository_path(workspace_id)
538 shadow_repository_path_del = '{}.{}.delete'.format(
539 shadow_repository_path, time.time())
540
541 # move the shadow repo, so it never conflicts with the one used.
542 # we use this method because shutil.rmtree had some edge case problems
543 # removing symlinked repositories
544 if not os.path.isdir(shadow_repository_path):
545 return
546
547 shutil.move(shadow_repository_path, shadow_repository_path_del)
548 try:
549 shutil.rmtree(shadow_repository_path_del, ignore_errors=False)
550 except Exception:
551 log.exception('Failed to gracefully remove shadow repo under %s',
552 shadow_repository_path_del)
553 shutil.rmtree(shadow_repository_path_del, ignore_errors=True)
534
554
535 # ========== #
555 # ========== #
536 # COMMIT API #
556 # COMMIT API #
@@ -25,7 +25,6 b' GIT repository module'
25 import logging
25 import logging
26 import os
26 import os
27 import re
27 import re
28 import shutil
29
28
30 from zope.cachedescriptors.property import Lazy as LazyProperty
29 from zope.cachedescriptors.property import Lazy as LazyProperty
31
30
@@ -983,7 +982,3 b' class GitRepository(BaseRepository):'
983 shadow_repository_path, target_ref.name, source_ref.name)
982 shadow_repository_path, target_ref.name, source_ref.name)
984
983
985 return shadow_repository_path
984 return shadow_repository_path
986
987 def cleanup_merge_workspace(self, workspace_id):
988 shadow_repository_path = self._get_shadow_repository_path(workspace_id)
989 shutil.rmtree(shadow_repository_path, ignore_errors=True)
@@ -24,7 +24,6 b' HG repository module'
24 import os
24 import os
25 import logging
25 import logging
26 import binascii
26 import binascii
27 import shutil
28 import urllib
27 import urllib
29
28
30 from zope.cachedescriptors.property import Lazy as LazyProperty
29 from zope.cachedescriptors.property import Lazy as LazyProperty
@@ -698,10 +697,6 b' class MercurialRepository(BaseRepository'
698
697
699 return shadow_repository_path
698 return shadow_repository_path
700
699
701 def cleanup_merge_workspace(self, workspace_id):
702 shadow_repository_path = self._get_shadow_repository_path(workspace_id)
703 shutil.rmtree(shadow_repository_path, ignore_errors=True)
704
705 def _merge_repo(self, shadow_repository_path, target_ref,
700 def _merge_repo(self, shadow_repository_path, target_ref,
706 source_repo, source_ref, merge_message,
701 source_repo, source_ref, merge_message,
707 merger_name, merger_email, dry_run=False,
702 merger_name, merger_email, dry_run=False,
General Comments 0
You need to be logged in to leave comments. Login now