Skip to content

Commit

Permalink
Fixed redefine-root checking to recognize if the impossible situation…
Browse files Browse the repository at this point in the history
… of the root directory being moved from somewhere would occur.
  • Loading branch information
dsuni committed Oct 25, 2017
1 parent dffbf05 commit 1f097b9
Show file tree
Hide file tree
Showing 4 changed files with 501 additions and 4 deletions.
16 changes: 12 additions & 4 deletions svndumpsanitizer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
svndumpsanitizer version 2.0.4, released 21 Aug 2017
svndumpsanitizer version 2.0.5, released 25 Oct 2017
Copyright 2011,2012,2013,2014,2015,2016,2017 Daniel Suni
Expand Down Expand Up @@ -33,7 +33,7 @@
#include <string.h>
#include <time.h>

#define SDS_VERSION "2.0.4"
#define SDS_VERSION "2.0.5"
#define ADD 0
#define CHANGE 1
#define DELETE 2
Expand Down Expand Up @@ -1527,12 +1527,20 @@ int main(int argc, char **argv) {

// Remove any directory entries that should no longer exist with the redefined root
if (redefined_root) {
// First check whether the redefining even has a chance to succeed. If we have a redefined root of
// "trunk/foo", and then try to do a copyfrom operation from "trunk", we're pretty much doomed...
// First check whether the redefining even has a chance to succeed.
for (i = 0; i < rev_len; ++i) {
for (j = 0; j < revisions[i].size; ++j) {
if (revisions[i].nodes[j].copyfrom && revisions[i].nodes[j].wanted) {
// If we're trying to copy the (new) root directory itself from somewhere, it won't work.
if (strcmp(revisions[i].nodes[j].path, redefined_root) == 0) {
fprintf(stderr, "WARNING: Detected move operation of the redefined root directory.\n Redefine operation will not be performed.\n");
redefined_root = NULL;
goto write_out;
}
// If we have a redefined root of "trunk/foo", and then try to do a copyfrom
// operation from "trunk", we're pretty much doomed...
temp_str = reduce_path(redefined_root, revisions[i].nodes[j].copyfrom);
printf("Test: %s %s %s\n", temp_str, revisions[i].nodes[j].path, redefined_root);
if (strcmp(temp_str, "") == 0 && strcmp(redefined_root, revisions[i].nodes[j].copyfrom) != 0) {
fprintf(stderr, "WARNING: Critical files detected upstream of redefined root.\n Redefine operation will not be performed.\n");
redefined_root = NULL;
Expand Down
231 changes: 231 additions & 0 deletions tests/test_redefine_root_move/facit.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
SVN-fs-dump-format-version: 2

UUID: 496b2440-ecb8-4940-b495-ae5874e104ef

Revision-number: 0
Prop-content-length: 56
Content-length: 56

K 8
svn:date
V 27
2017-10-22T11:18:43.996089Z
PROPS-END

Revision-number: 1
Prop-content-length: 125
Content-length: 125

K 10
svn:author
V 9
christian
K 8
svn:date
V 27
2017-10-22T11:20:11.886637Z
K 7
svn:log
V 21
folder for customer 1
PROPS-END

Node-path: customer1
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END



Revision-number: 2
Prop-content-length: 124
Content-length: 124

K 10
svn:author
V 9
christian
K 8
svn:date
V 27
2017-10-22T11:20:58.488800Z
K 7
svn:log
V 20
folder for project 1
PROPS-END

Node-path: customer1/project1
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Revision-number: 3
Prop-content-length: 123
Content-length: 123

K 10
svn:author
V 9
christian
K 8
svn:date
V 27
2017-10-22T11:24:25.327070Z
K 7
svn:log
V 19
trunk for project 1
PROPS-END

Node-path: customer1/project1/trunk
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Revision-number: 4
Prop-content-length: 122
Content-length: 122

K 10
svn:author
V 9
christian
K 8
svn:date
V 27
2017-10-22T11:24:45.827604Z
K 7
svn:log
V 18
tags for project 1
PROPS-END

Node-path: customer1/project1/tags
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Revision-number: 5
Prop-content-length: 126
Content-length: 126

K 10
svn:author
V 9
christian
K 8
svn:date
V 27
2017-10-22T11:25:18.713327Z
K 7
svn:log
V 22
branches for project 1
PROPS-END

Node-path: customer1/project1/branches
Node-kind: dir
Node-action: add
Prop-content-length: 10
Content-length: 10

PROPS-END


Revision-number: 6
Prop-content-length: 128
Content-length: 128

K 10
svn:author
V 9
christian
K 8
svn:date
V 27
2017-10-22T11:26:54.423868Z
K 7
svn:log
V 24
ReadMe.txt for procect 1
PROPS-END

Node-path: customer1/project1/trunk/ReadMe.txt
Node-kind: file
Node-action: add
Prop-content-length: 10
Text-content-length: 47
Text-content-md5: b3b2af5932b2315b5231de440f119adc
Text-content-sha1: 972c7db08d4bb0f097f3fafe2a889adfccb2e24c
Content-length: 57

PROPS-END
some text for project one in the inital release

Revision-number: 7
Prop-content-length: 140
Content-length: 140

K 10
svn:author
V 9
christian
K 8
svn:date
V 27
2017-10-22T11:30:18.347041Z
K 7
svn:log
V 36
prapare to use one repo per customer
PROPS-END

Node-path: customer1/project1
Node-action: delete


Node-path: project1
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 6
Node-copyfrom-path: customer1/project1


Revision-number: 8
Prop-content-length: 140
Content-length: 140

K 10
svn:author
V 9
christian
K 8
svn:date
V 27
2017-10-22T11:30:36.684635Z
K 7
svn:log
V 36
prapare to use one repo per customer
PROPS-END

Node-path: customer1
Node-action: delete


1 change: 1 addition & 0 deletions tests/test_redefine_root_move/options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-n project1/trunk project1/tags project1/branches -d -r project1
Loading

0 comments on commit 1f097b9

Please sign in to comment.