Index: ChangeLog
from Akim Demaille <akim(a)epita.fr>
* prcs2svn/re2glob.py (Parser.parse): Don't output globs with a
trailing / (e.g., "auto/") since that confuses prcs2svn that
believes it's an svn:ignore for auto/, which of course is not
registered.
* prcs2svn/prcs2svn.py (Main.create_svn_repository): While I'm at
it, use os.path.join consistently instead of ad hoc code.
(Prcs2svn.ignore_set): Ignore failures to register ignores.
Index: prcs2svn/re2glob.py
--- prcs2svn/re2glob.py (revision 96)
+++ prcs2svn/re2glob.py (working copy)
@@ -1,10 +1,10 @@
#!/usr/bin/env python
import sys
+import os
import string
import prcs
-
## ------------------------------------------------------------------------
## Regular expression to wildcard matching (globbing)
## ------------------------------------------------------------------------
@@ -197,17 +197,22 @@
for i in range(len(globs)):
if len(globs[i]) >= 2:
if globs[i][0] == '^' and globs[i][-1] == '$':
- globs[i] = globs[i][:-1]
- globs[i] = globs[i][1:]
+ globs[i] = globs[i][1:-1]
elif globs[i][-1] == '$':
- globs[i] = '*' + globs[i]
- globs[i] = globs[i][:-1]
+ globs[i] = '*' + globs[i][:-1]
elif globs[i][0] == '^':
- globs[i] = globs[i] + "*"
- globs[i] = globs[i][1:]
+ globs[i] = globs[i][1:] + "*"
else:
globs[i] = "*" + globs[i] + "*"
+ # Avoid useless trailing slashes that might confuse an engine
+ # looking for local (to a directory) vs. global patterns.
+ # Hopefully, there is only one such /.
+ for i in range (len (globs)):
+ if len (globs[i]) >= 2:
+ if globs[i][-1] == os.sep:
+ globs[i] = globs[i][:-1]
+
return globs
Index: prcs2svn/prcs2svn.py
--- prcs2svn/prcs2svn.py (revision 99)
+++ prcs2svn/prcs2svn.py (working copy)
@@ -267,7 +267,7 @@
# Return a clean list of files from a directory (full path).
def files_of_dir(self, dir, ignores=[]):
- files = glob.glob(dir + os.sep + "*")
+ files = glob.glob(os.path.join (dir, "*"))
for i in range(len(files)):
files[i] = os.path.basename(files[i])
for ignore in ignores:
@@ -412,8 +412,7 @@
# Compare branches of the project.
def cmp_branches(self):
info("> Comparing branches.")
- branches = glob.glob(self.prcs_project + os.sep + "branches" + \
- os.sep + "*")
+ branches = glob.glob(os.path.join (self.prcs_project, "branches",
"*"))
for branch in branches:
branch = os.path.basename(branch)
self.cmp_branch(branch)
@@ -527,7 +526,7 @@
# Rewrite each file exchanging prcs and svn keywords.
def change_keywords_(self, path):
xchdir(path)
- files = glob.glob(path + os.sep + "*")
+ files = glob.glob (os.path.join (path, "*"))
for f in files:
st = os.stat(f)
if stat.S_ISDIR(st.st_mode):
@@ -537,7 +536,7 @@
atime = st[stat.ST_ATIME]
mtime = st[stat.ST_MTIME]
xcopy(f, tmp)
- fd_tmp = open(tmp + os.sep + os.path.basename(f), "r")
+ fd_tmp = open (os.path.join (tmp, os.path.basename (f)), "r")
# FIXME: in python, we should have that.
xsystem("chmod +w " + f)
fd_f = open(f, "w+")
@@ -678,8 +677,7 @@
for e in l:
info(" * " + e)
# --force is a joke.
- if os.path.exists("." + os.sep + os.path.dirname(e) + os.sep +
- ".svn"):
+ if os.path.exists(os.path.join (os.path.dirname(e), ".svn")):
args = args + " " + quote(e)
if infos.action and len(args) > 0:
xsystem ("svn delete --force " + args)
@@ -929,7 +927,7 @@
self.svn.branch = svn_new_branch
if self.svn.branches.has_key(self.svn.branch):
info("> Return to branch: " + self.svn.branch)
- xchdir(self.workdir + os.sep + self.svn.branch)
+ xchdir(os.path.join (self.workdir, self.svn.branch))
# FIXME: may be a comparison with svn branches.
if prcsProject.prj.parent_version.major != \
prcsProject.prj.version.major:
@@ -939,7 +937,7 @@
else:
if prcsProject.prj.parent_version.major == "-*-":
info("> Initial revision")
- xchdir(self.workdir + os.sep + self.svn.branch)
+ xchdir(os.path.join (self.workdir, self.svn.branch))
xsystem("svn checkout " + self.svn.repository + " " +\
quote(self.workdir))
else:
@@ -948,7 +946,7 @@
self.prcs_to_svn[prcsProject.prj.parent_version.name()]
xsystem("svn copy -r " + str(svn_parent[1]) + \
" " + svn_parent[0] + " " + self.svn.branch)
- xchdir(self.workdir + os.sep + self.svn.branch)
+ xchdir(os.path.join (self.workdir, self.svn.branch))
self.svn.changes_commit("prcs2svn", "Make a new branch.",
prcsProject.create_date)
self.svn.branches[self.svn.branch] = [self.svn.revision,
@@ -956,7 +954,7 @@
# Merge with parents.
def merge(self, prcsProject):
- xchdir(self.workdir + os.sep + self.svn.branch)
+ xchdir(os.path.join (self.workdir, self.svn.branch))
prcs_merged_parents = []
for prcs_merge_parent in prcsProject.prj.merge_parents:
# Skip already merged parents (complete/incomplete repetition).
@@ -999,7 +997,7 @@
# Synchronize PRCS and Subversion repositories
def synchronize(self, prcsProject):
info("> Checkout whole revision from PRCS repository")
- xchdir(self.workdir + os.sep + self.svn.branch)
+ xchdir(os.path.join (self.workdir, self.svn.branch))
xsystem("prcs checkout -f -r " + prcsProject.prj.version.name() + \
" " + prcsProject.name + ".prj")
# Make a diff between previous and current prj's file.
@@ -1029,8 +1027,9 @@
info("> PRCS " + prcsProject.prj.version.name() + " ->
Subversion " + \
self.svn.branch + " r" + str(self.svn.revision) + "\n\n")
- # Set which file must be ignored by subversion.
+
def ignore_set(self, prcs_project):
+ "Set which file must be ignored by subversion."
p = prcs.ProjectParser()
p = p.parse(prcs_project + ".prj")
globs_local = []
@@ -1068,8 +1067,11 @@
for g in globs_local_bypath[path]:
fd.write(g + "\n")
fd.close()
- xsystem("svn --force propset svn:ignore -F " + \
- ".svnignore_local " + path)
+ xsystem ("svn --force propset svn:ignore -F .svnignore_local " + path,
+ # Ignore errors due to patterns in directories not under
+ # control (e.g., ignore "^auto/*", but auto/ not under
+ # control).
+ True)
# Print prcs revision / svn revision.
def print_revisions(self):
@@ -1110,7 +1112,7 @@
if infos.svn_root[0] != 'f':
return
path = infos.svn_root[7:]
- fpath = path + os.sep + infos.svn_project
+ fpath = os.path.join (path, infos.svn_project)
if len(dircache.opendir(fpath)) == 0:
info("> Create subversion repository")
xsystem("svnadmin create " + fpath)
@@ -1214,8 +1216,7 @@
infos.prcs_projects = args
# Should be done with autotools.
- p = os.path.normpath(
- os.path.dirname(os.path.join(os.getcwd(), sys.argv[0]))) + os.sep +
".libs"
+ p = os.path.join (os.path.abspath (sys.argv[0]), ".libs")
if len(dircache.opendir(p)) != 0:
infos.timelib_path = p