0641fcc30035e63cad3cf557c39c4b86a47c72ef
Author: Robin Luckey
Date: 2009-02-12 16:31:03 -0800
diff --git a/lib/scm/adapters/git/commit_all.rb b/lib/scm/adapters/git/commit_all.rb
index acf06cf..4ee7fbb 100644
--- a/lib/scm/adapters/git/commit_all.rb
+++ b/lib/scm/adapters/git/commit_all.rb
@@ -16,7 +16,7 @@ module Scm::Adapters
run "cd '#{self.url}' && git add ."
if anything_to_commit?
- run " cd '#{self.url}' && git commit -a -F #{message_filename}"
+ run "cd '#{self.url}' && git commit -a -F #{message_filename}"
else
logger.info { "nothing to commit" }
end
diff --git a/lib/scm/adapters/svn/chain.rb b/lib/scm/adapters/svn/chain.rb
index 7bfdd96..8f67b55 100644
--- a/lib/scm/adapters/svn/chain.rb
+++ b/lib/scm/adapters/svn/chain.rb
@@ -53,10 +53,10 @@ module Scm::Adapters
c = first_commit(since)
if c
c.diffs.each do |d|
- if d.action == 'A' && d.path == branch_name && d.from_path && d.from_revision
- parent = SvnAdapter.new(:url => File.join(root, d.from_path),
+ if (b = new_branch_name(d))
+ parent = SvnAdapter.new(:url => File.join(root, b), :branch_name => b,
:username => username, :password => password,
- :branch_name => d.from_path, :final_token => d.from_revision).normalize
+ :final_token => d.from_revision).normalize
break
end
end
@@ -114,5 +114,14 @@ module Scm::Adapters
return "<?xml?>" if since.to_i >= head_token
run "svn log --verbose --xml --stop-on-copy -r #{since.to_i+1}:#{final_token || 'HEAD'} --limit 1 #{opt_auth} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}@#{final_token || 'HEAD'}'"
end
+
+ # If the passed diff represents the wholesale movement of the entire
+ # code tree from one directory to another, this method returns the name
+ # of the previous directory.
+ def new_branch_name(d)
+ if d.action == 'A' && branch_name[0, d.path.size] == d.path && d.from_path && d.from_revision
+ d.from_path + branch_name[d.path.size..-1]
+ end
+ end
end
end
diff --git a/lib/scm/adapters/svn/commits.rb b/lib/scm/adapters/svn/commits.rb
index a0824dd..e956653 100644
--- a/lib/scm/adapters/svn/commits.rb
+++ b/lib/scm/adapters/svn/commits.rb
@@ -179,7 +179,7 @@ module Scm::Adapters
#---------------------------------------------------------------------
def log(since=0)
- run "svn log --xml --stop-on-copy -r #{since.to_i + 1}:#{final_token || 'HEAD'} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name.to_s))}' #{opt_auth}"
+ run "svn log --xml --stop-on-copy -r #{since.to_i + 1}:#{final_token || 'HEAD'} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name.to_s))}@#{final_token || 'HEAD'}' #{opt_auth}"
end
def open_log_file(since=0)
@@ -189,7 +189,7 @@ module Scm::Adapters
# As a time optimization, just create an empty file rather than fetch a log we know will be empty.
File.open(log_filename, 'w') { |f| f.puts '<?xml version="1.0"?>' }
else
- run "svn log --xml --stop-on-copy -r #{since.to_i + 1}:#{final_token || 'HEAD'} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}' #{opt_auth} > #{log_filename}"
+ run "svn log --xml --stop-on-copy -r #{since.to_i + 1}:#{final_token || 'HEAD'} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name))}@#{final_token || 'HEAD'}' #{opt_auth} > #{log_filename}"
end
File.open(log_filename, 'r') { |io| yield io }
ensure
diff --git a/test/repositories/svn_with_tree_move/README.txt b/test/repositories/svn_with_tree_move/README.txt
new file mode 100644
index 0000000..3bf5a57
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/README.txt
@@ -0,0 +1,5 @@
+This is a Subversion repository; use the 'svnadmin' tool to examine
+it. Do not add, delete, or modify files here unless you know how
+to avoid corrupting the repository.
+
+Visit http://subversion.tigris.org/ for more information.
diff --git a/test/repositories/svn_with_tree_move/conf/authz b/test/repositories/svn_with_tree_move/conf/authz
new file mode 100644
index 0000000..78cb28e
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/conf/authz
@@ -0,0 +1,21 @@
+### This file is an example authorization file for svnserve.
+### Its format is identical to that of mod_authz_svn authorization
+### files.
+### As shown below each section defines authorizations for the path and
+### (optional) repository specified by the section name.
+### The authorizations follow. An authorization line can refer to a
+### single user, to a group of users defined in a special [groups]
+### section, or to anyone using the '*' wildcard. Each definition can
+### grant read ('r') access, read-write ('rw') access, or no access
+### ('').
+
+[groups]
+# harry_and_sally = harry,sally
+
+# [/foo/bar]
+# harry = rw
+# * =
+
+# [repository:/baz/fuz]
+# @harry_and_sally = rw
+# * = r
diff --git a/test/repositories/svn_with_tree_move/conf/passwd b/test/repositories/svn_with_tree_move/conf/passwd
new file mode 100644
index 0000000..ecaa08d
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/conf/passwd
@@ -0,0 +1,8 @@
+### This file is an example password file for svnserve.
+### Its format is similar to that of svnserve.conf. As shown in the
+### example below it contains one section labelled [users].
+### The name and password for each user follow, one account per line.
+
+[users]
+# harry = harryssecret
+# sally = sallyssecret
diff --git a/test/repositories/svn_with_tree_move/conf/svnserve.conf b/test/repositories/svn_with_tree_move/conf/svnserve.conf
new file mode 100644
index 0000000..b52bc5a
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/conf/svnserve.conf
@@ -0,0 +1,30 @@
+### This file controls the configuration of the svnserve daemon, if you
+### use it to allow access to this repository. (If you only allow
+### access through http: and/or file: URLs, then this file is
+### irrelevant.)
+
+### Visit http://subversion.tigris.org/ for more information.
+
+[general]
+### These options control access to the repository for unauthenticated
+### and authenticated users. Valid values are "write", "read",
+### and "none". The sample settings below are the defaults.
+# anon-access = read
+# auth-access = write
+### The password-db option controls the location of the password
+### database file. Unless you specify a path starting with a /,
+### the file's location is relative to the conf directory.
+### Uncomment the line below to use the default password file.
+# password-db = passwd
+### The authz-db option controls the location of the authorization
+### rules for path-based access control. Unless you specify a path
+### starting with a /, the file's location is relative to the conf
+### directory. If you don't specify an authz-db, no path-based access
+### control is done.
+### Uncomment the line below to use the default authorization file.
+# authz-db = authz
+### This option specifies the authentication realm of the repository.
+### If two repositories have the same authentication realm, they should
+### have the same password database, and vice versa. The default realm
+### is repository's uuid.
+# realm = My First Repository
diff --git a/test/repositories/svn_with_tree_move/db/current b/test/repositories/svn_with_tree_move/db/current
new file mode 100644
index 0000000..394811d
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/current
@@ -0,0 +1 @@
+2 5 2
diff --git a/test/repositories/svn_with_tree_move/db/format b/test/repositories/svn_with_tree_move/db/format
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/format
@@ -0,0 +1 @@
+2
diff --git a/test/repositories/svn_with_tree_move/db/fs-type b/test/repositories/svn_with_tree_move/db/fs-type
new file mode 100644
index 0000000..4fdd953
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/fs-type
@@ -0,0 +1 @@
+fsfs
diff --git a/test/repositories/svn_with_tree_move/db/revprops/0 b/test/repositories/svn_with_tree_move/db/revprops/0
new file mode 100644
index 0000000..1716bf4
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/revprops/0
@@ -0,0 +1,5 @@
+K 8
+svn:date
+V 27
+2009-02-12T23:29:46.930803Z
+END
diff --git a/test/repositories/svn_with_tree_move/db/revprops/1 b/test/repositories/svn_with_tree_move/db/revprops/1
new file mode 100644
index 0000000..296a9a0
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/revprops/1
@@ -0,0 +1,13 @@
+K 10
+svn:author
+V 5
+robin
+K 8
+svn:date
+V 27
+2009-02-12T23:31:42.224055Z
+K 7
+svn:log
+V 16
+Initial Revision
+END
diff --git a/test/repositories/svn_with_tree_move/db/revprops/2 b/test/repositories/svn_with_tree_move/db/revprops/2
new file mode 100644
index 0000000..eed0157
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/revprops/2
@@ -0,0 +1,13 @@
+K 10
+svn:author
+V 5
+robin
+K 8
+svn:date
+V 27
+2009-02-12T23:32:13.278922Z
+K 7
+svn:log
+V 22
+Move tree up one level
+END
diff --git a/test/repositories/svn_with_tree_move/db/revs/0 b/test/repositories/svn_with_tree_move/db/revs/0
new file mode 100644
index 0000000..10f5c45
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/revs/0
@@ -0,0 +1,11 @@
+PLAIN
+END
+ENDREP
+id: 0.0.r0/17
+type: dir
+count: 0
+text: 0 0 4 4 2d2977d1c96f487abe4a1e202dd03b4e
+cpath: /
+
+
+17 107
diff --git a/test/repositories/svn_with_tree_move/db/revs/1 b/test/repositories/svn_with_tree_move/db/revs/1
new file mode 100644
index 0000000..72b68a3
Binary files /dev/null and b/test/repositories/svn_with_tree_move/db/revs/1 differ
diff --git a/test/repositories/svn_with_tree_move/db/revs/2 b/test/repositories/svn_with_tree_move/db/revs/2
new file mode 100644
index 0000000..61d2ca3
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/revs/2
@@ -0,0 +1,44 @@
+PLAIN
+END
+ENDREP
+id: 1.0.r2/17
+type: dir
+pred: 1.0.r1/625
+count: 1
+text: 2 0 4 4 2d2977d1c96f487abe4a1e202dd03b4e
+cpath: /all
+copyroot: 0 /
+
+id: 2.1.r2/141
+type: dir
+pred: 2.0.r1/452
+count: 1
+text: 1 405 34 34 421576a59ace312937c26664b844a879
+cpath: /myproject
+copyfrom: 1 /all/myproject
+
+PLAIN
+K 3
+all
+V 13
+dir 1.0.r2/17
+K 9
+myproject
+V 14
+dir 2.1.r2/141
+END
+ENDREP
+id: 0.0.r2/367
+type: dir
+pred: 0.0.r1/782
+count: 2
+text: 2 289 65 65 bc780155f14b1d1109add7e03a436d9f
+cpath: /
+copyroot: 0 /
+
+2.0.r1/452 delete false false /all/myproject
+
+2._0.t1-1 add false false /myproject
+1 /all/myproject
+
+367 493
diff --git a/test/repositories/svn_with_tree_move/db/uuid b/test/repositories/svn_with_tree_move/db/uuid
new file mode 100644
index 0000000..65ff7b9
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/db/uuid
@@ -0,0 +1 @@
+72ad96da-afe6-45cb-97a1-ca313a930b66
diff --git a/test/repositories/svn_with_tree_move/db/write-lock b/test/repositories/svn_with_tree_move/db/write-lock
new file mode 100644
index 0000000..e69de29
diff --git a/test/repositories/svn_with_tree_move/format b/test/repositories/svn_with_tree_move/format
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/format
@@ -0,0 +1 @@
+5
diff --git a/test/repositories/svn_with_tree_move/hooks/post-commit.tmpl b/test/repositories/svn_with_tree_move/hooks/post-commit.tmpl
new file mode 100644
index 0000000..b8345c6
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/post-commit.tmpl
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# POST-COMMIT HOOK
+#
+# The post-commit hook is invoked after a commit. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-commit' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REV (the number of the revision just committed)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the commit has already completed and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# newly-committed tree.
+#
+# On a Unix system, the normal procedure is to have 'post-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-commit.bat' or 'post-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+
+commit-email.pl "$REPOS" "$REV" commit-watchers@example.org
+log-commit.py --repository "$REPOS" --revision "$REV"
diff --git a/test/repositories/svn_with_tree_move/hooks/post-lock.tmpl b/test/repositories/svn_with_tree_move/hooks/post-lock.tmpl
new file mode 100644
index 0000000..c779f11
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/post-lock.tmpl
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# POST-LOCK HOOK
+#
+# The post-lock hook is run after a path is locked. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-lock' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the user who created the lock)
+#
+# The paths that were just locked are passed to the hook via STDIN (as
+# of Subversion 1.2, only one path is passed per invocation, but the
+# plan is to pass all locked paths at once, so the hook program
+# should be written accordingly).
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the lock has already been created and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# newly-created lock.
+#
+# On a Unix system, the normal procedure is to have 'post-lock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-lock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-lock.bat' or 'post-lock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+USER="$2"
+
+# Send email to interested parties, let them know a lock was created:
+mailer.py lock "$REPOS" "$USER" /path/to/mailer.conf
diff --git a/test/repositories/svn_with_tree_move/hooks/post-revprop-change.tmpl b/test/repositories/svn_with_tree_move/hooks/post-revprop-change.tmpl
new file mode 100644
index 0000000..2ed8b9a
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/post-revprop-change.tmpl
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# POST-REVPROP-CHANGE HOOK
+#
+# The post-revprop-change hook is invoked after a revision property
+# has been added, modified or deleted. Subversion runs this hook by
+# invoking a program (script, executable, binary, etc.) named
+# 'post-revprop-change' (for which this file is a template), with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REV (the revision that was tweaked)
+# [3] USER (the username of the person tweaking the property)
+# [4] PROPNAME (the property that was changed)
+# [5] ACTION (the property was 'A'dded, 'M'odified, or 'D'eleted)
+#
+# [STDIN] PROPVAL ** the old property value is passed via STDIN.
+#
+# Because the propchange has already completed and cannot be undone,
+# the exit code of the hook program is ignored. The hook program
+# can use the 'svnlook' utility to help it examine the
+# new property value.
+#
+# On a Unix system, the normal procedure is to have 'post-revprop-change'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-revprop-change' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-revprop-change.bat' or 'post-revprop-change.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+USER="$3"
+PROPNAME="$4"
+ACTION="$5"
+
+propchange-email.pl "$REPOS" "$REV" "$USER" "$PROPNAME" watchers@example.org
diff --git a/test/repositories/svn_with_tree_move/hooks/post-unlock.tmpl b/test/repositories/svn_with_tree_move/hooks/post-unlock.tmpl
new file mode 100644
index 0000000..ae95c4b
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/post-unlock.tmpl
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# POST-UNLOCK HOOK
+#
+# The post-unlock hook runs after a path is unlocked. Subversion runs
+# this hook by invoking a program (script, executable, binary, etc.)
+# named 'post-unlock' (for which this file is a template) with the
+# following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the user who destroyed the lock)
+#
+# The paths that were just unlocked are passed to the hook via STDIN
+# (as of Subversion 1.2, only one path is passed per invocation, but
+# the plan is to pass all unlocked paths at once, so the hook program
+# should be written accordingly).
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# Because the lock has already been destroyed and cannot be undone,
+# the exit code of the hook program is ignored.
+#
+# On a Unix system, the normal procedure is to have 'post-unlock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'post-unlock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'post-unlock.bat' or 'post-unlock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+USER="$2"
+
+# Send email to interested parties, let them know a lock was removed:
+mailer.py unlock "$REPOS" "$USER" /path/to/mailer.conf
diff --git a/test/repositories/svn_with_tree_move/hooks/pre-commit.tmpl b/test/repositories/svn_with_tree_move/hooks/pre-commit.tmpl
new file mode 100644
index 0000000..7444c51
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/pre-commit.tmpl
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# PRE-COMMIT HOOK
+#
+# The pre-commit hook is invoked before a Subversion txn is
+# committed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-commit' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] TXN-NAME (the name of the txn about to be committed)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the txn is committed; but
+# if it exits with failure (non-zero), the txn is aborted, no commit
+# takes place, and STDERR is returned to the client. The hook
+# program can use the 'svnlook' utility to help it examine the txn.
+#
+# On a Unix system, the normal procedure is to have 'pre-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***
+# *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***
+#
+# This is why we recommend using the read-only 'svnlook' utility.
+# In the future, Subversion may enforce the rule that pre-commit
+# hooks should not modify the versioned data in txns, or else come
+# up with a mechanism to make it safe to do so (by informing the
+# committing client of the changes). However, right now neither
+# mechanism is implemented, so hook writers just have to be careful.
+#
+# Note that 'pre-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-commit.bat' or 'pre-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+TXN="$2"
+
+# Make sure that the log message contains some text.
+SVNLOOK=/opt/local/bin/svnlook
+$SVNLOOK log -t "$TXN" "$REPOS" | \
+ grep "[a-zA-Z0-9]" > /dev/null || exit 1
+
+# Check that the author of this commit has the rights to perform
+# the commit on the files and directories being modified.
+commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
+
+# All checks passed, so allow the commit.
+exit 0
diff --git a/test/repositories/svn_with_tree_move/hooks/pre-lock.tmpl b/test/repositories/svn_with_tree_move/hooks/pre-lock.tmpl
new file mode 100644
index 0000000..020d172
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/pre-lock.tmpl
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# PRE-LOCK HOOK
+#
+# The pre-lock hook is invoked before an exclusive lock is
+# created. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-lock' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] PATH (the path in the repository about to be locked)
+# [3] USER (the user creating the lock)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the lock is created; but
+# if it exits with failure (non-zero), the lock action is aborted
+# and STDERR is returned to the client.
+
+# On a Unix system, the normal procedure is to have 'pre-lock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-lock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-lock.bat' or 'pre-lock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+PATH="$2"
+USER="$3"
+
+# If a lock exists and is owned by a different person, don't allow it
+# to be stolen (e.g., with 'svn lock --force ...').
+
+# (Maybe this script could send email to the lock owner?)
+SVNLOOK=/opt/local/bin/svnlook
+GREP=/bin/grep
+SED=/bin/sed
+
+LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
+ $GREP '^Owner: ' | $SED 's/Owner: //'`
+
+# If we get no result from svnlook, there's no lock, allow the lock to
+# happen:
+if [ "$LOCK_OWNER" = "" ]; then
+ exit 0
+fi
+
+# If the person locking matches the lock's owner, allow the lock to
+# happen:
+if [ "$LOCK_OWNER" = "$USER" ]; then
+ exit 0
+fi
+
+# Otherwise, we've got an owner mismatch, so return failure:
+echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2
+exit 1
diff --git a/test/repositories/svn_with_tree_move/hooks/pre-revprop-change.tmpl b/test/repositories/svn_with_tree_move/hooks/pre-revprop-change.tmpl
new file mode 100644
index 0000000..2f2de98
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/pre-revprop-change.tmpl
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# PRE-REVPROP-CHANGE HOOK
+#
+# The pre-revprop-change hook is invoked before a revision property
+# is added, modified or deleted. Subversion runs this hook by invoking
+# a program (script, executable, binary, etc.) named 'pre-revprop-change'
+# (for which this file is a template), with the following ordered
+# arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] REVISION (the revision being tweaked)
+# [3] USER (the username of the person tweaking the property)
+# [4] PROPNAME (the property being set on the revision)
+# [5] ACTION (the property is being 'A'dded, 'M'odified, or 'D'eleted)
+#
+# [STDIN] PROPVAL ** the new property value is passed via STDIN.
+#
+# If the hook program exits with success, the propchange happens; but
+# if it exits with failure (non-zero), the propchange doesn't happen.
+# The hook program can use the 'svnlook' utility to examine the
+# existing value of the revision property.
+#
+# WARNING: unlike other hooks, this hook MUST exist for revision
+# properties to be changed. If the hook does not exist, Subversion
+# will behave as if the hook were present, but failed. The reason
+# for this is that revision properties are UNVERSIONED, meaning that
+# a successful propchange is destructive; the old value is gone
+# forever. We recommend the hook back up the old value somewhere.
+#
+# On a Unix system, the normal procedure is to have 'pre-revprop-change'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-revprop-change' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-revprop-change.bat' or 'pre-revprop-change.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+REV="$2"
+USER="$3"
+PROPNAME="$4"
+ACTION="$5"
+
+if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
+
+echo "Changing revision properties other than svn:log is prohibited" >&2
+exit 1
diff --git a/test/repositories/svn_with_tree_move/hooks/pre-unlock.tmpl b/test/repositories/svn_with_tree_move/hooks/pre-unlock.tmpl
new file mode 100644
index 0000000..795f55f
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/pre-unlock.tmpl
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# PRE-UNLOCK HOOK
+#
+# The pre-unlock hook is invoked before an exclusive lock is
+# destroyed. Subversion runs this hook by invoking a program
+# (script, executable, binary, etc.) named 'pre-unlock' (for which
+# this file is a template), with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] PATH (the path in the repository about to be unlocked)
+# [3] USER (the user destroying the lock)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the lock is destroyed; but
+# if it exits with failure (non-zero), the unlock action is aborted
+# and STDERR is returned to the client.
+
+# On a Unix system, the normal procedure is to have 'pre-unlock'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'pre-unlock' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'pre-unlock.bat' or 'pre-unlock.exe',
+# but the basic idea is the same.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter:
+
+REPOS="$1"
+PATH="$2"
+USER="$3"
+
+# If a lock is owned by a different person, don't allow it be broken.
+# (Maybe this script could send email to the lock owner?)
+
+SVNLOOK=/opt/local/bin/svnlook
+GREP=/bin/grep
+SED=/bin/sed
+
+LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
+ $GREP '^Owner: ' | $SED 's/Owner: //'`
+
+# If we get no result from svnlook, there's no lock, return success:
+if [ "$LOCK_OWNER" = "" ]; then
+ exit 0
+fi
+# If the person unlocking matches the lock's owner, return success:
+if [ "$LOCK_OWNER" = "$USER" ]; then
+ exit 0
+fi
+
+# Otherwise, we've got an owner mismatch, so return failure:
+echo "Error: $PATH locked by ${LOCK_OWNER}." 1>&2
+exit 1
diff --git a/test/repositories/svn_with_tree_move/hooks/start-commit.tmpl b/test/repositories/svn_with_tree_move/hooks/start-commit.tmpl
new file mode 100644
index 0000000..348d706
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/hooks/start-commit.tmpl
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# START-COMMIT HOOK
+#
+# The start-commit hook is invoked before a Subversion txn is created
+# in the process of doing a commit. Subversion runs this hook
+# by invoking a program (script, executable, binary, etc.) named
+# 'start-commit' (for which this file is a template)
+# with the following ordered arguments:
+#
+# [1] REPOS-PATH (the path to this repository)
+# [2] USER (the authenticated user attempting to commit)
+#
+# The default working directory for the invocation is undefined, so
+# the program should set one explicitly if it cares.
+#
+# If the hook program exits with success, the commit continues; but
+# if it exits with failure (non-zero), the commit is stopped before
+# a Subversion txn is created, and STDERR is returned to the client.
+#
+# On a Unix system, the normal procedure is to have 'start-commit'
+# invoke other programs to do the real work, though it may do the
+# work itself too.
+#
+# Note that 'start-commit' must be executable by the user(s) who will
+# invoke it (typically the user httpd runs as), and that user must
+# have filesystem-level permission to access the repository.
+#
+# On a Windows system, you should name the hook program
+# 'start-commit.bat' or 'start-commit.exe',
+# but the basic idea is the same.
+#
+# The hook program typically does not inherit the environment of
+# its parent process. For example, a common problem is for the
+# PATH environment variable to not be set to its usual value, so
+# that subprograms fail to launch unless invoked via absolute path.
+# If you're having unexpected problems with a hook program, the
+# culprit may be unusual (or missing) environment variables.
+#
+# Here is an example hook script, for a Unix /bin/sh interpreter.
+# For more examples and pre-written hooks, see those in
+# the Subversion repository at
+# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
+# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/
+
+
+REPOS="$1"
+USER="$2"
+
+commit-allower.pl --repository "$REPOS" --user "$USER" || exit 1
+special-auth-check.py --user "$USER" --auth-level 3 || exit 1
+
+# All checks passed, so allow the commit.
+exit 0
diff --git a/test/repositories/svn_with_tree_move/locks/db-logs.lock b/test/repositories/svn_with_tree_move/locks/db-logs.lock
new file mode 100644
index 0000000..20dd636
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/locks/db-logs.lock
@@ -0,0 +1,3 @@
+This file is not used by Subversion 1.3.x or later.
+However, its existence is required for compatibility with
+Subversion 1.2.x or earlier.
diff --git a/test/repositories/svn_with_tree_move/locks/db.lock b/test/repositories/svn_with_tree_move/locks/db.lock
new file mode 100644
index 0000000..20dd636
--- /dev/null
+++ b/test/repositories/svn_with_tree_move/locks/db.lock
@@ -0,0 +1,3 @@
+This file is not used by Subversion 1.3.x or later.
+However, its existence is required for compatibility with
+Subversion 1.2.x or earlier.
diff --git a/test/unit/svn_chain_test.rb b/test/unit/svn_chain_test.rb
index b43d5b3..52e593b 100644
--- a/test/unit/svn_chain_test.rb
+++ b/test/unit/svn_chain_test.rb
@@ -146,7 +146,7 @@ module Scm::Parsers
# Revision 6: /trunk/goodbyeworld.c is created, but we only see activity
# on /branches/development, so no commit reported.
-
+
# Revision 7: /trunk is deleted, but again we don't see it.
# Revision 8: /branches/development is moved to become the new /trunk.
@@ -159,5 +159,35 @@ module Scm::Parsers
assert_equal '/helloworld.c', commits[5].diffs.first.path
end
+ # Specifically tests this case:
+ # Suppose we're importing /myproject/trunk, and the log
+ # contains the following:
+ #
+ # A /myproject (from /all/myproject:1)
+ # D /all/myproject
+ #
+ # We need to make sure we detect the move here, even though
+ # "/myproject" is not an exact match for "/myproject/trunk".
+ def test_tree_move
+ with_svn_repository('svn_with_tree_move', '/myproject/trunk') do |svn|
+ assert_equal svn.url, svn.root + '/myproject/trunk'
+ assert_equal svn.branch_name, '/myproject/trunk'
+
+ p = svn.parent_svn
+ assert_equal p.url, svn.root + '/all/myproject/trunk'
+ assert_equal p.branch_name, '/all/myproject/trunk'
+ assert_equal p.final_token, 1
+
+ assert_equal [1, 2], svn.commit_tokens
+ end
+ end
+
+ def test_new_branch_name
+ svn = Scm::Adapters::SvnAdapter.new(:branch_name => "/trunk")
+
+ assert_equal "/branches/b", svn.new_branch_name(Scm::Diff.new(:action => 'A',
+ :path => "/trunk", :from_revision => 1, :from_path => "/branches/b"))
+ end
+
end
end
