##// END OF EJS Templates
repo group: clarify comments
Mads Kiilerich -
r8748:ff22ffba stable
parent child Browse files
Show More
@@ -913,7 +913,7 b' class Repository(meta.Base, BaseDbModel)'
913 STATE_ERROR = 'repo_state_error'
913 STATE_ERROR = 'repo_state_error'
914
914
915 repo_id = Column(Integer(), primary_key=True)
915 repo_id = Column(Integer(), primary_key=True)
916 repo_name = Column(Unicode(255), nullable=False, unique=True)
916 repo_name = Column(Unicode(255), nullable=False, unique=True) # full path, must be updated (based on get_new_name) when name or path changes
917 repo_state = Column(String(255), nullable=False)
917 repo_state = Column(String(255), nullable=False)
918
918
919 clone_uri = Column(String(255), nullable=True) # FIXME: not nullable?
919 clone_uri = Column(String(255), nullable=True) # FIXME: not nullable?
@@ -1337,7 +1337,7 b' class RepoGroup(meta.Base, BaseDbModel):'
1337 SEP = ' » '
1337 SEP = ' » '
1338
1338
1339 group_id = Column(Integer(), primary_key=True)
1339 group_id = Column(Integer(), primary_key=True)
1340 group_name = Column(Unicode(255), nullable=False, unique=True) # full path
1340 group_name = Column(Unicode(255), nullable=False, unique=True) # full path, must be updated (based on get_new_name) when name or path changes
1341 parent_group_id = Column('group_parent_id', Integer(), ForeignKey('groups.group_id'), nullable=True)
1341 parent_group_id = Column('group_parent_id', Integer(), ForeignKey('groups.group_id'), nullable=True)
1342 group_description = Column(Unicode(10000), nullable=False)
1342 group_description = Column(Unicode(10000), nullable=False)
1343 owner_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
1343 owner_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
@@ -278,9 +278,8 b' class RepoGroupModel(object):'
278 def update(self, repo_group, repo_group_args):
278 def update(self, repo_group, repo_group_args):
279 try:
279 try:
280 repo_group = db.RepoGroup.guess_instance(repo_group)
280 repo_group = db.RepoGroup.guess_instance(repo_group)
281 old_path = repo_group.full_path
281 old_path = repo_group.full_path # aka .group_name
282
282
283 # change properties
284 if 'owner' in repo_group_args:
283 if 'owner' in repo_group_args:
285 repo_group.owner = db.User.get_by_username(repo_group_args['owner'])
284 repo_group.owner = db.User.get_by_username(repo_group_args['owner'])
286 if 'group_description' in repo_group_args:
285 if 'group_description' in repo_group_args:
@@ -297,26 +296,23 b' class RepoGroupModel(object):'
297 new_path = repo_group.full_path
296 new_path = repo_group.full_path
298 meta.Session().add(repo_group)
297 meta.Session().add(repo_group)
299
298
300 # iterate over all members of this groups and do fixes
299 # Iterate over all members of this repo group and update the full
301 # if obj is a repoGroup also fix the name of the group according
300 # path (repo_name and group_name) based on the (already updated)
302 # to the parent
301 # full path of the parent.
303 # if obj is a Repo fix it's name
302 # This can potentially be a heavy operation.
304 # this can be potentially heavy operation
305 for obj in repo_group.recursive_groups_and_repos():
303 for obj in repo_group.recursive_groups_and_repos():
306 # set the value from it's parent
307 if isinstance(obj, db.RepoGroup):
304 if isinstance(obj, db.RepoGroup):
308 new_name = obj.get_new_name(obj.name)
305 new_name = obj.get_new_name(obj.name)
309 log.debug('Fixing group %s to new name %s'
306 log.debug('Fixing group %s to new name %s'
310 % (obj.group_name, new_name))
307 % (obj.group_name, new_name))
311 obj.group_name = new_name
308 obj.group_name = new_name
312 elif isinstance(obj, db.Repository):
309 elif isinstance(obj, db.Repository):
313 # we need to get all repositories from this new group and
314 # rename them accordingly to new group path
315 new_name = obj.get_new_name(obj.just_name)
310 new_name = obj.get_new_name(obj.just_name)
316 log.debug('Fixing repo %s to new name %s'
311 log.debug('Fixing repo %s to new name %s'
317 % (obj.repo_name, new_name))
312 % (obj.repo_name, new_name))
318 obj.repo_name = new_name
313 obj.repo_name = new_name
319
314
315 # Rename in file system
320 self._rename_group(old_path, new_path)
316 self._rename_group(old_path, new_path)
321
317
322 return repo_group
318 return repo_group
General Comments 0
You need to be logged in to leave comments. Login now