From 3b270cf149ee67bcf2dace4edec34c91abe13bc5 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sat, 24 May 2014 23:31:39 +0100 Subject: 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. --- src/svn.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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 #include +#include #include #include @@ -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; -- cgit v1.2.1