stepmod-utils 0.2.0 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +42 -0
- data/.github/workflows/release.yml +23 -20
- data/Gemfile +2 -1
- data/Makefile +5 -0
- data/README.adoc +82 -1
- data/exe/stepmod-annotate-all +39 -0
- data/exe/stepmod-build-resource-docs-cache +19 -0
- data/exe/stepmod-convert-express-description +33 -0
- data/exe/stepmod-convert-express-resource +33 -0
- data/exe/stepmod-extract-terms +3 -3
- data/exe/stepmod-find-express-files +23 -0
- data/lib/stepmod/utils/cleaner.rb +11 -0
- data/lib/stepmod/utils/converters/a.rb +47 -0
- data/lib/stepmod/utils/converters/blockquote.rb +22 -0
- data/lib/stepmod/utils/converters/br.rb +15 -0
- data/lib/stepmod/utils/converters/bypass.rb +81 -0
- data/lib/stepmod/utils/converters/code.rb +19 -0
- data/lib/stepmod/utils/converters/comment.rb +16 -0
- data/lib/stepmod/utils/converters/dd.rb +15 -0
- data/lib/stepmod/utils/converters/def.rb +11 -4
- data/lib/stepmod/utils/converters/dl.rb +31 -0
- data/lib/stepmod/utils/converters/drop.rb +22 -0
- data/lib/stepmod/utils/converters/dt.rb +17 -0
- data/lib/stepmod/utils/converters/em_express_description.rb +22 -0
- data/lib/stepmod/utils/converters/eqn.rb +97 -0
- data/lib/stepmod/utils/converters/example.rb +1 -6
- data/lib/stepmod/utils/converters/express_g.rb +49 -0
- data/lib/stepmod/utils/converters/express_ref_express_description.rb +13 -0
- data/lib/stepmod/utils/converters/ext_description.rb +17 -0
- data/lib/stepmod/utils/converters/ext_descriptions.rb +14 -0
- data/lib/stepmod/utils/converters/fund_cons.rb +21 -0
- data/lib/stepmod/utils/converters/head.rb +22 -0
- data/lib/stepmod/utils/converters/hr.rb +15 -0
- data/lib/stepmod/utils/converters/ignore.rb +16 -0
- data/lib/stepmod/utils/converters/introduction.rb +15 -0
- data/lib/stepmod/utils/converters/note.rb +1 -6
- data/lib/stepmod/utils/converters/ol.rb +3 -2
- data/lib/stepmod/utils/converters/p.rb +21 -0
- data/lib/stepmod/utils/converters/pass_through.rb +13 -0
- data/lib/stepmod/utils/converters/q.rb +16 -0
- data/lib/stepmod/utils/converters/resource.rb +14 -0
- data/lib/stepmod/utils/converters/schema.rb +19 -0
- data/lib/stepmod/utils/converters/schema_diag.rb +14 -0
- data/lib/stepmod/utils/converters/strong.rb +41 -0
- data/lib/stepmod/utils/converters/sub.rb +24 -0
- data/lib/stepmod/utils/converters/sup.rb +22 -0
- data/lib/stepmod/utils/converters/table.rb +62 -0
- data/lib/stepmod/utils/converters/text.rb +68 -0
- data/lib/stepmod/utils/html_to_asciimath.rb +157 -0
- data/lib/stepmod/utils/smrl_description_converter.rb +49 -0
- data/lib/stepmod/utils/smrl_resource_converter.rb +67 -0
- data/lib/stepmod/utils/stepmod_file_annotator.rb +78 -0
- data/lib/stepmod/utils/version.rb +1 -1
- data/migrating_from_cvs.adoc +190 -0
- data/stepmod-utils.gemspec +1 -0
- metadata +69 -8
- data/.github/workflows/macos.yml +0 -39
- data/.github/workflows/ubuntu.yml +0 -53
- data/.github/workflows/windows.yml +0 -41
@@ -0,0 +1,157 @@
|
|
1
|
+
module Stepmod
|
2
|
+
module Utils
|
3
|
+
class HtmlToAsciimath
|
4
|
+
def call(input)
|
5
|
+
return input if input.nil? || input.empty?
|
6
|
+
|
7
|
+
to_asciimath = Nokogiri::HTML.fragment(input, "UTF-8")
|
8
|
+
|
9
|
+
to_asciimath.css('i').each do |math_element|
|
10
|
+
# puts "HTML MATH!! #{math_element.to_xml}"
|
11
|
+
# puts "HTML MATH!! #{math_element.text}"
|
12
|
+
decoded = text_to_asciimath(math_element.text)
|
13
|
+
case decoded.length
|
14
|
+
when 1..12
|
15
|
+
# puts "(#{math_element.text} to => #{decoded})"
|
16
|
+
math_element.replace "stem:[#{decoded}]"
|
17
|
+
when 0
|
18
|
+
math_element.remove
|
19
|
+
else
|
20
|
+
math_element.replace "_#{decoded}_"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
to_asciimath.css('sub').each do |math_element|
|
25
|
+
case math_element.text.length
|
26
|
+
when 0
|
27
|
+
math_element.remove
|
28
|
+
else
|
29
|
+
math_element.replace "~#{text_to_asciimath(math_element.text)}~"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
to_asciimath.css('sup').each do |math_element|
|
34
|
+
case math_element.text.length
|
35
|
+
when 0
|
36
|
+
math_element.remove
|
37
|
+
else
|
38
|
+
math_element.replace "^#{text_to_asciimath(math_element.text)}^"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
to_asciimath.css('ol').each do |element|
|
43
|
+
element.css('li').each do |li|
|
44
|
+
li.replace ". #{li.text}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
to_asciimath.css('ul').each do |element|
|
49
|
+
element.css('li').each do |li|
|
50
|
+
li.replace "* #{li.text}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Replace sans-serif font with monospace
|
55
|
+
to_asciimath.css('font[style*="sans-serif"]').each do |x|
|
56
|
+
x.replace "`#{x.text}`"
|
57
|
+
end
|
58
|
+
|
59
|
+
html_entities_to_stem(
|
60
|
+
to_asciimath.children.to_s.gsub(/\]stem:\[/, '').gsub(/<\/?[uo]l>/, '')
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def text_to_asciimath(text)
|
65
|
+
html_entities_to_asciimath(text.decode_html)
|
66
|
+
end
|
67
|
+
|
68
|
+
def html_entities_to_asciimath(x)
|
69
|
+
x.gsub("α", "alpha").
|
70
|
+
gsub("β", "beta").
|
71
|
+
gsub("γ", "gamma").
|
72
|
+
gsub("Γ", "Gamma").
|
73
|
+
gsub("δ", "delta").
|
74
|
+
gsub("Δ", "Delta").
|
75
|
+
gsub("ε", "epsilon").
|
76
|
+
gsub("ϵ", "varepsilon").
|
77
|
+
gsub("ζ", "zeta").
|
78
|
+
gsub("η", "eta").
|
79
|
+
gsub("θ", "theta").
|
80
|
+
gsub("Θ", "Theta").
|
81
|
+
gsub("ϑ", "vartheta").
|
82
|
+
gsub("ι", "iota").
|
83
|
+
gsub("κ", "kappa").
|
84
|
+
gsub("λ", "lambda").
|
85
|
+
gsub("Λ", "Lambda").
|
86
|
+
gsub("μ", "mu").
|
87
|
+
gsub("ν", "nu").
|
88
|
+
gsub("ξ", "xi").
|
89
|
+
gsub("Ξ", "Xi").
|
90
|
+
gsub("π", "pi").
|
91
|
+
gsub("Π", "Pi").
|
92
|
+
gsub("ρ", "rho").
|
93
|
+
gsub("β", "beta").
|
94
|
+
gsub("σ", "sigma").
|
95
|
+
gsub("Σ", "Sigma").
|
96
|
+
gsub("τ", "tau").
|
97
|
+
gsub("υ", "upsilon").
|
98
|
+
gsub("φ", "phi").
|
99
|
+
gsub("Φ", "Phi").
|
100
|
+
gsub("ϕ", "varphi").
|
101
|
+
gsub("χ", "chi").
|
102
|
+
gsub("ψ", "psi").
|
103
|
+
gsub("Ψ", "Psi").
|
104
|
+
gsub("ω", "omega")
|
105
|
+
gsub("χ", "χ").
|
106
|
+
gsub("×", "×").
|
107
|
+
gsub("Σ", "Σ").
|
108
|
+
gsub("ρ", "ρ").
|
109
|
+
gsub("σ", "σ").
|
110
|
+
gsub("λ", "λ").
|
111
|
+
gsub("τ", "τ").
|
112
|
+
gsub("∂", "∂").
|
113
|
+
gsub("≤", "≤").
|
114
|
+
gsub("≥", "≥")
|
115
|
+
end
|
116
|
+
|
117
|
+
def html_entities_to_stem(x)
|
118
|
+
x.gsub("α", "stem:[alpha]").
|
119
|
+
gsub("β", "stem:[beta]").
|
120
|
+
gsub("γ", "stem:[gamma]").
|
121
|
+
gsub("Γ", "stem:[Gamma]").
|
122
|
+
gsub("δ", "stem:[delta]").
|
123
|
+
gsub("Δ", "stem:[Delta]").
|
124
|
+
gsub("ε", "stem:[epsilon]").
|
125
|
+
gsub("ϵ", "stem:[varepsilon]").
|
126
|
+
gsub("ζ", "stem:[zeta]").
|
127
|
+
gsub("η", "stem:[eta]").
|
128
|
+
gsub("θ", "stem:[theta]").
|
129
|
+
gsub("Θ", "stem:[Theta]").
|
130
|
+
gsub("ϑ", "stem:[vartheta]").
|
131
|
+
gsub("ι", "stem:[iota]").
|
132
|
+
gsub("κ", "stem:[kappa]").
|
133
|
+
gsub("λ", "stem:[lambda]").
|
134
|
+
gsub("Λ", "stem:[Lambda]").
|
135
|
+
gsub("μ", "stem:[mu]").
|
136
|
+
gsub("ν", "stem:[nu]").
|
137
|
+
gsub("ξ", "stem:[xi]").
|
138
|
+
gsub("Ξ", "stem:[Xi]").
|
139
|
+
gsub("π", "stem:[pi]").
|
140
|
+
gsub("Π", "stem:[Pi]").
|
141
|
+
gsub("ρ", "stem:[rho]").
|
142
|
+
gsub("β", "stem:[beta]").
|
143
|
+
gsub("σ", "stem:[sigma]").
|
144
|
+
gsub("Σ", "stem:[Sigma]").
|
145
|
+
gsub("τ", "stem:[tau]").
|
146
|
+
gsub("υ", "stem:[upsilon]").
|
147
|
+
gsub("φ", "stem:[phi]").
|
148
|
+
gsub("Φ", "stem:[Phi]").
|
149
|
+
gsub("ϕ", "stem:[varphi]").
|
150
|
+
gsub("χ", "stem:[chi]").
|
151
|
+
gsub("ψ", "stem:[psi]").
|
152
|
+
gsub("Ψ", "stem:[Psi]").
|
153
|
+
gsub("ω", "stem:[omega]")
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'reverse_adoc'
|
4
|
+
require 'stepmod/utils/converters/a'
|
5
|
+
require 'stepmod/utils/converters/blockquote'
|
6
|
+
require 'stepmod/utils/converters/br'
|
7
|
+
require 'stepmod/utils/converters/bypass'
|
8
|
+
require 'stepmod/utils/converters/code'
|
9
|
+
require 'stepmod/utils/converters/drop'
|
10
|
+
require 'stepmod/utils/converters/em_express_description'
|
11
|
+
require 'stepmod/utils/converters/example'
|
12
|
+
require 'stepmod/utils/converters/express_ref_express_description'
|
13
|
+
require 'stepmod/utils/converters/ext_description'
|
14
|
+
require 'stepmod/utils/converters/ext_descriptions'
|
15
|
+
require 'stepmod/utils/converters/head'
|
16
|
+
require 'stepmod/utils/converters/hr'
|
17
|
+
require 'stepmod/utils/converters/ignore'
|
18
|
+
require 'stepmod/utils/converters/note'
|
19
|
+
require 'stepmod/utils/converters/p'
|
20
|
+
require 'stepmod/utils/converters/pass_through'
|
21
|
+
require 'stepmod/utils/converters/q'
|
22
|
+
require 'stepmod/utils/converters/strong'
|
23
|
+
require 'stepmod/utils/converters/sub'
|
24
|
+
require 'stepmod/utils/converters/sup'
|
25
|
+
require 'stepmod/utils/converters/text'
|
26
|
+
require 'stepmod/utils/cleaner'
|
27
|
+
|
28
|
+
module Stepmod
|
29
|
+
module Utils
|
30
|
+
class SmrlDescriptionConverter
|
31
|
+
def self.convert(input, options = {})
|
32
|
+
root = if input.is_a?(String)
|
33
|
+
then Nokogiri::XML(input).root
|
34
|
+
elsif input.is_a?(Nokogiri::XML::Document)
|
35
|
+
then input.root
|
36
|
+
elsif input.is_a?(Nokogiri::XML::Node)
|
37
|
+
then input
|
38
|
+
end
|
39
|
+
|
40
|
+
root || (return '')
|
41
|
+
|
42
|
+
ReverseAdoc.config.with(options) do
|
43
|
+
result = ReverseAdoc::Converters.lookup(root.name).convert(root)
|
44
|
+
Stepmod::Utils::Cleaner.new.tidy(result)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'reverse_adoc'
|
4
|
+
require 'reverse_adoc/converters/bypass'
|
5
|
+
require 'reverse_adoc/converters/pass_through'
|
6
|
+
require 'stepmod/utils/converters/a'
|
7
|
+
require 'stepmod/utils/converters/blockquote'
|
8
|
+
require 'stepmod/utils/converters/br'
|
9
|
+
require 'stepmod/utils/converters/bypass'
|
10
|
+
require 'stepmod/utils/converters/code'
|
11
|
+
require 'stepmod/utils/converters/comment'
|
12
|
+
require 'stepmod/utils/converters/dd'
|
13
|
+
require 'stepmod/utils/converters/dl'
|
14
|
+
require 'stepmod/utils/converters/dt'
|
15
|
+
require 'stepmod/utils/converters/drop'
|
16
|
+
require 'stepmod/utils/converters/example'
|
17
|
+
require 'stepmod/utils/converters/express_g'
|
18
|
+
require 'stepmod/utils/converters/fund_cons'
|
19
|
+
require 'stepmod/utils/converters/eqn'
|
20
|
+
require 'stepmod/utils/converters/head'
|
21
|
+
require 'stepmod/utils/converters/hr'
|
22
|
+
require 'stepmod/utils/converters/ignore'
|
23
|
+
require 'stepmod/utils/converters/introduction'
|
24
|
+
require 'stepmod/utils/converters/note'
|
25
|
+
require 'stepmod/utils/converters/ol'
|
26
|
+
require 'stepmod/utils/converters/p'
|
27
|
+
require 'stepmod/utils/converters/pass_through'
|
28
|
+
require 'stepmod/utils/converters/q'
|
29
|
+
require 'stepmod/utils/converters/resource'
|
30
|
+
require 'stepmod/utils/converters/schema_diag'
|
31
|
+
require 'stepmod/utils/converters/schema'
|
32
|
+
require 'stepmod/utils/converters/strong'
|
33
|
+
require 'stepmod/utils/converters/sub'
|
34
|
+
require 'stepmod/utils/converters/sup'
|
35
|
+
require 'stepmod/utils/converters/table'
|
36
|
+
require 'stepmod/utils/converters/text'
|
37
|
+
require 'stepmod/utils/cleaner'
|
38
|
+
|
39
|
+
require 'reverse_adoc/converters/figure'
|
40
|
+
require 'reverse_adoc/converters/img'
|
41
|
+
require 'reverse_adoc/converters/li'
|
42
|
+
require 'reverse_adoc/converters/tr'
|
43
|
+
require 'reverse_adoc/converters/td'
|
44
|
+
require 'reverse_adoc/converters/th'
|
45
|
+
|
46
|
+
module Stepmod
|
47
|
+
module Utils
|
48
|
+
class SmrlResourceConverter
|
49
|
+
def self.convert(input, options = {})
|
50
|
+
root = if input.is_a?(String)
|
51
|
+
then Nokogiri::XML(input).root
|
52
|
+
elsif input.is_a?(Nokogiri::XML::Document)
|
53
|
+
then input.root
|
54
|
+
elsif input.is_a?(Nokogiri::XML::Node)
|
55
|
+
then input
|
56
|
+
end
|
57
|
+
|
58
|
+
root || (return '')
|
59
|
+
|
60
|
+
ReverseAdoc.config.with(options) do
|
61
|
+
result = ReverseAdoc::Converters.lookup(root.name).convert(root)
|
62
|
+
Stepmod::Utils::Cleaner.new.tidy(result)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'stepmod/utils/smrl_description_converter'
|
3
|
+
require 'stepmod/utils/smrl_resource_converter'
|
4
|
+
|
5
|
+
module Stepmod
|
6
|
+
module Utils
|
7
|
+
class StepmodFileAnnotator
|
8
|
+
attr_reader :express_file, :resource_docs_cache_file, :stepmod_dir
|
9
|
+
|
10
|
+
# @param express_file [String] path to the exp file needed to annotate
|
11
|
+
# @param resource_docs_cache_file [String] output of ./stepmod-build-resource-docs-cache
|
12
|
+
def initialize(express_file:, resource_docs_cache_file:, stepmod_dir: nil)
|
13
|
+
@express_file = express_file
|
14
|
+
@resource_docs_cache_file = resource_docs_cache_file
|
15
|
+
@stepmod_dir = stepmod_dir || Dir.pwd
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
match = File.basename(express_file).match('^(arm|mim|bom)\.exp$')
|
20
|
+
descriptions_base = match ? "#{match.captures[0]}_descriptions.xml" : 'descriptions.xml'
|
21
|
+
descriptions_file = File.join(File.dirname(express_file), descriptions_base)
|
22
|
+
output_express = File.read(express_file)
|
23
|
+
resource_docs_cache = JSON.parse(File.read(resource_docs_cache_file))
|
24
|
+
|
25
|
+
if File.exists?(descriptions_file)
|
26
|
+
descriptions = Nokogiri::XML(File.read(descriptions_file)).root
|
27
|
+
added_resource_descriptions = {}
|
28
|
+
descriptions.xpath('ext_description').each do |description|
|
29
|
+
# Add base resource from linked path if exists, eg "language_schema.language.wr:WR1" -> "language_schema"
|
30
|
+
base_linked = description['linkend'].to_s.split('.').first
|
31
|
+
if added_resource_descriptions[base_linked].nil?
|
32
|
+
base_reource_doc_dir = resource_docs_cache[description['linkend'].to_s.split('.').first]
|
33
|
+
if base_reource_doc_dir
|
34
|
+
output_express << convert_from_resource_file(base_reource_doc_dir, stepmod_dir, base_linked, descriptions_file)
|
35
|
+
end
|
36
|
+
added_resource_descriptions[base_linked] = true
|
37
|
+
end
|
38
|
+
resource_docs_dir = resource_docs_cache[description['linkend']]
|
39
|
+
# Convert content description
|
40
|
+
# when a schema description is available from resource.xml and also descriptions.xml, the description from resource.xml is only used.
|
41
|
+
# https://github.com/metanorma/annotated-express/issues/32#issuecomment-792609078
|
42
|
+
if description.text.strip.length.positive? && resource_docs_dir.nil?
|
43
|
+
output_express << convert_from_description_text(descriptions_file, description)
|
44
|
+
end
|
45
|
+
# Add converted description from exact linked path
|
46
|
+
if resource_docs_dir && added_resource_descriptions[description['linkend']].nil?
|
47
|
+
output_express << convert_from_resource_file(resource_docs_dir, stepmod_dir, description['linkend'], descriptions_file)
|
48
|
+
added_resource_descriptions[description['linkend']] = true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
output_express
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def convert_from_description_text(descriptions_file, description)
|
59
|
+
Dir.chdir(File.dirname(descriptions_file)) do
|
60
|
+
wrapper = "<ext_descriptions>#{description.to_s}</ext_descriptions>"
|
61
|
+
"\n" + Stepmod::Utils::SmrlDescriptionConverter.convert(wrapper)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def convert_from_resource_file(resource_docs_dir, stepmod_dir, linked, descriptions_file)
|
66
|
+
resource_docs_file = File.join(stepmod_dir, 'data/resource_docs', resource_docs_dir, 'resource.xml')
|
67
|
+
puts(resource_docs_file)
|
68
|
+
resource_docs = Nokogiri::XML(File.read(resource_docs_file)).root
|
69
|
+
schema = resource_docs.xpath("schema[@name='#{linked}']")
|
70
|
+
|
71
|
+
Dir.chdir(File.dirname(descriptions_file)) do
|
72
|
+
wrapper = "<resource>#{schema.to_s}</resource>"
|
73
|
+
"\n" + Stepmod::Utils::SmrlResourceConverter.convert(wrapper)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
= STEPmod CVS to Git import
|
2
|
+
|
3
|
+
== Purpose
|
4
|
+
|
5
|
+
The `cvs/` submodule is a CSV import of STEPmod files from the CVS server hosted at Boost Conseil.
|
6
|
+
|
7
|
+
The goal is to import the CSV-managed files in a way useable via Git, with full history information.
|
8
|
+
|
9
|
+
This guide is used as reference for the usage of `cvs-fast-import`:
|
10
|
+
https://oitofelix.github.io/article-savannah-cvs-to-git-migration/
|
11
|
+
|
12
|
+
|
13
|
+
== Strategy to import
|
14
|
+
|
15
|
+
Cloning a remote CVS repository while importing is super slow,
|
16
|
+
especially for a large repository like STEPmod.
|
17
|
+
|
18
|
+
We have tested and settled on these steps:
|
19
|
+
|
20
|
+
. Maintain a local `rsync` copy of the CVS repository.
|
21
|
+
. Resolve all names from the CVS repository (CVS only stores UNIX usernames, in Git are names and emails) using `cvs-fast-import`.
|
22
|
+
. Run `cvs-fast-import` to import the CVS repository into the `iso-10303-stepmod-cvs` Git repo.
|
23
|
+
|
24
|
+
|
25
|
+
== Creating the `rsync` clone of the CVS repository
|
26
|
+
|
27
|
+
[source,sh]
|
28
|
+
----
|
29
|
+
rsync -avrPz -e ssh ronald@cvs.boost-lab.net:/stepmod/ stepmod-rsync/
|
30
|
+
----
|
31
|
+
|
32
|
+
|
33
|
+
== Install cvs-fast-export
|
34
|
+
|
35
|
+
`cvs-fast-export` only works on Linux.
|
36
|
+
Run it on Ubuntu with the `rsync`'ed CVS directory.
|
37
|
+
|
38
|
+
Install:
|
39
|
+
[source,sh]
|
40
|
+
----
|
41
|
+
$ apt-get -y install cvs-fast-export
|
42
|
+
----
|
43
|
+
|
44
|
+
== Getting all users for email mapping
|
45
|
+
|
46
|
+
Find all authors in the CVS repository using `cvs-fast-export -a`.
|
47
|
+
It is much faster than using the equivalent CVS command to list all authors.
|
48
|
+
|
49
|
+
[source,sh]
|
50
|
+
----
|
51
|
+
$ find stepmod-rsync -type f | cvs-fast-export -a
|
52
|
+
----
|
53
|
+
|
54
|
+
|
55
|
+
== Create fast-import file for Git
|
56
|
+
|
57
|
+
After all authors are mapped, run `cvs-fast-export` to create
|
58
|
+
the import file.
|
59
|
+
|
60
|
+
[source,sh]
|
61
|
+
----
|
62
|
+
$ find stepmod-rsync -type f | cvs-fast-export -A author-map.txt > fast-import-file
|
63
|
+
----
|
64
|
+
|
65
|
+
== Perform the Git fast-import
|
66
|
+
|
67
|
+
Once the fast-import file is created, we can perform the Git import.
|
68
|
+
|
69
|
+
[source,sh]
|
70
|
+
----
|
71
|
+
$ cd iso-10303-stepmod-cvs
|
72
|
+
$ git fast-import < ../fast-import-file
|
73
|
+
----
|
74
|
+
|
75
|
+
|
76
|
+
== Upload the new Git repo
|
77
|
+
|
78
|
+
[source,sh]
|
79
|
+
----
|
80
|
+
git push --all && git push --tags
|
81
|
+
----
|
82
|
+
|
83
|
+
|
84
|
+
== DEPRECATED steps using `git cvsimport` (do not use, it won't work)
|
85
|
+
|
86
|
+
=== General
|
87
|
+
|
88
|
+
https://stackoverflow.com/questions/11362676/how-to-import-and-keep-updated-a-cvs-repository-in-git[This StackOverflow post]
|
89
|
+
describes steps for using `git cvsimport`.
|
90
|
+
|
91
|
+
Originally the `git cvsimport` tool was chosen since it is part of
|
92
|
+
`git`. However, it utilizes a deprecated/unmaintained tool called
|
93
|
+
`cvsps`. The latest `cvsps` is version 3, but only version 2 is
|
94
|
+
compatible with `git cvsimport`.
|
95
|
+
|
96
|
+
In addition, the `cvsps` tool is maintained by the maintainer
|
97
|
+
of `cvs-fast-import`, and is no longer updated.
|
98
|
+
Eventually `cvs-fast-import` is used instead.
|
99
|
+
|
100
|
+
WARNING: This command completely fails
|
101
|
+
on this repository because it is too large and complex.
|
102
|
+
|
103
|
+
|
104
|
+
=== Setup
|
105
|
+
|
106
|
+
On macOS, run the following commands to setup for running the import. The `git` executable must be installed.
|
107
|
+
|
108
|
+
Install `cvsps` version 2.
|
109
|
+
|
110
|
+
NOTE: The steps from the StackOverflow of installing `cvsps` no longer work.
|
111
|
+
|
112
|
+
[source,sh]
|
113
|
+
----
|
114
|
+
$ brew tap Frizlab/Perso
|
115
|
+
# ==> Tapping frizlab/perso
|
116
|
+
# Cloning into '/usr/local/Homebrew/Library/Taps/frizlab/homebrew-perso'...
|
117
|
+
# remote: Enumerating objects: 123, done.
|
118
|
+
# remote: Total 123 (delta 0), reused 0 (delta 0), pack-reused 123
|
119
|
+
# Receiving objects: 100% (123/123), 19.08 KiB | 91.00 KiB/s, done.
|
120
|
+
# Resolving deltas: 100% (43/43), done.
|
121
|
+
# Tapped 1 cask and 10 formulae (38 files, 60.5KB).
|
122
|
+
|
123
|
+
$ brew install cvsps@2
|
124
|
+
# ==> Installing cvsps@2 from frizlab/perso
|
125
|
+
# Warning: A newer Command Line Tools release is available.
|
126
|
+
# Update them from Software Update in System Preferences or
|
127
|
+
# https://developer.apple.com/download/more/.
|
128
|
+
# ==> Downloading https://deb.debian.org/debian/pool/main/c/cvsps/cvsps_2.1.orig.tar.gz
|
129
|
+
######################################################################## 100.0%
|
130
|
+
# ==> make all
|
131
|
+
# ==> make install prefix=/usr/local/Cellar/cvsps@2/2.1
|
132
|
+
# 🍺 /usr/local/Cellar/cvsps@2/2.1: 7 files, 124.6KB, built in 6 seconds
|
133
|
+
----
|
134
|
+
|
135
|
+
Verify it is installed:
|
136
|
+
[source,sh]
|
137
|
+
----
|
138
|
+
$ cvsps -v
|
139
|
+
# Can't open CVS/Root
|
140
|
+
# cannot determine CVSROOT
|
141
|
+
----
|
142
|
+
|
143
|
+
////
|
144
|
+
== Checkout the CVS repository
|
145
|
+
|
146
|
+
First set the `CVSROOT` and `CVS_RSH` variables.
|
147
|
+
|
148
|
+
[source,sh]
|
149
|
+
----
|
150
|
+
export CVSROOT=:ext:ronald@cvs.boost-lab.net:/stepmod
|
151
|
+
export CVS_RSH=ssh
|
152
|
+
cvs checkout stepmod
|
153
|
+
# => stepmod/ is created in $PWD
|
154
|
+
----
|
155
|
+
////
|
156
|
+
|
157
|
+
|
158
|
+
=== Run the import
|
159
|
+
|
160
|
+
Run the import from CVS to Git.
|
161
|
+
|
162
|
+
Go to the directory that will carry the target Git repository.
|
163
|
+
|
164
|
+
Run `git cvsimport`.
|
165
|
+
|
166
|
+
[source,sh]
|
167
|
+
----
|
168
|
+
# Importing from remote
|
169
|
+
$ export CVSROOT=:ext:ronald@cvs.boost-lab.net:/stepmod
|
170
|
+
$ export CVS_RSH=ssh
|
171
|
+
$ git cvsimport -C iso-10303-stepmod-cvs -r cvs -k -v -d $CVSROOT stepmod
|
172
|
+
|
173
|
+
# Importing from local rsync'ed copy
|
174
|
+
$ export CVSROOT=$(pwd)/stepmod-rsync
|
175
|
+
$ git cvsimport -C iso-10303-stepmod-cvs -r cvs -k -v -d $CVSROOT stepmod
|
176
|
+
----
|
177
|
+
|
178
|
+
WARNING: TLDR. Technically this should work, but I ran into a `cvsps cannot allocate memory` error with 64GB of RAM, and not even completing the clone after 24 hours. So I gave up and switched to local. And local still takes a long time with tons of error messages. `cvs-fast-import` only takes 5-10 minutes to import.
|
179
|
+
|
180
|
+
|
181
|
+
=== Updating the CVS import
|
182
|
+
|
183
|
+
Run `git cvsimport` to synchronize the Git repo using updated data from CVS.
|
184
|
+
|
185
|
+
[source,sh]
|
186
|
+
----
|
187
|
+
$ git cvsimport
|
188
|
+
----
|
189
|
+
|
190
|
+
|