Pas pu réduire.
Index: ChangeLog
from Akim Demaille <akim(a)epita.fr>
Be more verbose.
* prcs2svn/prcs2svn.py (TempDir): Use xmkdir and xrm so that we
can see the actions.
(Informations.initial_svn_revision): Remove.
Use just the right number of directories to compare Svn and Prcs
repositories.
* prcs2svn/prcs2svn.py (repositoryCmp.__init__): New.
(repository_cmp, repositoryCmp.doit): Adjust.
Clean up the diff directory once done.
(repositoryCmp.compare): Say what you do.
Remove useless chdirs.
Various fixes.
* prcs2svn/prcs2svn.py (repositoryCmp.cmp_trunk): Simplify Python syntax.
(Svn.__init__): Adjust: no longer initialize Svn.revision.
(Svn.repository_init): svn mkdir is allowed to fail here.
(Svn.change_keywords): Fix change_keywords_line invocation: pass
the file name, not its fd.
Rather than blindly incrementing by one the current revision each
time we check in, just read the answer from "svn commit" and fetch
the revision number there.
* prcs2svn/prcs2svn.py (Svn.changes_commit): Do it.
Comment out some weird code (svn update).
(Prcs2svn.convert_project, Main.init_repositories): Adjust.
(Main.initialize_svn_revision): Remove.
Index: prcs2svn/prcs2svn.py
--- prcs2svn/prcs2svn.py (revision 106)
+++ prcs2svn/prcs2svn.py (working copy)
@@ -22,14 +22,14 @@
def mkdir (self, name):
dirname = os.path.join (self.base, name)
# Ignore rm errors: the file might be fresh.
- shutil.rmtree (dirname, True)
- os.mkdir (dirname)
+ xrm (dirname)
+ xmkdir (dirname)
return dirname
def mkfile (self, name):
fname = os.path.join (self.base, name)
# Ignore rm errors: the file might be fresh.
- shutil.rmtree (fname, True)
+ xrm (fname)
return (open (fname, "wb"), fname)
def mksfile (self, name):
@@ -227,9 +227,6 @@
# Copy svn repository (use it to extend a svn repository)
copy_svn = False
- # Initial revision number of svn repository
- initial_svn_revision = 0
-
# Where to write in svn project
subdir = ""
@@ -381,11 +378,14 @@
__prcs_project = ""
def prjname (self):
- """Name of the PRJ file."""
+ "Name of the PRJ file."
return self.prcs_project + ".prj"
- def __del__(self):
- xrm(self.tmp)
+ def __init__ (self, prcs_project, svn_project):
+ self.prcs_project = prcs_project
+ self.svn_project = svn_project
+ self.tmp = TempDir().mkdir ("%s.prcs-%s.svn.diff"
+ % (prcs_project, svn_project))
# Remove keyword to compare repositories.
def keywords_clean(self, line):
@@ -399,7 +399,7 @@
# Compare two directories.
def compare(self, path_svn, path_prcs):
- xchdir(self.tmp)
+ info ("Compare %s and %s." % (path_svn, path_prcs))
dircmp = dirCmp()
result = dircmp.cmp(os.path.join(os.getcwd(), path_prcs),
os.path.join(os.getcwd(), path_svn),
@@ -408,12 +408,11 @@
if not result:
dircmp.report()
raise RepositoriesDifferent()
- xchdir(self.tmp)
# Compare trunk of the project.
def cmp_trunk(self, prcs_revision=""):
info("> Comparing trunk.")
- if prcs_revision != "":
+ if prcs_revision:
prcs_revision = " -r " + prcs_revision + " "
xmkdir(self.prcs_project + "_prcs")
xchdir(self.prcs_project + "_prcs")
@@ -447,13 +446,9 @@
self.compare(svn_repo, self.prcs_project + prcs_revision + "_prcs")
# Compare two repositories of specified (or not) revisions.
- def doit(self, prcs_project, svn_project, svn_repo, prcs_revision="",
- svn_revision=""):
- self.prcs_project = prcs_project
- self.svn_project = svn_project
- self.tmp = TempDir().mkdir ("%s.prcs-%s.svn.diff" % (prcs_project,
svn_project))
+ def doit (self, svn_repo, prcs_revision="", svn_revision=""):
xchdir(self.tmp)
- if svn_revision != "":
+ if svn_revision:
svn_revision = " -r " + svn_revision + " "
xsystem("svn checkout " + svn_revision + svn_repo)
if prcs_revision == "":
@@ -468,10 +463,10 @@
# Main to compare two repositories.
def repository_cmp(prcs_project, svn_project, svn_repo, prcs_revision="",
svn_revision=""):
- repo_cmp = repositoryCmp()
- repo_cmp.doit(prcs_project, svn_project, svn_repo, prcs_revision,
- svn_revision)
-
+ repo_cmp = repositoryCmp (prcs_project, svn_project)
+ repo_cmp.doit (svn_repo, prcs_revision, svn_revision)
+ # Don't rely on the dtor, since it is non deterministically called!
+ xrm (repo_cmp.tmp)
@@ -505,7 +500,6 @@
self.branch = ""
self.branches = {}
self.name = infos.svn_project
- self.revision = infos.initial_svn_revision
# Create initial repository.
# Simulate branches with the 'trunk' and 'branches' repositories.
@@ -518,10 +512,16 @@
xsystem("svn checkout " + self.repository + " " +
quote(self.topdir))
info("> Create subversion repository tree")
if len(infos.subdir) > 0:
- xsystem("svn mkdir " + infos.subdir, False)
- xsystem("svn mkdir " + os.path.join(infos.subdir, "branches") +
" " +\
- os.path.join(infos.subdir, "trunk") + " " +\
- os.path.join(infos.subdir, "tags"), False)
+ xsystem("svn mkdir " + infos.subdir)
+ # FIXME: Rather than accepting failures on mkdir, we should test for
+ # there existence first.
+ xsystem ("svn mkdir " +
+ os.path.join (infos.subdir, "branches") + " " +
+ os.path.join (infos.subdir, "trunk") + " " +
+ os.path.join (infos.subdir, "tags"),
+ # If we are launched on an existing hierarchy, these directories
+ # already exist.
+ True)
def repository_desinit(self):
pass
@@ -536,7 +536,7 @@
line = re.sub("\$" + keyword + ": [^\$]*\$",
"$" + prcs_to_svn_keywords[keyword] + "$",
line)
if len(line_bak) != len(line):
- xsystem("svn propset svn:keywords " +\
+ xsystem ("svn propset svn:keywords " +
prcs_to_svn_keywords[keyword] + " " + f)
return line
@@ -552,7 +552,7 @@
fout, rekeyed = TempDir().mkfile ("%s.re-keyed" % f)
fin = open (f, "r")
for l in fin:
- l = self.change_keywords_line (fin, l)
+ l = self.change_keywords_line (f, l)
fout.writelines ([l])
fout.close ()
fin.close ()
@@ -587,14 +587,16 @@
# FIXME: `encoding' must be a command line option.
self.change_keywords(self.workdir)
env = self.env_to_preserve_dates ()
- r = xtee (env + "svn commit --encoding latin1 " + \
+ msg = xcat (env + "svn commit --encoding latin1 " + \
"--username " + quote (checkin_login) + \
" --message " + quote (version_log))
- if r > 0:
- self.revision += 1
+ # The last line of the msg contains the checkin revision.
+ print "(" + msg + ")"
+ if msg:
+ self.revision = re.search (r'Committed revision (\d+)\.', msg).group (1)
# Refresh local copy (should be useless, may be a bug of svn).
- if update:
- xsystem("svn update")
+ # if update:
+ # xsystem("svn update")
# Replace symbolic links with the files they point to.
def changes_apply_links_replace(self, diffs):
@@ -890,7 +892,6 @@
prcsProject.prj.version.name(),
str(self.svn.revision))
repository_cmp(prcsProject.name, self.svn.name, self.svn.repository)
- infos.initial_svn_revision = self.svn.revision
self.prcs_to_svn_list.append(self.prcs_to_svn)
@@ -1111,7 +1112,6 @@
self.copy_prcs_repository()
self.copy_svn_repository()
self.create_svn_repository()
- self.initialize_svn_revision()
def desinit_repositories(self):
if infos.copy_prcs:
@@ -1159,11 +1159,6 @@
" " + new_repo, False)
infos.svn_root = urlparse.urljoin("file://", urllib.pathname2url(tmp))
- def initialize_svn_revision(self):
- infos.initial_svn_revision = \
- int (xcat("svnlook youngest " + os.path.join(infos.svn_root[7:],
- infos.svn_project)))
-
def test_environment(self):
if not os.environ.has_key('LANG') or os.environ['LANG'] ==
'C':
print "Warning: LANG is not set. " +\