From 70b22862e7efd9511cc39b479223aaacbb88c3c1 Mon Sep 17 00:00:00 2001 From: Torgny Nyblom Date: Mon, 13 Dec 2010 18:11:22 +0100 Subject: Delete before other changes Fix issue where if a branch reset was triggered before a branch deletion in the same revision the reset was overridden by the deletion --- src/svn.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/svn.cpp b/src/svn.cpp index 38e21dc..c7835ff 100644 --- a/src/svn.cpp +++ b/src/svn.cpp @@ -44,6 +44,8 @@ #include #include +#include +#include #include #include "repository.h" @@ -451,6 +453,7 @@ int SvnPrivate::exportRevision(int revnum) int SvnRevision::prepareTransactions() { + QLinkedList< QPair > sortedChanges; // find out what was changed in this revision: apr_hash_t *changes; SVN_ERR(svn_fs_paths_changed(&changes, fs_root, pool)); @@ -461,11 +464,20 @@ int SvnRevision::prepareTransactions() const char *key = reinterpret_cast(vkey); svn_fs_path_change_t *change = reinterpret_cast(value); - if (exportEntry(key, change, changes) == EXIT_FAILURE) - return EXIT_FAILURE; + // If we mix path deletions with path adds/replaces we might erase a branch after that it has been reset -> history truncated + if(change->change_kind == svn_fs_path_change_delete) { + sortedChanges.prepend( qMakePair(change, key) ); + } else { + sortedChanges.append( qMakePair(change, key) ); + } } - return EXIT_SUCCESS; + QPair pair; + foreach (pair, sortedChanges) { + if (exportEntry(pair.second, pair.first, changes) == EXIT_FAILURE) + return EXIT_FAILURE; + } + return EXIT_SUCCESS; } int SvnRevision::fetchRevProps() -- cgit v1.2.1