You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2010/03/08 13:15:51 UTC
svn commit: r920292 - in /subversion/trunk/subversion:
libsvn_ra_local/split_url.c tests/cmdline/checkout_tests.py
Author: rhuijben
Date: Mon Mar 8 12:15:51 2010
New Revision: 920292
URL: http://svn.apache.org/viewvc?rev=920292&view=rev
Log:
Resolve issue #3535, by making it possible to checkout repositories from a
Windows drive root. Based on a patch by Gavin Baumanis, but extended to
produce a better dirent. (The original version should work in 1.6.X,
because the code doesn't use dirents there)
* subversion/libsvn_ra_local/split_url.c
(svn_ra_local__split_URL): Allow urls in the form 'file:///E:' to be used
for finding a repository. Resolve this class of paths to a "E:/" like
dirent to make sure that the code handles different current directories
correctly.
* subversion/tests/cmdline/checkout_tests.py
(imports): Add subprocess.
(checkout_wc_from_drive):
New function, based on update_wc_on_windows_drive() in update_tests.py.
(test_list): Add checkout_wc_from_drive.
Patch by: Gavin Baumanis <gavin{_AT_}thespidernet.com>
(Tweaks and testcase by me)
Modified:
subversion/trunk/subversion/libsvn_ra_local/split_url.c
subversion/trunk/subversion/tests/cmdline/checkout_tests.py
Modified: subversion/trunk/subversion/libsvn_ra_local/split_url.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_local/split_url.c?rev=920292&r1=920291&r2=920292&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_local/split_url.c (original)
+++ subversion/trunk/subversion/libsvn_ra_local/split_url.c Mon Mar 8 12:15:51 2010
@@ -106,7 +106,7 @@
char *dup_path = (char *)svn_path_uri_decode(path, pool);
if (!hostname && dup_path[1] && strchr(valid_drive_letters, dup_path[1])
&& (dup_path[2] == ':' || dup_path[2] == '|')
- && dup_path[3] == '/')
+ && (dup_path[3] == '/' || dup_path[3] == '\0'))
{
/* Skip the leading slash. */
++dup_path;
@@ -114,6 +114,19 @@
++path;
if (dup_path[1] == '|')
dup_path[1] = ':';
+
+ if (dup_path[3] == '\0')
+ {
+ /* A valid dirent for the driveroot must be like "C:/" instead of
+ just "C:" or svn_dirent_join() will use the current directory
+ on the drive instead */
+
+ char *new_path = apr_pcalloc(pool, 4);
+ new_path[0] = dup_path[0];
+ new_path[1] = ':';
+ new_path[2] = '/';
+ new_path[3] = '\0';
+ }
}
if (hostname)
/* We still know that the path starts with a slash. */
Modified: subversion/trunk/subversion/tests/cmdline/checkout_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/checkout_tests.py?rev=920292&r1=920291&r2=920292&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/checkout_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/checkout_tests.py Mon Mar 8 12:15:51 2010
@@ -26,7 +26,7 @@
######################################################################
# General modules
-import sys, re, os, time
+import sys, re, os, time, subprocess
# Our testing module
import svntest
@@ -824,6 +824,87 @@
svntest.actions.run_and_verify_status(wc_dir, expected_status)
#----------------------------------------------------------------------
+# Test if checking out from a Windows driveroot is supported.
+def checkout_wc_from_drive(sbox):
+ "checkout from the root of a Windows drive"
+
+ def find_the_next_available_drive_letter():
+ "find the first available drive"
+
+ # get the list of used drive letters, use some Windows specific function.
+ try:
+ import win32api
+
+ drives=win32api.GetLogicalDriveStrings()
+ drives=drives.split('\000')
+
+ for d in range(ord('G'), ord('Z')+1):
+ drive = chr(d)
+ if not drive + ':\\' in drives:
+ return drive
+ except ImportError:
+ # In ActiveState python x64 win32api is not available
+ for d in range(ord('G'), ord('Z')+1):
+ drive = chr(d)
+ if not os.path.isdir(drive + ':\\'):
+ return drive
+
+ return None
+
+ # Skip the test if not on Windows
+ if not svntest.main.windows:
+ raise svntest.Skip
+
+ # just create an empty folder, we'll checkout later.
+ sbox.build(create_wc = False)
+ svntest.main.safe_rmtree(sbox.wc_dir)
+ os.mkdir(sbox.wc_dir)
+
+ # create a virtual drive to the working copy folder
+ drive = find_the_next_available_drive_letter()
+ if drive is None:
+ raise svntest.Skip
+
+ subprocess.call(['subst', drive +':', sbox.repo_dir])
+ repo_url = 'file:///' + drive + ':/'
+ wc_dir = sbox.wc_dir
+ was_cwd = os.getcwd()
+
+ try:
+ expected_wc = svntest.main.greek_state.copy()
+ expected_output = wc.State(wc_dir, {
+ 'A' : Item(status='A '),
+ 'A/D' : Item(status='A '),
+ 'A/D/H' : Item(status='A '),
+ 'A/D/H/psi' : Item(status='A '),
+ 'A/D/H/chi' : Item(status='A '),
+ 'A/D/H/omega' : Item(status='A '),
+ 'A/D/G' : Item(status='A '),
+ 'A/D/G/tau' : Item(status='A '),
+ 'A/D/G/pi' : Item(status='A '),
+ 'A/D/G/rho' : Item(status='A '),
+ 'A/D/gamma' : Item(status='A '),
+ 'A/C' : Item(status='A '),
+ 'A/mu' : Item(status='A '),
+ 'A/B' : Item(status='A '),
+ 'A/B/E' : Item(status='A '),
+ 'A/B/E/alpha' : Item(status='A '),
+ 'A/B/E/beta' : Item(status='A '),
+ 'A/B/F' : Item(status='A '),
+ 'A/B/lambda' : Item(status='A '),
+ 'iota' : Item(status='A '),
+ })
+ svntest.actions.run_and_verify_checkout(repo_url, wc_dir,
+ expected_output, expected_wc,
+ None, None, None, None,
+ '--force')
+
+ finally:
+ os.chdir(was_cwd)
+ # cleanup the virtual drive
+ subprocess.call(['subst', '/D', drive +':'])
+
+#----------------------------------------------------------------------
# list all tests here, starting with None:
test_list = [ None,
@@ -840,6 +921,7 @@
checkout_peg_rev,
checkout_peg_rev_date,
co_with_obstructing_local_adds,
+ checkout_wc_from_drive
]
if __name__ == "__main__":