diff options
| author | Colin Guthrie <colin@mageia.org> | 2014-05-28 23:34:35 +0100 | 
|---|---|---|
| committer | Colin Guthrie <colin@mageia.org> | 2014-05-28 23:50:40 +0100 | 
| commit | 1dbf0a91195c6e8bd4404cc6b922ba35dd5e9b4e (patch) | |
| tree | 7369e927673164a656d12a84543dbabfa7873d16 | |
| parent | 3b270cf149ee67bcf2dace4edec34c91abe13bc5 (diff) | |
| download | svn2git-1dbf0a91195c6e8bd4404cc6b922ba35dd5e9b4e.tar svn2git-1dbf0a91195c6e8bd4404cc6b922ba35dd5e9b4e.tar.gz svn2git-1dbf0a91195c6e8bd4404cc6b922ba35dd5e9b4e.tar.bz2 svn2git-1dbf0a91195c6e8bd4404cc6b922ba35dd5e9b4e.tar.xz svn2git-1dbf0a91195c6e8bd4404cc6b922ba35dd5e9b4e.zip | |
Move the repo renaming to a method for convenience.
This also renames log and marks files.
| -rw-r--r-- | src/repository.cpp | 34 | ||||
| -rw-r--r-- | src/repository.h | 1 | ||||
| -rw-r--r-- | src/svn.cpp | 13 | 
3 files changed, 36 insertions, 12 deletions
| diff --git a/src/repository.cpp b/src/repository.cpp index 2fbe2a5..f6ee98a 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -127,6 +127,40 @@ static QString logFileName(QString name)      return name;  } +bool Repository::rename(const QString &newName) +{ +    if (!QDir(name).exists()) { // repo doesn't exist yet. +        qCritical() << "Cannot find repository dir for" << name; +        return false; +    } + +    qDebug() << "repository" << name << "deleted - renaming repo with revision number suffix" << newName; +    if (!QFile::rename(name, newName)) { +        qCritical() << "Could not rename repository dir for" << name; +        return false; +    } + +    if (!QFile::rename(logFileName(name), logFileName(newName))) { +        qCritical() << "Could not rename logfile for repository" << name; +        return false; +    } + +    closeFastImport(); + +    if (!QFile::rename(newName + "/" + marksFileName(name), newName + "/" + marksFileName(newName))) { +        qCritical() << "Could not rename marks file for repository" << name; +        return false; +    } + +    name = newName; + +    // fastImport will be restarted on next txn +    fastImport.setWorkingDirectory(name); + +    return true; +} + +  static int lastValidMark(QString name)  {      QFile marksfile(name + "/" + marksFileName(name)); diff --git a/src/repository.h b/src/repository.h index c5a289b..b0bbff7 100644 --- a/src/repository.h +++ b/src/repository.h @@ -132,6 +132,7 @@ public:      };      Repository(const Rules::Repository &rule);      Repository(const QString &name, const QString &branchName, int revision); +    bool rename(const QString &newName);      int setupIncremental(int &cutoff);      void restoreLog();      ~Repository(); diff --git a/src/svn.cpp b/src/svn.cpp index ed49f48..72f73cd 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -724,20 +724,9 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha              return repo->deleteBranch(branch, revnum);          } -        // Master is deleted, which generally means we're obsoleting our package -        // Rename the repository instead (and keep the revision number in-case it's -        // resurrected later -        if (!QDir(repository).exists()) { // repo doesn't exist yet. -            qCritical() << "Cannot find repository dir for" << repository; -            return EXIT_FAILURE; -        } -          QString newreponame = repository + "-r" + QString::number(revnum); -        if (!QFile::rename(repository, newreponame)) { -            qCritical() << "Could not rename repository dir for" << repository; +        if (!repo->rename(newreponame))              return EXIT_FAILURE; -        } -          repositories->remove(repository);          repositories->insert(newreponame, repo);          return EXIT_SUCCESS; | 
