Mercurial > kallithea
comparison rhodecode/model/repos_group.py @ 2961:08f89c688592 beta
deleting a group now does same archive operation like deleting repositories. Improve prompt that show number of repos that will
be archived together with a group.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 26 Oct 2012 00:13:55 +0200 |
parents | c0cc8f8a71b0 |
children | abd49f6f5805 |
comparison
equal
deleted
inserted
replaced
2960:91d5f720e88f | 2961:08f89c688592 |
---|---|
25 | 25 |
26 import os | 26 import os |
27 import logging | 27 import logging |
28 import traceback | 28 import traceback |
29 import shutil | 29 import shutil |
30 import datetime | |
30 | 31 |
31 from rhodecode.lib.utils2 import LazyProperty | 32 from rhodecode.lib.utils2 import LazyProperty |
32 | 33 |
33 from rhodecode.model import BaseModel | 34 from rhodecode.model import BaseModel |
34 from rhodecode.model.db import RepoGroup, RhodeCodeUi, UserRepoGroupToPerm, \ | 35 from rhodecode.model.db import RepoGroup, RhodeCodeUi, UserRepoGroupToPerm, \ |
124 """ | 125 """ |
125 paths = group.full_path.split(RepoGroup.url_sep()) | 126 paths = group.full_path.split(RepoGroup.url_sep()) |
126 paths = os.sep.join(paths) | 127 paths = os.sep.join(paths) |
127 | 128 |
128 rm_path = os.path.join(self.repos_path, paths) | 129 rm_path = os.path.join(self.repos_path, paths) |
130 log.info("Removing group %s" % (rm_path)) | |
131 # delete only if that path really exists | |
129 if os.path.isdir(rm_path): | 132 if os.path.isdir(rm_path): |
130 # delete only if that path really exists | |
131 if force_delete: | 133 if force_delete: |
132 shutil.rmtree(rm_path) | 134 shutil.rmtree(rm_path) |
133 else: | 135 else: |
134 os.rmdir(rm_path) # this raises an exception when there are still objects inside | 136 #archive that group` |
137 _now = datetime.datetime.now() | |
138 _ms = str(_now.microsecond).rjust(6, '0') | |
139 _d = 'rm__%s_GROUP_%s' % (_now.strftime('%Y%m%d_%H%M%S_' + _ms), | |
140 group.name) | |
141 shutil.move(rm_path, os.path.join(self.repos_path, _d)) | |
135 | 142 |
136 def create(self, group_name, group_description, parent=None, just_db=False): | 143 def create(self, group_name, group_description, parent=None, just_db=False): |
137 try: | 144 try: |
138 new_repos_group = RepoGroup() | 145 new_repos_group = RepoGroup() |
139 new_repos_group.group_description = group_description | 146 new_repos_group.group_description = group_description |