[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] cvs2svn on windows

From: <kfogel_at_collab.net>
Date: 2003-06-15 18:32:48 CEST

"Russell Yanofsky" <rey4@columbia.edu> writes:
> Changes to cvs2svn.py and its regression testing script so they can work on
> Windows. (All the tests pass, by the way, except for #2 "detection of the
> executable flag" which must be a real doozie :)

Thank you!

Sander R, I'll file this one myself.

-K

> * tools/cvs2svn/cvs2svn.py (relative_name): Changed this helper function to
> expect os.sep in the file path passed to it instead of forward slashes.
> Also added an assertion to detect incorrect usage.
>
> (add_or_change_path): got rid of the buffer size parameter to the os.popen()
> call which causes a strange error on windows: "ValueError: popen() arg 3
> must be -1"
>
> (pass3): Changed to sort the file listing in memory instead with the "sort"
> command on Windows. Original behavior is preserved on other platforms.
>
> * tools/cvs2svn/run-tests.py (repos_to_url): Added missing slash detection.
> Needed because absolute paths on windows begin with a drive letter instead
> of a slash.
>
> (svn_strptime): new function to take the place of time.strptime, which
> doesn't exist on windows
>
> (Log.__init__): replaced time.strptime() call with svn_strptime() call.
>
>
> Index: tools/cvs2svn/cvs2svn.py
> ===================================================================
> --- tools/cvs2svn/cvs2svn.py (revision 6221)
> +++ tools/cvs2svn/cvs2svn.py (working copy)
> @@ -284,11 +284,8 @@
>
> def relative_name(cvsroot, fname):
> l = len(cvsroot)
> - if fname[:l] == cvsroot:
> - if fname[l] == '/':
> - return fname[l+1:]
> - return fname[l:]
> - return l
> + assert fname[:l] == cvsroot and fname[l] == os.sep
> + return string.replace(fname[l+1:], os.sep, '/')
>
> def visit_file(arg, dirname, files):
> cd, p, stats = arg
> @@ -767,7 +764,7 @@
> ### use it to set svn:mime-type.
>
> basename = os.path.basename(rcs_file[:-2])
> - pipe = os.popen('co -q -p%s \'%s\'' % (cvs_rev, rcs_file), 'r', 102400)
> + pipe = os.popen('co -q -p%s "%s"' % (cvs_rev, rcs_file), 'r')
>
> # You might think we could just test
> #
> @@ -1278,7 +1275,7 @@
> # read the resync data file
> resync = read_resync(ctx.log_fname_base + RESYNC_SUFFIX)
>
> - output = open(ctx.log_fname_base + CLEAN_REVS_SUFFIX, 'w')
> + output = open(ctx.log_fname_base + CLEAN_REVS_SUFFIX, 'wt')
>
> # process the revisions file, looking for items to clean up
> for line in fileinput.FileInput(ctx.log_fname_base + REVS_SUFFIX):
> @@ -1313,8 +1310,14 @@
>
> def pass3(ctx):
> # sort the log files
> - os.system('sort %s > %s' % (ctx.log_fname_base + CLEAN_REVS_SUFFIX,
> - ctx.log_fname_base + SORTED_REVS_SUFFIX))
> + clean = ctx.log_fname_base + CLEAN_REVS_SUFFIX
> + sorted = ctx.log_fname_base + SORTED_REVS_SUFFIX
> + if sys.platform == "win32":
> + lines = open(clean, 'rt').readlines()
> + lines.sort()
> + open(sorted, 'wt').writelines(lines)
> + else:
> + os.system('sort %s > %s' % (clean, sorted))
>
> def pass4(ctx):
> # create the target repository
> Index: tools/cvs2svn/run-tests.py
> ===================================================================
> --- tools/cvs2svn/run-tests.py (revision 6221)
> +++ tools/cvs2svn/run-tests.py (working copy)
> @@ -85,8 +85,20 @@
>
> def repos_to_url(path_to_svn_repos):
> """This does what you think it does."""
> - return 'file://%s' % os.path.abspath(path_to_svn_repos)
> + rpath = os.path.abspath(path_to_svn_repos)
> + if rpath[0] != '/':
> + rpath = '/' + rpath
> + return 'file://%s' % rpath
>
> +if hasattr(time, 'strptime'):
> + def svn_strptime(timestr):
> + return time.strptime(timestr, '%Y-%m-%d %H:%M:%S')
> +else:
> + _re_rev_date = re.compile('([0-9]{4})-([0-9][0-9])-([0-9][0-9]) '
> + '([0-9][0-9]):([0-9][0-9]):([0-9][0-9])')
> + def svn_strptime(timestr):
> + matches = _re_rev_date.match(timestr).groups()
> + return tuple(map(int, matches)) + (0, 1, 0)
>
> class Log:
> def __init__(self, revision, author, date):
> @@ -100,7 +112,7 @@
> #
> # and time.mktime() converts from localtime, it all works out very
> # happily.
> - self.date = time.mktime(time.strptime(date[0:19], "%Y-%m-%d %H:%M:%S"))
> + self.date = time.mktime(svn_strptime(date[0:19]))
>
> # The changed paths will be accumulated later, as log data is read.
> # Keys here are paths such as '/trunk/foo/bar', values are letter
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Jun 15 19:19:51 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.