# HG changeset patch # User Mads Kiilerich # Date 2022-12-21 23:15:38 # Node ID ff22ffbac5a3199f2e41aae465afb2f3b6007121 # Parent 11cae16e5a5d142e05024d6743452bae86407cba repo group: clarify comments diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -913,7 +913,7 @@ class Repository(meta.Base, BaseDbModel) STATE_ERROR = 'repo_state_error' repo_id = Column(Integer(), primary_key=True) - repo_name = Column(Unicode(255), nullable=False, unique=True) + repo_name = Column(Unicode(255), nullable=False, unique=True) # full path, must be updated (based on get_new_name) when name or path changes repo_state = Column(String(255), nullable=False) clone_uri = Column(String(255), nullable=True) # FIXME: not nullable? @@ -1337,7 +1337,7 @@ class RepoGroup(meta.Base, BaseDbModel): SEP = ' » ' group_id = Column(Integer(), primary_key=True) - group_name = Column(Unicode(255), nullable=False, unique=True) # full path + group_name = Column(Unicode(255), nullable=False, unique=True) # full path, must be updated (based on get_new_name) when name or path changes parent_group_id = Column('group_parent_id', Integer(), ForeignKey('groups.group_id'), nullable=True) group_description = Column(Unicode(10000), nullable=False) owner_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False) diff --git a/kallithea/model/repo_group.py b/kallithea/model/repo_group.py --- a/kallithea/model/repo_group.py +++ b/kallithea/model/repo_group.py @@ -278,9 +278,8 @@ class RepoGroupModel(object): def update(self, repo_group, repo_group_args): try: repo_group = db.RepoGroup.guess_instance(repo_group) - old_path = repo_group.full_path + old_path = repo_group.full_path # aka .group_name - # change properties if 'owner' in repo_group_args: repo_group.owner = db.User.get_by_username(repo_group_args['owner']) if 'group_description' in repo_group_args: @@ -297,26 +296,23 @@ class RepoGroupModel(object): new_path = repo_group.full_path meta.Session().add(repo_group) - # iterate over all members of this groups and do fixes - # if obj is a repoGroup also fix the name of the group according - # to the parent - # if obj is a Repo fix it's name - # this can be potentially heavy operation + # Iterate over all members of this repo group and update the full + # path (repo_name and group_name) based on the (already updated) + # full path of the parent. + # This can potentially be a heavy operation. for obj in repo_group.recursive_groups_and_repos(): - # set the value from it's parent if isinstance(obj, db.RepoGroup): new_name = obj.get_new_name(obj.name) log.debug('Fixing group %s to new name %s' % (obj.group_name, new_name)) obj.group_name = new_name elif isinstance(obj, db.Repository): - # we need to get all repositories from this new group and - # rename them accordingly to new group path new_name = obj.get_new_name(obj.just_name) log.debug('Fixing repo %s to new name %s' % (obj.repo_name, new_name)) obj.repo_name = new_name + # Rename in file system self._rename_group(old_path, new_path) return repo_group