Skip to content

I18n feature #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Features:
- cache for ClearCase files
- tested on Linux/Solaris and __Windows__

Requires
--------
- pytz module
https://pypi.python.org/pypi/pytz/

Main points
-----------

Expand Down
18 changes: 14 additions & 4 deletions cc2svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@

from __future__ import with_statement
import os, subprocess, time, sys, hashlib, codecs, fnmatch
import datetime
import pytz

USAGE = "Usage: %(cmd)s -run | -help" % { "cmd" : sys.argv[0] }

Expand Down Expand Up @@ -128,6 +130,9 @@
if DUMP_SINCE_DATE:
DUMP_SINCE_DATE = time.strptime(DUMP_SINCE_DATE, CC_DATE_FORMAT)

if HISTORY_FILE_TIMEZONE == "":
HISTORY_FILE_TIMEZONE = "UTC"

CCVIEW_TMPFILE = CACHE_DIR + "/label_config_spec_tmp_cc2svnpy"
CCVIEW_CONFIGSPEC = CACHE_DIR + "/user_config_spec_tmp_cc2svnpy"

Expand Down Expand Up @@ -194,7 +199,7 @@ def askYesNo(question):
if answer == "n": return False

def toUTF8(text):
unicode_str = text.decode(ENCODING)
unicode_str = text.decode(ENCODING, ENCODING_ERROR_HANDLING)
return unicode_str.encode("utf8")

#return codecs.utf_8_encode(text)[0]
Expand Down Expand Up @@ -463,7 +468,9 @@ def setAuthor(self, author):
self.properties.set("svn:author", toUTF8(author));

def setDate(self, date):
self.properties.set("svn:date", time.strftime(SVN_DATE_FORMAT, date))
dt = datetime.datetime.fromtimestamp(time.mktime(date))
utc = pytz.timezone(HISTORY_FILE_TIMEZONE).localize(dt).astimezone(pytz.utc)
self.properties.set("svn:date", utc.strftime(SVN_DATE_FORMAT))

def setMessage(self, message):
self.properties.set("svn:log", toUTF8(message));
Expand Down Expand Up @@ -830,13 +837,14 @@ def saveConfigSpec(self, file):
shellCmd(cmd, cwd=CC_VOB_DIR, outfile=file)

def setConfigSpec(self, file):
cmd = CLEARTOOL + " setcs -def " + file
cmd = CLEARTOOL + " setcs " + file
shellCmd(cmd, cwd=CC_VOB_DIR)

def setLabelSpec(self, label):
with open(CCVIEW_TMPFILE, 'w') as file:
file.write("element * CHECKEDOUT\n")
file.write("element * " + label + "\n")
file.write("element * /main/LATEST\n")
self.setConfigSpec(CCVIEW_TMPFILE)

def completeLabels(self):
Expand Down Expand Up @@ -930,10 +938,12 @@ def readList(filename):
def main():

try:

labels = readList(CC_LABELS_FILE)
branches = readList(CC_BRANCHES_FILE)
ignoredDirectories = readList(CC_IGNORED_DIRECTORIES_FILE)

info("timezone: " + HISTORY_FILE_TIMEZONE)

getCCHistory(HISTORY_FILE)

Expand Down
12 changes: 9 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
# file must contain one label per line, example:
# LABEL_1
# LABEL_2
CC_LABELS_FILE = THIS_FILE_DIR + "/labels.txt"
#CC_LABELS_FILE = THIS_FILE_DIR + "/labels.txt"

# If CC_BRANCHES_FILE is not defined, the tool will convert all branches it finds in history of the current view
# If CC_BRANCHES_FILE is defined, the tool will transfer only those branches mentioned in file
# If you do not want to transfer any branches, specify an empty file
# file must contain one branch name per line (without slashes), example:
# main
# user_dev
CC_BRANCHES_FILE = THIS_FILE_DIR + "/branches.txt"
#CC_BRANCHES_FILE = THIS_FILE_DIR + "/branches.txt"


# If CC_IGNORED_DIRECTORIES_FILE is not defined, the tool will not import history of files
Expand All @@ -64,6 +64,10 @@
# ClearCase history file created by the tool
HISTORY_FILE = "cchistory.txt"

# ClarCase history timezone by the tool (pytz.timezone())
#HISTORY_FILE_TIMEZONE = "UTC"
HISTORY_FILE_TIMEZONE = "Asia/Tokyo"

# DUMP_SINCE_DATE activates incremental dump mode. This should be used after the full dump mode only.
# The idea is: you convert cc2svn on the day X without using this option, working in svn and ClearCase simultaneously
# (do not commit the same changes in svn and CC), then create incremental dump using DUMP_SINCE_DATE=X option.
Expand All @@ -73,4 +77,6 @@
#DUMP_SINCE_DATE = "20010921.175059"

# Encoding of the history file
ENCODING = "Windows-1252"
#ENCODING = "Windows-1252"
ENCODING = "Shift_JIS"
ENCODING_ERROR_HANDLING = "ignore"