[PATCH] Allow keyword keyword expansion in a CVS 1.11-compatible way

Greg Ward <[email protected]>
Newsgroups gmane.comp.version-control.subversion.cvs2svn.devel
Message-ID <a7bbd105d6eb581a5714.1250820050@davros>
# HG changeset patch
# User Greg Ward <[email protected]>
# Date 1249407716 14400
# Node ID a7bbd105d6eb581a5714764086764a761cf4ca4d
# Parent  5f2cf6a14fcce3789fa0b1c5713707a1262c18fc
Allow keyword keyword expansion in a CVS 1.11-compatible way.

Specifically, makes it possible for a clueful user to specify
slash-delimited dates rather than hyphen-delimited.

Necessary for verifying a conversion using CVS 1.11.

* cvs2svn_lib/checkout_internal.py: _KeywordExpander:
  - factor out date_fmt class attr
  - add date_fmt_old, date_fmt_new
  - add class method use_old_date_format()

diff --git a/cvs2svn_lib/checkout_internal.py b/cvs2svn_lib/checkout_internal.py
--- a/cvs2svn_lib/checkout_internal.py
+++ b/cvs2svn_lib/checkout_internal.py
@@ -614,6 +614,18 @@
   Instances of this class can be passed as the REPL argument to
   re.sub()."""
 
+  date_fmt_old = "%Y/%m/%d %H:%M:%S"    # CVS 1.11, rcs
+  date_fmt_new = "%Y-%m-%d %H:%M:%S"    # CVS 1.12
+
+  date_fmt = date_fmt_new
+
+  @classmethod
+  def use_old_date_format(klass):
+      """Class method to ensure exact compatibility with CVS 1.11
+      output.  Use this if you want to verify your conversion and you're
+      using CVS 1.11."""
+      klass.date_fmt = klass.date_fmt_old
+
   def __init__(self, cvs_rev):
     self.cvs_rev = cvs_rev
 
@@ -625,7 +637,7 @@
     return Ctx()._metadata_db[self.cvs_rev.metadata_id].original_author
 
   def date(self):
-    return time.strftime("%Y-%m-%d %H:%M:%S",
+    return time.strftime(self.date_fmt,
                          time.gmtime(self.cvs_rev.timestamp))
 
   def header(self):

------------------------------------------------------
http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=2385871

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.