Skip to content

Commit 6a83f29

Browse files
Vampiretnyblom
authored andcommitted
Do not delete a whole branch if the repository the change is applied to has a prefix or forwards to a repository with prefix (#8)
1 parent 94779bf commit 6a83f29

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/repository.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class FastImportRepository : public Repository
8787
const QByteArray branchNote(const QString& branch) const;
8888
void setBranchNote(const QString& branch, const QByteArray& noteText);
8989

90+
bool hasPrefix() const;
9091
private:
9192
struct Branch
9293
{
@@ -200,6 +201,9 @@ class ForwardingRepository : public Repository
200201
{ return repo->branchNote(branch); }
201202
void setBranchNote(const QString& branch, const QByteArray& noteText)
202203
{ repo->setBranchNote(branch, noteText); }
204+
205+
bool hasPrefix() const
206+
{ return !prefix.isEmpty() || repo->hasPrefix(); }
203207
};
204208

205209
class ProcessCache: QLinkedList<FastImportRepository *>
@@ -766,6 +770,11 @@ void FastImportRepository::setBranchNote(const QString& branch, const QByteArray
766770
branches[branch].note = noteText;
767771
}
768772

773+
bool FastImportRepository::hasPrefix() const
774+
{
775+
return !prefix.isEmpty();
776+
}
777+
769778
FastImportRepository::Transaction::~Transaction()
770779
{
771780
repository->forgetTransaction(this);

src/repository.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ class Repository
137137
virtual bool branchExists(const QString& branch) const = 0;
138138
virtual const QByteArray branchNote(const QString& branch) const = 0;
139139
virtual void setBranchNote(const QString& branch, const QByteArray& noteText) = 0;
140+
141+
virtual bool hasPrefix() const = 0;
140142
};
141143

142144
Repository *createRepository(const Rules::Repository &rule, const QHash<QString, Repository *> &repositories);

src/svn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ int SvnRevision::exportInternal(const char *key, const svn_fs_path_change_t *cha
706706
// qDebug() << " " << qPrintable(current) << "rev" << revnum << "->"
707707
// << qPrintable(repository) << qPrintable(branch) << qPrintable(path);
708708

709-
if (change->change_kind == svn_fs_path_change_delete && current == svnprefix && path.isEmpty()) {
709+
if (change->change_kind == svn_fs_path_change_delete && current == svnprefix && path.isEmpty() && !repo->hasPrefix()) {
710710
if(ruledebug)
711711
qDebug() << "repository" << repository << "branch" << branch << "deleted";
712712
return repo->deleteBranch(branch, revnum);

0 commit comments

Comments
 (0)