Index: ChangeLog
from Akim Demaille <akim(a)epita.fr>
* prcs2svn/prcs2svn.py
Introduce --no-rekey, and spare useless keyword translations.
* prcs2svn/prcs2svn.py (Informations.translate_keywords): New.
(Main.parse_opt): Handle --no-rekey.
(Svn.change_keywords): Rename as...
(Svn.change_keywords_): this.
(Svn.change_keywords): New wrapper, taking
Informations.translate_keywords into account.
(Svn.changes_commit): Do not call change_keywords here, since some
commit do not need keyword translation.
(Prcs2svn.synchronize): Do it here, when the files are actually
coming from PRCS.
Index: prcs2svn/prcs2svn.py
--- prcs2svn/prcs2svn.py (revision 107)
+++ prcs2svn/prcs2svn.py (working copy)
@@ -233,6 +233,9 @@
# Delete files after a merge
keep_deleted_files = False
+ # Translate the $Id$ etc. keywords.
+ translate_keywords = True
+
infos = Informations()
# Keywords.
@@ -540,14 +543,14 @@
prcs_to_svn_keywords[keyword] + " " + f)
return line
- def change_keywords (self, path):
+ def change_keywords_ (self, path):
"Rewrite each file replacing PRCS keywords with Subversion's."
pwd = os.getcwd ()
xchdir (path)
for f in glob.glob ("*"):
st = os.stat (f)
if stat.S_ISDIR (st.st_mode):
- self.change_keywords (f)
+ self.change_keywords_ (f)
else:
fout, rekeyed = TempDir().mkfile ("%s.re-keyed" % f)
fin = open (f, "r")
@@ -560,6 +563,12 @@
xmove (rekeyed, f)
xchdir (pwd)
+ def change_keywords (self):
+ "Rewrite each file replacing PRCS keywords with Subversion's."
+ if infos.translate_keywords:
+ info("> Translating keywords")
+ self.change_keywords_ (self.workdir)
+
def env_to_preserve_dates (self):
"Return the environment assignment needed to preserve checkin dates."
res = ""
@@ -585,7 +594,6 @@
# Write version log in a temporary file.
# Do commit.
# FIXME: `encoding' must be a command line option.
- self.change_keywords(self.workdir)
env = self.env_to_preserve_dates ()
msg = xcat (env + "svn commit --encoding latin1 " + \
"--username " + quote (checkin_login) + \
@@ -1017,8 +1025,12 @@
prcsProject.prj.version_log,
prcsProject.prj.checkin_time)
self.ignore_set(prcsProject.name)
+ # FIXME: Brute force keyword translation: using a list of files
+ # would be more intelligent.
+ self.svn.change_keywords ()
self.svn.changes_commit(prcsProject.prj.checkin_login,
- prcsProject.prj.version_log, prcsProject.prj.checkin_time)
+ prcsProject.prj.version_log,
+ prcsProject.prj.checkin_time)
# Convert a revision of a project.
def convert_project_of_revision(self, prcsProject, prcs_version):
@@ -1174,7 +1186,8 @@
"preserve-date", "copy-prcs",
"svn-root=", "copy-svn",
"svn-project=", "subdir=",
- "keep-deleted-files"])
+ "keep-deleted-files",
+ "no-rekey"])
except getopt.GetoptError, error_msg:
raise ScanOpt(str(error_msg))
@@ -1184,31 +1197,33 @@
sys.exit(0)
if o == "--usage":
self.usage(); sys.exit(0)
- if o in ("-V", "--version"):
+ elif o in ("-V", "--version"):
self.version()
sys.exit(0)
- if o in ("-t", "--trace"):
+ elif o in ("-t", "--trace"):
if not a in trace_levels:
self.usage()
raise ParseOpt()
infos.trace_level = trace_levels[a]
if o in ("-f", "--force"):
infos.force = True
- if o in ("-p", "--preserve-date"):
+ elif o in ("-p", "--preserve-date"):
infos.preserve_dates = True
- if o in ("-n", "--no-action"):
+ elif o in ("-n", "--no-action"):
infos.action = False
- if o in ("-c", "--copy-prcs"):
+ elif o in ("-c", "--copy-prcs"):
infos.copy_prcs = True
- if o == "--copy-svn":
+ elif o == "--copy-svn":
infos.copy_svn = True
- if o == "--keep-deleted-files":
+ elif o == "--keep-deleted-files":
infos.keep_deleted_files = True
- if o == "--svn-root":
+ elif o == "--svn-root":
infos.svn_root = a
- if o == "--svn-project":
+ elif o == "--no-rekey":
+ infos.translate_keywords = False
+ elif o == "--svn-project":
infos.svn_project = a
- if o == "--subdir":
+ elif o == "--subdir":
infos.subdir = a
if len(args) < 1:
@@ -1235,6 +1250,7 @@
print " [--svn-root=URL]"
print " [--svn-project=NAME]"
print " [--subdir=PATH]"
+ print " [--no-rekey]"
print " <project prcs> ..."
def version(self):
@@ -1262,6 +1278,8 @@
--copy-svn copy svn repository of a project and extend this copy
(need a svn root beginning with 'file' and not
'http').
--keep-deleted-files preserve deleted files after a merge operation
+ --no-rekey do not translate PRCS keywords into Subversion keywords.
+ This is useful to speed up tests.
Subversion destination repository and project:
--svn-root=URL set subversion repository root to URL