diff options
author | Colin Guthrie <colin@mageia.org> | 2014-05-24 23:31:39 +0100 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2014-05-24 23:31:39 +0100 |
commit | 3b270cf149ee67bcf2dace4edec34c91abe13bc5 (patch) | |
tree | a29135c3b4db4390f3db93185ce7655752369a98 | |
parent | 41fbc8cbd2e559f3d9590747bef7d37c426e3f65 (diff) | |
download | svn2git-3b270cf149ee67bcf2dace4edec34c91abe13bc5.tar svn2git-3b270cf149ee67bcf2dace4edec34c91abe13bc5.tar.gz svn2git-3b270cf149ee67bcf2dace4edec34c91abe13bc5.tar.bz2 svn2git-3b270cf149ee67bcf2dace4edec34c91abe13bc5.tar.xz svn2git-3b270cf149ee67bcf2dace4edec34c91abe13bc5.zip |
Handle master branch deletion.
If the master branch is deleted, this typically means we are obsoleting our
package.
Rather than 'deal' with the branch deletion, simply rename the repository
and then continue.
We will likely have to deal with a later resurrection and also deal with
package renames better too (e.g. one commit renames and resurrecting
a specific package that was subsequently brought back from the dead)
but this will be dealt with in a later commit.
-rw-r--r-- | src/svn.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/svn.cpp b/src/svn.cpp index f63219b..ed49f48 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -43,6 +43,7 @@ #include <svn_repos.h> #include <svn_types.h> +#include <QDir> #include <QFile> #include <QDebug> @@ -717,7 +718,29 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha if (change->change_kind == svn_fs_path_change_delete && current == svnprefix && path.isEmpty()) { if(ruledebug) qDebug() << "repository" << repository << "branch" << branch << "deleted"; - return repo->deleteBranch(branch, revnum); + + + if ("master" != branch) { + 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; + return EXIT_FAILURE; + } + + repositories->remove(repository); + repositories->insert(newreponame, repo); + return EXIT_SUCCESS; } QString previous; |