Changeset - 0f4402c519ff
[Not reviewed]
default
0 2 0
Mads Kiilerich - 12 years ago 2013-12-10 19:30:37
madski@unity3d.com
remove: when removing a repo don't rename its .hg/.git folder

There is no need to do that ... and doing it will just make analysis and
recovery harder and confuse other tools recursing the repos, such as hgweb.
2 files changed with 7 insertions and 19 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/utils/helpers.py
Show inline comments
 
@@ -75,10 +75,12 @@ def get_scms_for_path(path):
 

	
 
    result = []
 
    for key in ALIASES:
 
        # find .hg / .git
 
        dirname = os.path.join(path, '.' + key)
 
        if os.path.isdir(dirname):
 
            result.append(key)
 
            continue
 
        # find rm__.hg / rm__.git too - left overs from old method for deleting
 
        dirname = os.path.join(path, 'rm__.' + key)
 
        if os.path.isdir(dirname):
 
            return result
kallithea/model/repo.py
Show inline comments
 
@@ -762,26 +762,14 @@ class RepoModel(BaseModel):
 

	
 
    def _delete_filesystem_repo(self, repo):
 
        """
 
        removes repo from filesystem, the removal is acctually made by
 
        added rm__ prefix into dir, and rename internat .hg/.git dirs so this
 
        repository is no longer valid for kallithea, can be undeleted later on
 
        by reverting the renames on this repository
 
        removes repo from filesystem, the removal is actually done by
 
        renaming dir to a 'rm__*' prefix which Kallithea will skip.
 
        It can be undeleted later by reverting the rename.
 

	
 
        :param repo: repo object
 
        """
 
        rm_path = os.path.join(self.repos_path, repo.repo_name)
 
        log.info("Removing repository %s" % (rm_path,))
 
        # disable hg/git internal that it doesn't get detected as repo
 
        alias = repo.repo_type
 

	
 
        bare = getattr(repo.scm_instance, 'bare', False)
 

	
 
        # skip this for bare git repos
 
        if not bare:
 
            # disable VCS repo
 
            vcs_path = os.path.join(rm_path, '.%s' % alias)
 
            if os.path.exists(vcs_path):
 
                shutil.move(vcs_path, os.path.join(rm_path, 'rm__.%s' % alias))
 
        log.info("Removing %s" % (rm_path))
 

	
 
        _now = datetime.now()
 
        _ms = str(_now.microsecond).rjust(6, '0')
 
@@ -790,6 +778,4 @@ class RepoModel(BaseModel):
 
        if repo.group:
 
            args = repo.group.full_path_splitted + [_d]
 
            _d = os.path.join(*args)
 

	
 
        if os.path.isdir(rm_path):
 
            shutil.move(rm_path, os.path.join(self.repos_path, _d))
 
        shutil.move(rm_path, os.path.join(self.repos_path, _d))
0 comments (0 inline, 0 general)