Index: ChangeLog
from Akim Demaille <akim(a)epita.fr>
* prcs2svn/prcs2svn.py (Svn.change_keywords_): Rewrite, the logic
is rotten, and makes too many file system moves.
Much remains to be optimized.
And rename to...
(Svn.change_keywords): this.
(Prcs.parse): Display time before log, since the latter can span
over several lines.
Index: prcs2svn/prcs2svn.py
--- prcs2svn/prcs2svn.py (revision 105)
+++ prcs2svn/prcs2svn.py (working copy)
@@ -540,35 +540,24 @@
prcs_to_svn_keywords[keyword] + " " + f)
return line
- # Rewrite each file exchanging prcs and svn keywords.
- def change_keywords_(self, path):
+ def change_keywords (self, path):
+ "Rewrite each file replacing PRCS keywords with Subversion's."
+ pwd = os.getcwd ()
xchdir(path)
- files = glob.glob (os.path.join (path, "*"))
- for f in files:
+ for f in glob.glob ("*"):
st = os.stat(f)
if stat.S_ISDIR (st.st_mode):
- self.change_keywords_ (os.path.join (path, f))
+ self.change_keywords (f)
else:
- tmp = TempDir().mkdir ("prcs2svn.keywords")
- atime = st[stat.ST_ATIME]
- mtime = st[stat.ST_MTIME]
- xcopy(f, tmp)
- fd_tmp = open (os.path.join (tmp, os.path.basename (f)), "r")
- # FIXME: in python, we should have that.
- xsystem("chmod +w " + quote (f))
- fd_f = open(f, "w+")
- for l in fd_tmp:
- l = self.change_keywords_line(f, l)
- fd_f.writelines([l])
- fd_tmp.close()
- fd_f.close()
- os.utime(f, (atime, mtime))
- xrm(tmp)
-
- # Just a garbage function because change_keywords_ is recursive.
- def change_keywords(self, path):
- pwd = os.getcwd()
- self.change_keywords_(path)
+ fout, rekeyed = TempDir().mkfile ("%s.re-keyed" % f)
+ fin = open (f, "r")
+ for l in fin:
+ l = self.change_keywords_line (fin, l)
+ fout.writelines ([l])
+ fout.close ()
+ fin.close ()
+ os.utime (rekeyed, (st[stat.ST_ATIME], st[stat.ST_MTIME]))
+ xmove (rekeyed, f)
xchdir(pwd)
def env_to_preserve_dates (self):
@@ -773,8 +762,8 @@
self.prev_prj = self.prj
self.prj = self.prj_parser.parse(self.prjname ())
info(" * User: " + self.prj.checkin_login)
- info(" * Version-Log: " + self.prj.version_log)
info(" * Time: " + self.prj.checkin_time)
+ info(" * Version-Log: " + self.prj.version_log)
# Set prev_prj to the PRCS parent project descriptor.
def project_parent_set(self):
Show replies by date