Code

Merge commit 'jn/svn-fe' of git://github.com/gitster/git into svn-fe
authorJonathan Nieder <jrnieder@gmail.com>
Sat, 26 Feb 2011 11:21:29 +0000 (05:21 -0600)
committerJonathan Nieder <jrnieder@gmail.com>
Sat, 26 Feb 2011 11:21:29 +0000 (05:21 -0600)
* git://github.com/gitster/git:
  vcs-svn: Allow change nodes for root of tree (/)
  vcs-svn: Implement Prop-delta handling
  vcs-svn: Sharpen parsing of property lines
  vcs-svn: Split off function for handling of individual properties
  vcs-svn: Make source easier to read on small screens
  vcs-svn: More dump format sanity checks
  vcs-svn: Reject path nodes without Node-action
  vcs-svn: Delay read of per-path properties
  vcs-svn: Combine repo_replace and repo_modify functions
  vcs-svn: Replace = Delete + Add
  vcs-svn: handle_node: Handle deletion case early
  vcs-svn: Use mark to indicate nodes with included text
  vcs-svn: Unclutter handle_node by introducing have_props var
  vcs-svn: Eliminate node_ctx.mark global
  vcs-svn: Eliminate node_ctx.srcRev global
  vcs-svn: Check for errors from open()
  vcs-svn: Allow simple v3 dumps (no deltas yet)

Conflicts:
t/t9010-svn-fe.sh
vcs-svn/svndump.c

1  2 
t/t9010-svn-fe.sh
vcs-svn/repo_tree.c
vcs-svn/svndump.c

index 88a9751dd3c73a39a15ec3d18d3dddb7790706bb,87945073b0de3411dd4d80ffd61aae4b63a06ba2..5a6a4b9b7a6e6abbb9570ddceaac68baf5c2690b
@@@ -25,21 -49,682 +49,694 @@@ test_expect_success 'v4 dumps not suppo
        test_cmp empty stream
  '
  
 -test_expect_success 't9135/svn.dump' '
 -      svnadmin create simple-svn &&
 -      svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" &&
 -      svn_cmd export "file://$PWD/simple-svn" simple-svnco &&
+ test_expect_failure 'empty revision' '
+       reinit_git &&
+       printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
+       cat >emptyrev.dump <<-\EOF &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 0
+       Content-length: 0
+       Revision-number: 2
+       Prop-content-length: 0
+       Content-length: 0
+       EOF
+       test-svn-fe emptyrev.dump >stream &&
+       git fast-import <stream &&
+       git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
+       test_cmp expect actual
+ '
+ test_expect_success 'empty properties' '
+       reinit_git &&
+       printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
+       cat >emptyprop.dump <<-\EOF &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Revision-number: 2
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       EOF
+       test-svn-fe emptyprop.dump >stream &&
+       git fast-import <stream &&
+       git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
+       test_cmp expect actual
+ '
+ test_expect_success 'author name and commit message' '
+       reinit_git &&
+       echo "<author@example.com, author@example.com@local>" >expect.author &&
+       cat >message <<-\EOF &&
+       A concise summary of the change
+       A detailed description of the change, why it is needed, what
+       was broken and why applying this is the best course of action.
+       * file.c
+           Details pertaining to an individual file.
+       EOF
+       {
+               properties \
+                       svn:author author@example.com \
+                       svn:log "$(cat message)" &&
+               echo PROPS-END
+       } >props &&
+       {
+               echo "SVN-fs-dump-format-version: 3" &&
+               echo &&
+               echo "Revision-number: 1" &&
+               echo Prop-content-length: $(wc -c <props) &&
+               echo Content-length: $(wc -c <props) &&
+               echo &&
+               cat props
+       } >log.dump &&
+       test-svn-fe log.dump >stream &&
+       git fast-import <stream &&
+       git log -p --format="%B" HEAD >actual.log &&
+       git log --format="<%an, %ae>" >actual.author &&
+       test_cmp message actual.log &&
+       test_cmp expect.author actual.author
+ '
+ test_expect_success 'unsupported properties are ignored' '
+       reinit_git &&
+       echo author >expect &&
+       cat >extraprop.dump <<-\EOF &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 56
+       Content-length: 56
+       K 8
+       nonsense
+       V 1
+       y
+       K 10
+       svn:author
+       V 6
+       author
+       PROPS-END
+       EOF
+       test-svn-fe extraprop.dump >stream &&
+       git fast-import <stream &&
+       git log -p --format=%an HEAD >actual &&
+       test_cmp expect actual
+ '
+ test_expect_failure 'timestamp and empty file' '
+       echo author@example.com >expect.author &&
+       echo 1999-01-01 >expect.date &&
+       echo file >expect.files &&
+       reinit_git &&
+       {
+               properties \
+                       svn:author author@example.com \
+                       svn:date "1999-01-01T00:01:002.000000Z" \
+                       svn:log "add empty file" &&
+               echo PROPS-END
+       } >props &&
+       {
+               cat <<-EOF &&
+               SVN-fs-dump-format-version: 3
+               Revision-number: 1
+               EOF
+               echo Prop-content-length: $(wc -c <props) &&
+               echo Content-length: $(wc -c <props) &&
+               echo &&
+               cat props &&
+               cat <<-\EOF
+               Node-path: empty-file
+               Node-kind: file
+               Node-action: add
+               Content-length: 0
+               EOF
+       } >emptyfile.dump &&
+       test-svn-fe emptyfile.dump >stream &&
+       git fast-import <stream &&
+       git log --format=%an HEAD >actual.author &&
+       git log --date=short --format=%ad HEAD >actual.date &&
+       git ls-tree -r --name-only HEAD >actual.files &&
+       test_cmp expect.author actual.author &&
+       test_cmp expect.date actual.date &&
+       test_cmp expect.files actual.files &&
+       git checkout HEAD empty-file &&
+       test_cmp empty file
+ '
+ test_expect_success 'directory with files' '
+       reinit_git &&
+       printf "%s\n" directory/file1 directory/file2 >expect.files &&
+       echo hi >hi &&
+       echo hello >hello &&
+       {
+               properties \
+                       svn:author author@example.com \
+                       svn:date "1999-02-01T00:01:002.000000Z" \
+                       svn:log "add directory with some files in it" &&
+               echo PROPS-END
+       } >props &&
+       {
+               cat <<-EOF &&
+               SVN-fs-dump-format-version: 3
+               Revision-number: 1
+               EOF
+               echo Prop-content-length: $(wc -c <props) &&
+               echo Content-length: $(wc -c <props) &&
+               echo &&
+               cat props &&
+               cat <<-\EOF &&
+               Node-path: directory
+               Node-kind: dir
+               Node-action: add
+               Prop-content-length: 10
+               Content-length: 10
+               PROPS-END
+               Node-path: directory/file1
+               Node-kind: file
+               Node-action: add
+               EOF
+               text_no_props hello &&
+               cat <<-\EOF &&
+               Node-path: directory/file2
+               Node-kind: file
+               Node-action: add
+               EOF
+               text_no_props hi
+       } >directory.dump &&
+       test-svn-fe directory.dump >stream &&
+       git fast-import <stream &&
+       git ls-tree -r --name-only HEAD >actual.files &&
+       git checkout HEAD directory &&
+       test_cmp expect.files actual.files &&
+       test_cmp hello directory/file1 &&
+       test_cmp hi directory/file2
+ '
+ test_expect_success 'node without action' '
+       cat >inaction.dump <<-\EOF &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: directory
+       Node-kind: dir
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       EOF
+       test_must_fail test-svn-fe inaction.dump
+ '
+ test_expect_success 'action: add node without text' '
+       cat >textless.dump <<-\EOF &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: textless
+       Node-kind: file
+       Node-action: add
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       EOF
+       test_must_fail test-svn-fe textless.dump
+ '
+ test_expect_failure 'change file mode but keep old content' '
+       reinit_git &&
+       cat >expect <<-\EOF &&
+       OBJID
+       :120000 100644 OBJID OBJID T    greeting
+       OBJID
+       :100644 120000 OBJID OBJID T    greeting
+       OBJID
+       :000000 100644 OBJID OBJID A    greeting
+       EOF
+       echo "link hello" >expect.blob &&
+       echo hello >hello &&
+       cat >filemode.dump <<-\EOF &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: greeting
+       Node-kind: file
+       Node-action: add
+       Prop-content-length: 10
+       Text-content-length: 11
+       Content-length: 21
+       PROPS-END
+       link hello
+       Revision-number: 2
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: greeting
+       Node-kind: file
+       Node-action: change
+       Prop-content-length: 33
+       Content-length: 33
+       K 11
+       svn:special
+       V 1
+       *
+       PROPS-END
+       Revision-number: 3
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: greeting
+       Node-kind: file
+       Node-action: change
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       EOF
+       test-svn-fe filemode.dump >stream &&
+       git fast-import <stream &&
+       {
+               git rev-list HEAD |
+               git diff-tree --root --stdin |
+               sed "s/$_x40/OBJID/g"
+       } >actual &&
+       git show HEAD:greeting >actual.blob &&
+       git show HEAD^:greeting >actual.target &&
+       test_cmp expect actual &&
+       test_cmp expect.blob actual.blob &&
+       test_cmp hello actual.target
+ '
+ test_expect_success 'change file mode and reiterate content' '
+       reinit_git &&
+       cat >expect <<-\EOF &&
+       OBJID
+       :120000 100644 OBJID OBJID T    greeting
+       OBJID
+       :100644 120000 OBJID OBJID T    greeting
+       OBJID
+       :000000 100644 OBJID OBJID A    greeting
+       EOF
+       echo "link hello" >expect.blob &&
+       echo hello >hello &&
+       cat >filemode.dump <<-\EOF &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: greeting
+       Node-kind: file
+       Node-action: add
+       Prop-content-length: 10
+       Text-content-length: 11
+       Content-length: 21
+       PROPS-END
+       link hello
+       Revision-number: 2
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: greeting
+       Node-kind: file
+       Node-action: change
+       Prop-content-length: 33
+       Text-content-length: 11
+       Content-length: 44
+       K 11
+       svn:special
+       V 1
+       *
+       PROPS-END
+       link hello
+       Revision-number: 3
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: greeting
+       Node-kind: file
+       Node-action: change
+       Prop-content-length: 10
+       Text-content-length: 11
+       Content-length: 21
+       PROPS-END
+       link hello
+       EOF
+       test-svn-fe filemode.dump >stream &&
+       git fast-import <stream &&
+       {
+               git rev-list HEAD |
+               git diff-tree --root --stdin |
+               sed "s/$_x40/OBJID/g"
+       } >actual &&
+       git show HEAD:greeting >actual.blob &&
+       git show HEAD^:greeting >actual.target &&
+       test_cmp expect actual &&
+       test_cmp expect.blob actual.blob &&
+       test_cmp hello actual.target
+ '
+ test_expect_success 'deltas not supported' '
+       {
+               # (old) h + (inline) ello + (old) \n
+               printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" |
+               q_to_nul
+       } >delta &&
+       {
+               properties \
+                       svn:author author@example.com \
+                       svn:date "1999-01-05T00:01:002.000000Z" \
+                       svn:log "add greeting" &&
+               echo PROPS-END
+       } >props &&
+       {
+               properties \
+                       svn:author author@example.com \
+                       svn:date "1999-01-06T00:01:002.000000Z" \
+                       svn:log "change it" &&
+               echo PROPS-END
+       } >props2 &&
+       {
+               echo SVN-fs-dump-format-version: 3 &&
+               echo &&
+               echo Revision-number: 1 &&
+               echo Prop-content-length: $(wc -c <props) &&
+               echo Content-length: $(wc -c <props) &&
+               echo &&
+               cat props &&
+               cat <<-\EOF &&
+               Node-path: hello
+               Node-kind: file
+               Node-action: add
+               Prop-content-length: 10
+               Text-content-length: 3
+               Content-length: 13
+               PROPS-END
+               hi
+               EOF
+               echo Revision-number: 2 &&
+               echo Prop-content-length: $(wc -c <props2) &&
+               echo Content-length: $(wc -c <props2) &&
+               echo &&
+               cat props2 &&
+               cat <<-\EOF &&
+               Node-path: hello
+               Node-kind: file
+               Node-action: change
+               Text-delta: true
+               Prop-content-length: 10
+               EOF
+               echo Text-content-length: $(wc -c <delta) &&
+               echo Content-length: $((10 + $(wc -c <delta))) &&
+               echo &&
+               echo PROPS-END &&
+               cat delta
+       } >delta.dump &&
+       test_must_fail test-svn-fe delta.dump
+ '
+ test_expect_success 'property deltas supported' '
+       reinit_git &&
+       cat >expect <<-\EOF &&
+       OBJID
+       :100755 100644 OBJID OBJID M    script.sh
+       EOF
+       {
+               properties \
+                       svn:author author@example.com \
+                       svn:date "1999-03-06T00:01:002.000000Z" \
+                       svn:log "make an executable, or chmod -x it" &&
+               echo PROPS-END
+       } >revprops &&
+       {
+               echo SVN-fs-dump-format-version: 3 &&
+               echo &&
+               echo Revision-number: 1 &&
+               echo Prop-content-length: $(wc -c <revprops) &&
+               echo Content-length: $(wc -c <revprops) &&
+               echo &&
+               cat revprops &&
+               echo &&
+               cat <<-\EOF &&
+               Node-path: script.sh
+               Node-kind: file
+               Node-action: add
+               Text-content-length: 0
+               Prop-content-length: 39
+               Content-length: 39
+               K 14
+               svn:executable
+               V 4
+               true
+               PROPS-END
+               EOF
+               echo Revision-number: 2 &&
+               echo Prop-content-length: $(wc -c <revprops) &&
+               echo Content-length: $(wc -c <revprops) &&
+               echo &&
+               cat revprops &&
+               echo &&
+               cat <<-\EOF
+               Node-path: script.sh
+               Node-kind: file
+               Node-action: change
+               Prop-delta: true
+               Prop-content-length: 30
+               Content-length: 30
+               D 14
+               svn:executable
+               PROPS-END
+               EOF
+       } >propdelta.dump &&
+       test-svn-fe propdelta.dump >stream &&
+       git fast-import <stream &&
+       {
+               git rev-list HEAD |
+               git diff-tree --stdin |
+               sed "s/$_x40/OBJID/g"
+       } >actual &&
+       test_cmp expect actual
+ '
+ test_expect_success 'properties on /' '
+       reinit_git &&
+       cat <<-\EOF >expect &&
+       OBJID
+       OBJID
+       :000000 100644 OBJID OBJID A    greeting
+       EOF
+       sed -e "s/X$//" <<-\EOF >changeroot.dump &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: greeting
+       Node-kind: file
+       Node-action: add
+       Text-content-length: 0
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Revision-number: 2
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: X
+       Node-kind: dir
+       Node-action: change
+       Prop-delta: true
+       Prop-content-length: 43
+       Content-length: 43
+       K 10
+       svn:ignore
+       V 11
+       build-area
+       PROPS-END
+       EOF
+       test-svn-fe changeroot.dump >stream &&
+       git fast-import <stream &&
+       {
+               git rev-list HEAD |
+               git diff-tree --root --always --stdin |
+               sed "s/$_x40/OBJID/g"
+       } >actual &&
+       test_cmp expect actual
+ '
+ test_expect_success 'deltas for typechange' '
+       reinit_git &&
+       cat >expect <<-\EOF &&
+       OBJID
+       :120000 100644 OBJID OBJID T    test-file
+       OBJID
+       :100755 120000 OBJID OBJID T    test-file
+       OBJID
+       :000000 100755 OBJID OBJID A    test-file
+       EOF
+       cat >deleteprop.dump <<-\EOF &&
+       SVN-fs-dump-format-version: 3
+       Revision-number: 1
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: test-file
+       Node-kind: file
+       Node-action: add
+       Prop-delta: true
+       Prop-content-length: 35
+       Text-content-length: 17
+       Content-length: 52
+       K 14
+       svn:executable
+       V 0
+       PROPS-END
+       link testing 123
+       Revision-number: 2
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: test-file
+       Node-kind: file
+       Node-action: change
+       Prop-delta: true
+       Prop-content-length: 53
+       Text-content-length: 17
+       Content-length: 70
+       K 11
+       svn:special
+       V 1
+       *
+       D 14
+       svn:executable
+       PROPS-END
+       link testing 231
+       Revision-number: 3
+       Prop-content-length: 10
+       Content-length: 10
+       PROPS-END
+       Node-path: test-file
+       Node-kind: file
+       Node-action: change
+       Prop-delta: true
+       Prop-content-length: 27
+       Text-content-length: 17
+       Content-length: 44
+       D 11
+       svn:special
+       PROPS-END
+       link testing 321
+       EOF
+       test-svn-fe deleteprop.dump >stream &&
+       git fast-import <stream &&
+       {
+               git rev-list HEAD |
+               git diff-tree --root --stdin |
+               sed "s/$_x40/OBJID/g"
+       } >actual &&
+       test_cmp expect actual
+ '
++
 +test_expect_success 'set up svn repo' '
 +      svnconf=$PWD/svnconf &&
 +      mkdir -p "$svnconf" &&
 +
 +      if
 +              svnadmin -h >/dev/null 2>&1 &&
 +              svnadmin create simple-svn &&
 +              svnadmin load simple-svn <"$TEST_DIRECTORY/t9135/svn.dump" &&
 +              svn export --config-dir "$svnconf" "file://$PWD/simple-svn" simple-svnco
 +      then
 +              test_set_prereq SVNREPO
 +      fi
 +'
 +
 +test_expect_success SVNREPO 't9135/svn.dump' '
        git init simple-git &&
        test-svn-fe "$TEST_DIRECTORY/t9135/svn.dump" >simple.fe &&
        (
Simple merge
index 4195da9cf8000ec3e01fcaa6c1564188497b862b,1669d0fa5e01d54150981c861920d7b6d122392d..ee7c0bb2ea869c66cdbab4f4f23a0d2207e6b27d
@@@ -30,9 -30,7 +30,9 @@@
  /* Create memory pool for log messages */
  obj_pool_gen(log, char, 4096)
  
- static char* log_copy(uint32_t length, char *log)
 +static struct line_buffer input = LINE_BUFFER_INIT;
 +
+ static char *log_copy(uint32_t length, const char *log)
  {
        char *buffer;
        log_free(log_pool.size);
@@@ -113,78 -149,108 +151,109 @@@ static void handle_property(uint32_t ke
  
  static void read_props(void)
  {
-       uint32_t len;
        uint32_t key = ~0;
-       char *val = NULL;
-       char *t;
+       const char *t;
+       /*
+        * NEEDSWORK: to support simple mode changes like
+        *      K 11
+        *      svn:special
+        *      V 1
+        *      *
+        *      D 14
+        *      svn:executable
+        * we keep track of whether a mode has been set and reset to
+        * plain file only if not.  We should be keeping track of the
+        * symlink and executable bits separately instead.
+        */
+       uint32_t type_set = 0;
 -      while ((t = buffer_read_line()) && strcmp(t, "PROPS-END")) {
 +      while ((t = buffer_read_line(&input)) && strcmp(t, "PROPS-END")) {
-               if (!strncmp(t, "K ", 2)) {
-                       len = atoi(&t[2]);
-                       key = pool_intern(buffer_read_string(&input, len));
-                       buffer_read_line(&input);
-               } else if (!strncmp(t, "V ", 2)) {
-                       len = atoi(&t[2]);
-                       val = buffer_read_string(&input, len);
-                       if (key == keys.svn_log) {
-                               /* Value length excludes terminating nul. */
-                               rev_ctx.log = log_copy(len + 1, val);
-                       } else if (key == keys.svn_author) {
-                               rev_ctx.author = pool_intern(val);
-                       } else if (key == keys.svn_date) {
-                               if (parse_date_basic(val, &rev_ctx.timestamp, NULL))
-                                       fprintf(stderr, "Invalid timestamp: %s\n", val);
-                       } else if (key == keys.svn_executable) {
-                               node_ctx.type = REPO_MODE_EXE;
-                       } else if (key == keys.svn_special) {
-                               node_ctx.type = REPO_MODE_LNK;
-                       }
+               uint32_t len;
+               const char *val;
+               const char type = t[0];
+               if (!type || t[1] != ' ')
+                       die("invalid property line: %s\n", t);
+               len = atoi(&t[2]);
 -              val = buffer_read_string(len);
 -              buffer_skip_bytes(1);   /* Discard trailing newline. */
++              val = buffer_read_string(&input, len);
++              buffer_skip_bytes(&input, 1);   /* Discard trailing newline. */
+               switch (type) {
+               case 'K':
+                       key = pool_intern(val);
+                       continue;
+               case 'D':
+                       key = pool_intern(val);
+                       val = NULL;
+                       len = 0;
+                       /* fall through */
+               case 'V':
+                       handle_property(key, val, len, &type_set);
                        key = ~0;
-                       buffer_read_line(&input);
+                       continue;
+               default:
+                       die("invalid property line: %s\n", t);
                }
        }
  }
  
  static void handle_node(void)
  {
-       if (node_ctx.propLength != LENGTH_UNKNOWN && node_ctx.propLength)
-               read_props();
-       if (node_ctx.srcRev)
-               node_ctx.srcMode = repo_copy(node_ctx.srcRev, node_ctx.src, node_ctx.dst);
-       if (node_ctx.textLength != LENGTH_UNKNOWN &&
-           node_ctx.type != REPO_MODE_DIR)
-               node_ctx.mark = next_blob_mark();
+       uint32_t mark = 0;
+       const uint32_t type = node_ctx.type;
+       const int have_props = node_ctx.propLength != LENGTH_UNKNOWN;
  
+       if (node_ctx.text_delta)
+               die("text deltas not supported");
+       if (node_ctx.textLength != LENGTH_UNKNOWN)
+               mark = next_blob_mark();
        if (node_ctx.action == NODEACT_DELETE) {
+               if (mark || have_props || node_ctx.srcRev)
+                       die("invalid dump: deletion node has "
+                               "copyfrom info, text, or properties");
+               return repo_delete(node_ctx.dst);
+       }
+       if (node_ctx.action == NODEACT_REPLACE) {
                repo_delete(node_ctx.dst);
-       } else if (node_ctx.action == NODEACT_CHANGE ||
-                          node_ctx.action == NODEACT_REPLACE) {
-               if (node_ctx.action == NODEACT_REPLACE &&
-                   node_ctx.type == REPO_MODE_DIR)
-                       repo_replace(node_ctx.dst, node_ctx.mark);
-               else if (node_ctx.propLength != LENGTH_UNKNOWN)
-                       repo_modify(node_ctx.dst, node_ctx.type, node_ctx.mark);
-               else if (node_ctx.textLength != LENGTH_UNKNOWN)
-                       node_ctx.srcMode = repo_replace(node_ctx.dst, node_ctx.mark);
+               node_ctx.action = NODEACT_ADD;
+       }
+       if (node_ctx.srcRev) {
+               repo_copy(node_ctx.srcRev, node_ctx.src, node_ctx.dst);
+               if (node_ctx.action == NODEACT_ADD)
+                       node_ctx.action = NODEACT_CHANGE;
+       }
+       if (mark && type == REPO_MODE_DIR)
+               die("invalid dump: directories cannot have text attached");
+       if (node_ctx.action == NODEACT_CHANGE && !~*node_ctx.dst) {
+               if (type != REPO_MODE_DIR)
+                       die("invalid dump: root of tree is not a regular file");
+       } else if (node_ctx.action == NODEACT_CHANGE) {
+               uint32_t mode = repo_modify_path(node_ctx.dst, 0, mark);
+               if (!mode)
+                       die("invalid dump: path to be modified is missing");
+               if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR)
+                       die("invalid dump: cannot modify a directory into a file");
+               if (mode != REPO_MODE_DIR && type == REPO_MODE_DIR)
+                       die("invalid dump: cannot modify a file into a directory");
+               node_ctx.type = mode;
        } else if (node_ctx.action == NODEACT_ADD) {
-               if (node_ctx.srcRev && node_ctx.propLength != LENGTH_UNKNOWN)
-                       repo_modify(node_ctx.dst, node_ctx.type, node_ctx.mark);
-               else if (node_ctx.srcRev && node_ctx.textLength != LENGTH_UNKNOWN)
-                       node_ctx.srcMode = repo_replace(node_ctx.dst, node_ctx.mark);
-               else if ((node_ctx.type == REPO_MODE_DIR && !node_ctx.srcRev) ||
-                        node_ctx.textLength != LENGTH_UNKNOWN)
-                       repo_add(node_ctx.dst, node_ctx.type, node_ctx.mark);
+               if (!mark && type != REPO_MODE_DIR)
+                       die("invalid dump: adds node without text");
+               repo_add(node_ctx.dst, type, mark);
+       } else {
+               die("invalid dump: Node-path block lacks Node-action");
        }
-       if (node_ctx.propLength == LENGTH_UNKNOWN && node_ctx.srcMode)
-               node_ctx.type = node_ctx.srcMode;
-       if (node_ctx.mark)
-               fast_export_blob(node_ctx.type,
-                                node_ctx.mark, node_ctx.textLength, &input);
-       else if (node_ctx.textLength != LENGTH_UNKNOWN)
-               buffer_skip_bytes(&input, node_ctx.textLength);
+       if (have_props) {
+               const uint32_t old_mode = node_ctx.type;
+               if (!node_ctx.prop_delta)
+                       node_ctx.type = type;
+               if (node_ctx.propLength)
+                       read_props();
+               if (node_ctx.type != old_mode)
+                       repo_modify_path(node_ctx.dst, node_ctx.type, mark);
+       }
+       if (mark)
 -              fast_export_blob(node_ctx.type, mark, node_ctx.textLength);
++              fast_export_blob(node_ctx.type, mark,
++                               node_ctx.textLength, &input);
  }
  
  static void handle_revision(void)
@@@ -213,8 -279,8 +282,8 @@@ void svndump_read(const char *url
  
                if (key == keys.svn_fs_dump_format_version) {
                        dump_ctx.version = atoi(val);
-                       if (dump_ctx.version > 2)
-                               die("expected svn dump format version <= 2, found %"PRIu32,
+                       if (dump_ctx.version > 3)
 -                              die("expected svn dump format version <= 3, found %d",
++                              die("expected svn dump format version <= 3, found %"PRIu32,
                                    dump_ctx.version);
                } else if (key == keys.uuid) {
                        dump_ctx.uuid = pool_intern(val);
                        node_ctx.textLength = atoi(val);
                } else if (key == keys.prop_content_length) {
                        node_ctx.propLength = atoi(val);
+               } else if (key == keys.text_delta) {
+                       node_ctx.text_delta = !strcmp(val, "true");
+               } else if (key == keys.prop_delta) {
+                       node_ctx.prop_delta = !strcmp(val, "true");
                } else if (key == keys.content_length) {
                        len = atoi(val);
 -                      buffer_read_line();
 +                      buffer_read_line(&input);
                        if (active_ctx == REV_CTX) {
                                read_props();
                        } else if (active_ctx == NODE_CTX) {
                handle_revision();
  }
  
void svndump_init(const char *filename)
int svndump_init(const char *filename)
  {
-       buffer_init(&input, filename);
 -      if (buffer_init(filename))
++      if (buffer_init(&input, filename))
+               return error("cannot open %s: %s", filename, strerror(errno));
        repo_init();
        reset_dump_ctx(~0);
        reset_rev_ctx(0);