vcs 0.2.148 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/AUTHORS +6 -0
  2. data/NEWS +9 -0
  3. data/README +82 -0
  4. data/Rakefile +7 -72
  5. data/SPEC.dyn.yml +10 -0
  6. data/SPEC.gemspec +14 -0
  7. data/SPEC.yml +39 -0
  8. data/bin/vcs +18 -16
  9. data/lib/vcs/changelog.rb +164 -0
  10. data/lib/vcs/conflict.rb +21 -0
  11. data/{src → lib/vcs}/cvs.rb +1 -1
  12. data/{src → lib/vcs}/diff.rb +2 -2
  13. data/lib/vcs/diffstat.rb +28 -0
  14. data/lib/vcs/edit.rb +16 -0
  15. data/{src → lib/vcs}/last_changed_date.rb +3 -5
  16. data/{src → lib/vcs}/mail.rb +4 -4
  17. data/lib/vcs/message.rb +79 -0
  18. data/{src → lib/vcs}/mycommit.rb +15 -15
  19. data/{src → lib/vcs}/news.rb +6 -6
  20. data/{src → lib/vcs}/prcs.rb +1 -1
  21. data/{src → lib/vcs}/revision.rb +3 -4
  22. data/lib/vcs/script.rb +19 -0
  23. data/{src → lib/vcs}/status.rb +1 -1
  24. data/{src → lib/vcs}/svn.rb +3 -5
  25. data/lib/vcs/url.rb +16 -0
  26. data/lib/vcs/vcs.rb +279 -0
  27. metadata +52 -150
  28. data/TODO +0 -19
  29. data/doc/jamis.rb +0 -564
  30. data/ruby_ex/abstract.rb +0 -254
  31. data/ruby_ex/abstract_node.rb +0 -85
  32. data/ruby_ex/algorithms/simulated_annealing.rb +0 -140
  33. data/ruby_ex/array_each_pair.rb +0 -18
  34. data/ruby_ex/ask.rb +0 -101
  35. data/ruby_ex/attributed_class.rb +0 -302
  36. data/ruby_ex/cache.rb +0 -373
  37. data/ruby_ex/checkout.rb +0 -12
  38. data/ruby_ex/choose.rb +0 -271
  39. data/ruby_ex/commands.rb +0 -18
  40. data/ruby_ex/commands/command.rb +0 -401
  41. data/ruby_ex/commands/datas.rb +0 -16
  42. data/ruby_ex/commands/datas/data.rb +0 -33
  43. data/ruby_ex/commands/datas/factory.rb +0 -66
  44. data/ruby_ex/commands/factory.rb +0 -66
  45. data/ruby_ex/commands/helpers.rb +0 -67
  46. data/ruby_ex/commands/pipe.rb +0 -64
  47. data/ruby_ex/commands/runners.rb +0 -17
  48. data/ruby_ex/commands/runners/exec.rb +0 -49
  49. data/ruby_ex/commands/runners/fork.rb +0 -97
  50. data/ruby_ex/commands/runners/runner.rb +0 -107
  51. data/ruby_ex/commands/seq.rb +0 -27
  52. data/ruby_ex/config_file.rb +0 -96
  53. data/ruby_ex/const_regexp.rb +0 -59
  54. data/ruby_ex/daemon.rb +0 -134
  55. data/ruby_ex/diff.rb +0 -667
  56. data/ruby_ex/dlogger.rb +0 -62
  57. data/ruby_ex/drb/dispatcher.rb +0 -252
  58. data/ruby_ex/drb/dispatcher_server_test.rb +0 -29
  59. data/ruby_ex/drb/drb_observable.rb +0 -97
  60. data/ruby_ex/drb/drb_observable_pool.rb +0 -27
  61. data/ruby_ex/drb/drb_service.rb +0 -43
  62. data/ruby_ex/drb/drb_undumped_attributes.rb +0 -55
  63. data/ruby_ex/drb/drb_undumped_indexed_object.rb +0 -54
  64. data/ruby_ex/drb/insecure_protected_methods.rb +0 -103
  65. data/ruby_ex/drb/session_client_test.rb +0 -40
  66. data/ruby_ex/drb/session_manager.rb +0 -246
  67. data/ruby_ex/drb/session_server.rb +0 -53
  68. data/ruby_ex/dtime.rb +0 -143
  69. data/ruby_ex/dumpable_proc.rb +0 -63
  70. data/ruby_ex/exception.rb +0 -32
  71. data/ruby_ex/filetype.rb +0 -229
  72. data/ruby_ex/fileutils_ex.rb +0 -44
  73. data/ruby_ex/fold.rb +0 -58
  74. data/ruby_ex/generate_id.rb +0 -44
  75. data/ruby_ex/hookable.rb +0 -262
  76. data/ruby_ex/hooker.rb +0 -54
  77. data/ruby_ex/inactive_timeout.rb +0 -137
  78. data/ruby_ex/indexed_node.rb +0 -66
  79. data/ruby_ex/io_marshal.rb +0 -100
  80. data/ruby_ex/ioo.rb +0 -194
  81. data/ruby_ex/labeled_node.rb +0 -63
  82. data/ruby_ex/logger_observer.rb +0 -23
  83. data/ruby_ex/md5sum.rb +0 -66
  84. data/ruby_ex/mktemp.rb +0 -208
  85. data/ruby_ex/module/attr_once.rb +0 -36
  86. data/ruby_ex/module/autoload_tree.rb +0 -75
  87. data/ruby_ex/module/hierarchy.rb +0 -335
  88. data/ruby_ex/module/instance_method_visibility.rb +0 -73
  89. data/ruby_ex/module_ex.rb +0 -11
  90. data/ruby_ex/node.rb +0 -80
  91. data/ruby_ex/object_monitor.rb +0 -145
  92. data/ruby_ex/object_monitor_activity.rb +0 -33
  93. data/ruby_ex/observable.rb +0 -140
  94. data/ruby_ex/observable_pool.rb +0 -293
  95. data/ruby_ex/orderedhash.rb +0 -252
  96. data/ruby_ex/pathname_ex.rb +0 -152
  97. data/ruby_ex/pp_hierarchy.rb +0 -29
  98. data/ruby_ex/pseudo_cache.rb +0 -190
  99. data/ruby_ex/queue.rb +0 -56
  100. data/ruby_ex/random_generators.rb +0 -25
  101. data/ruby_ex/random_generators/random_generator.rb +0 -31
  102. data/ruby_ex/random_generators/ruby.rb +0 -23
  103. data/ruby_ex/safe_eval.rb +0 -348
  104. data/ruby_ex/sendmail.rb +0 -215
  105. data/ruby_ex/service_manager.rb +0 -121
  106. data/ruby_ex/session/administrable.rb +0 -120
  107. data/ruby_ex/session/client.rb +0 -153
  108. data/ruby_ex/session/const.rb +0 -18
  109. data/ruby_ex/session/dispatcher.rb +0 -184
  110. data/ruby_ex/session/error.rb +0 -21
  111. data/ruby_ex/session/fetchable.rb +0 -57
  112. data/ruby_ex/session/fetcher.rb +0 -62
  113. data/ruby_ex/session/hookable.rb +0 -26
  114. data/ruby_ex/session/profile.rb +0 -110
  115. data/ruby_ex/session/server.rb +0 -582
  116. data/ruby_ex/session/test/administrable_test.rb +0 -337
  117. data/ruby_ex/session/test/basic_test.rb +0 -523
  118. data/ruby_ex/session/test/dispatcher_test.rb +0 -409
  119. data/ruby_ex/session/test/fetchable_test.rb +0 -119
  120. data/ruby_ex/session/test/sub_server_test.rb +0 -188
  121. data/ruby_ex/shuffle.rb +0 -30
  122. data/ruby_ex/spring.rb +0 -136
  123. data/ruby_ex/spring_set.rb +0 -137
  124. data/ruby_ex/string_ex.rb +0 -28
  125. data/ruby_ex/symtbl.rb +0 -106
  126. data/ruby_ex/synflow.rb +0 -474
  127. data/ruby_ex/test/unit/ui/yaml/testrunner.rb +0 -164
  128. data/ruby_ex/thread_mutex.rb +0 -10
  129. data/ruby_ex/timeout_ex.rb +0 -81
  130. data/ruby_ex/top_down.rb +0 -73
  131. data/ruby_ex/trace.rb +0 -26
  132. data/ruby_ex/uri/druby.rb +0 -81
  133. data/ruby_ex/uri/file.rb +0 -65
  134. data/ruby_ex/uri/ftp_ex.rb +0 -37
  135. data/ruby_ex/uri/http_ex.rb +0 -43
  136. data/ruby_ex/uri/ssh.rb +0 -92
  137. data/ruby_ex/uri/svn.rb +0 -118
  138. data/ruby_ex/uri_ex.rb +0 -45
  139. data/ruby_ex/verbose_object.rb +0 -30
  140. data/ruby_ex/version.rb +0 -66
  141. data/ruby_ex/yaml/basenode_ext.rb +0 -63
  142. data/ruby_ex/yaml/chop_header.rb +0 -23
  143. data/ruby_ex/yaml/transform.rb +0 -449
  144. data/ruby_ex/yaml/yregexpath.rb +0 -76
  145. data/src/ask.rb +0 -101
  146. data/src/changelog.rb +0 -117
  147. data/src/conflict.rb +0 -20
  148. data/src/diffstat.rb +0 -42
  149. data/src/message.rb +0 -64
  150. data/src/reply-mail.rb +0 -14
  151. data/src/tools.rb +0 -22
  152. data/src/vcs.rb +0 -176
data/AUTHORS ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ Vcs was written by and with the assistance of:
3
+
4
+ - Nicolas Pouillard <ertai@lrde.epita.fr>:
5
+ - Initial Design
6
+ - Maintenance
data/NEWS ADDED
@@ -0,0 +1,9 @@
1
+ New in 0.3 2005-09-16:
2
+
3
+ * The help command now show all commands including vcs ones.
4
+ * New system to fill values like the subject, the title... of your
5
+ changelog, mails and news which belong to your patches.
6
+ * No more put the subject as an argument of vcs.
7
+ * Improve the command running handling, vcs calls are now full stream based.
8
+ * Add two commands `url' and `script'.
9
+ * Improve the error handling.
data/README ADDED
@@ -0,0 +1,82 @@
1
+ ---
2
+
3
+ - Intro: >
4
+ C'est un wrapper pour les syst�mes de versions comme Svn, Cvs, Prcs,
5
+ Arch... Il permet donc au minimum de faire tout ce que le syst�me
6
+ sous-jacent propose, mais l'avantage est de pouvoir l'�tendre facilement.
7
+
8
+ - HOWTO: Reportez vous au fichier HOWTO pour configurer et installer Vcs.
9
+
10
+ - Description:
11
+
12
+ - Les commandes de base peuvent �tre surcharg�es: >
13
+ par exemple `svn commit' a un comportement non interactif par d�faut.
14
+
15
+ Mais l'on peut tout de m�me appeler le v�ritable `svn commit'.
16
+
17
+ Pour cela il y a une convention: toutes les m�thodes terminant par `_'
18
+ sont directement celles du syst�me.
19
+
20
+ Avec cela on peut v�rifier que l'outil est bien devant le vrai svn:
21
+ svn status_
22
+
23
+ - Quelques fonctionnalit�s:
24
+
25
+ - Un des principaux avantages est la gestion des erreurs: >
26
+
27
+ Par exemple on utilise une commande qui commit puis poste une news.
28
+ Si le commit r�ussit et que la news ne passe pas, il suffit de
29
+ relancer l'envoi de la news: svn news
30
+
31
+ En effet chaque m�thode peut conserver des fichiers, ces fichiers
32
+ commencent par `,'.
33
+
34
+ - Les alias de m�thodes: >
35
+
36
+ Tout comme svn et cvs il existe des raccourcis pour certaines m�thodes
37
+ et bien s�r lorsque l'on surcharge une m�thode, le raccourci pointe
38
+ vers la nouvelle m�thode.
39
+
40
+ - Quelques nouvelles m�thodes:
41
+
42
+ - svn revision: Renvoie le num�ro de r�vision courante
43
+ alias: rev
44
+
45
+ - svn mkchangelog: G�n�re une entr�e de ChangeLog � partir de `status'
46
+ alias: mkcl
47
+
48
+ - svn changelog: Concat�ne la nouvelle entr�e au v�ritable ChangeLog
49
+ alias: cl
50
+
51
+ - svn message: Cr�e le contenu du message du mail ou de la news
52
+ alias: msg
53
+
54
+ - svn mail: Envoie un mail.
55
+
56
+ - svn news: Poste une news.
57
+
58
+ - Plus facile d'�crire des scripts: >
59
+
60
+ Lorsque l'on veut automatiser un traitement fait avec un Rcs,
61
+ il est g�n�ralement plus simple de le faire en script shell
62
+ lorsque cela n'exc�de pas une dixaine de lignes. Apr�s cela certains
63
+ avantages des langages de script �volu�s nous manquent.
64
+ Pourtant certaines choses tr�s faciles peuvent devenir plus lourdes:
65
+ svn commit => system("svn commit")
66
+
67
+ Heureusement avec le mod�le objet d�j� pos� cela devient plus
68
+ raisonnable, comparez par exemple:
69
+
70
+ svn commit => svn.commit
71
+
72
+ svn info | grep '^Revision' | sed s/^Revision: //
73
+
74
+ =>
75
+
76
+ svn.info.readlines.grep(/^Revision/)[0].sub(/^Revision: /, '').to_i
77
+
78
+ - Exemple final: commit complet pour les lrde tools.
79
+
80
+ commande: svn lrdetools_commit 'votre sujet pour la news'
81
+
82
+ ensuite: laissez vous guider.
data/Rakefile CHANGED
@@ -1,73 +1,8 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rake/testtask'
4
- require 'rake/packagetask'
5
- require 'rake/rdoctask'
6
- require 'rake/gempackagetask'
7
- require 'rake/contrib/rubyforgepublisher'
8
-
9
- PKG_VERSION = "0.2.#{`vcs-svn rev`.chomp}"
10
-
11
- PKG_FILES = FileList[*%w"
12
- src/**/*.rb
13
- ruby_ex/**/*.rb
14
- bin/**/*
15
- doc/**/*
16
- [A-Z]*
17
- "].exclude(/\b\.svn\b|\..*\.sw[op]$|~$|README/)
18
-
19
- desc 'Default Task'
20
- task :default => :package
21
-
22
- desc 'Publish to RubyForge'
23
- task :rubyforge do
24
- Rake::RubyForgePublisher.new('vcs', 'ertai').upload
25
- end
26
-
27
-
28
- Rake::RDocTask.new('doc') do |rdoc|
29
- rdoc.title = 'Vcs -- A wrapper over any version control system'
30
- rdoc.template = 'kilmer'
31
- #rdoc.template = 'doc/jamis'
32
- rdoc.options << '--line-numbers' << '--inline-source'
33
- #rdoc.rdoc_files.add('src/vcs.rb', 'src/**/*.rb')
34
- rdoc.rdoc_files.add('src/**/*.rb')
35
- #rdoc.main =
36
- end
37
-
38
-
39
- # The Gem specification
40
- spec = Gem::Specification.new do |s|
41
- s.platform = Gem::Platform::RUBY
42
- s.name = 'vcs'
43
- s.version = PKG_VERSION
44
- s.summary = 'A wrapper over any version control system'
45
- s.description = '
46
- Version control systems (Subversion, CVS, PRCS...), however useful,
47
- are not very extensible: adding new features can be cumbersome, especially
48
- if you want them for different such systems at once.
49
- Vcs provide a simple dynamic hierarchy for Version Control Systems.
50
- '
51
-
52
- s.bindir = 'bin'
53
- s.executables = %w[ vcs vcs-svn vcs-cvs vcs-prcs ]
54
- s.default_executable = 'vcs'
55
- s.files = PKG_FILES.to_a
56
- s.require_path = 'src'
57
- s.autorequire = 'vcs'
58
-
59
- s.has_rdoc = true
60
- s.author = 'Nicolas Pouillard'
61
- s.email = 'ertai@lrde.epita.fr'
62
- s.homepage = 'https://svn.lrde.epita.fr/svn/lrdetools/trunk/vcs/'
63
- s.rubyforge_project = s.name
64
- end
65
-
66
- # Create compressed packages
67
- Rake::GemPackageTask.new(spec) do |p|
68
- p.gem_spec = spec
69
- # p.need_tar = true
70
- # p.need_zip = true
71
- end
72
-
1
+ # Author:: The TTK Team. -*- ruby -*-
2
+ # Copyright:: Copyright (c) 2005 TTK team. All rights reserved.
3
+ # License:: Ruby License
4
+ # Revision:: $Id$
73
5
 
6
+ require 'rubygems'
7
+ require_gem 'core_ex'
8
+ load 'core_ex/rakefile_base.rf'
@@ -0,0 +1,10 @@
1
+ --- !ruby/object:OpenStruct
2
+ table:
3
+ :version_id: ''
4
+ :url: https://svn.lrde.epita.fr/svn/lrdetools/trunk/vcs
5
+ :version: !ruby/object:Version
6
+ build: 0
7
+ major: 0
8
+ minor: 3
9
+ revision: 227
10
+ :date: "Fri, 16 Sep 2005"
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{vcs}
3
+ s.version = "0.3.0"
4
+ s.date = %q{2005-09-16}
5
+ s.summary = %q{A wrapper over any version control system}
6
+ s.email = ["ertai@lrde.epita.fr"]
7
+ s.homepage = %q{http://rubyforge.org/projects/vcs}
8
+ s.rubyforge_project = %q{vcs}
9
+ s.description = %q{Version control systems (Subversion, CVS, PRCS...), however useful, are not very extensible: adding new features can be cumbersome, especially if you want them for different such systems at once. Vcs provide a simple dynamic hierarchy for Version Control Systems.}
10
+ s.authors = ["Nicolas Pouillard"]
11
+ s.files = ["lib/vcs/changelog.rb", "lib/vcs/conflict.rb", "lib/vcs/cvs.rb", "lib/vcs/diff.rb", "lib/vcs/diffstat.rb", "lib/vcs/edit.rb", "lib/vcs/last_changed_date.rb", "lib/vcs/mail.rb", "lib/vcs/message.rb", "lib/vcs/mycommit.rb", "lib/vcs/news.rb", "lib/vcs/prcs.rb", "lib/vcs/revision.rb", "lib/vcs/script.rb", "lib/vcs/status.rb", "lib/vcs/svn.rb", "lib/vcs/url.rb", "lib/vcs/vcs.rb", "bin/vcs", "bin/vcs-cvs", "bin/vcs-prcs", "bin/vcs-svn", "AUTHORS", "HOWTO", "NEWS", "Rakefile", "README", "SPEC.dyn.yml", "SPEC.gemspec", "SPEC.yml"]
12
+ s.executables = ["vcs", "vcs-cvs", "vcs-prcs", "vcs-svn"]
13
+ s.add_dependency(%q<ruby_ex>, ["~> 0.2.0"])
14
+ end
@@ -0,0 +1,39 @@
1
+ ---
2
+ Author: Nicolas Pouillard
3
+ License: GNU General Public License (GPL)
4
+ Revision: '$Id$'
5
+
6
+ name: vcs
7
+
8
+ title: Vcs -- A wrapper over any version control system
9
+ summary: A wrapper over any version control system
10
+ description: |
11
+ Version control systems (Subversion, CVS, PRCS...), however useful, are not
12
+ very extensible: adding new features can be cumbersome, especially if you
13
+ want them for different such systems at once. Vcs provide a simple dynamic
14
+ hierarchy for Version Control Systems.
15
+ homepage: http://rubyforge.org/projects/vcs
16
+
17
+ rdoc_dir: doc/html
18
+ tags_url: https://svn.lrde.epita.fr/svn/lrdetools/tags
19
+
20
+ commit_command: ltci
21
+ commit_dir: ..
22
+
23
+ rdoc_files: !filelist
24
+ - README
25
+ - AUTHORS
26
+ - lib/vcs/**/*.rb
27
+
28
+ pkg_files: !filelist
29
+ - lib/vcs/**/*.rb
30
+ - bin/**/*
31
+ - '[A-Z]*'
32
+
33
+ executables: [ vcs, vcs-svn, vcs-cvs, vcs-prcs ]
34
+
35
+ dependencies:
36
+ ruby_ex: [~> 0.2.0, 6087/ruby_ex-0.2.0.tar.gz]
37
+
38
+ root_test_suite: test/vcs-check.yml
39
+ ttk_version: ~> 0.3.0
data/bin/vcs CHANGED
@@ -16,13 +16,11 @@ require 'logger'
16
16
  require 'optparse'
17
17
  require 'set'
18
18
 
19
- VCS_VERSION = '0.2.148'
19
+ VCS_VERSION = '0.3.0'
20
20
  VCS_PATH = Pathname.new(__FILE__).expand_path
21
21
  VCS_DIR, VCS = VCS_PATH.split
22
- SRC = VCS_DIR + '..' + 'src'
23
- RUBY_EX = VCS_DIR + '..' + 'ruby_ex'
24
- $: << SRC.to_s
25
- $: << RUBY_EX.to_s
22
+ LIB = VCS_DIR + '..' + 'lib'
23
+ $: << LIB.to_s
26
24
 
27
25
  dir = Pathname.pwd
28
26
  while not dir.root? and not (vcs_dir = dir + 'vcs').exist?
@@ -41,14 +39,14 @@ def LOG.format_message(severity, timestamp, msg, progname)
41
39
  "#{VCS}: #{progname}#{severity.downcase}: #{msg}\n"
42
40
  end
43
41
 
44
- Pathname.glob("{#{SRC}/**,#{vcs_dir}}/*.rb") do |file|
42
+ Pathname.glob("{#{LIB}/**,#{vcs_dir}}/*.rb") do |file|
45
43
  LOG.debug { file.basename.to_s }
46
44
  begin
47
- require file.basename.to_s
48
- rescue LoadError => ex
45
+ require "vcs/#{file.basename}"
46
+ rescue LoadError
49
47
  begin
50
48
  require file.to_s
51
- rescue
49
+ rescue LoadError => ex
52
50
  raise ex
53
51
  end
54
52
  end
@@ -81,13 +79,13 @@ OPTS = OptionParser.new do |opts|
81
79
  exit
82
80
  end
83
81
 
84
- opts.on('--mk-alias', 'Use this command like that `vcs --mk-alias`') do
82
+ opts.on('--mk-alias', 'Put the result of this command in your .zshrc or .bashrc') do
85
83
  ALL_VCS_NAMES.each do |n|
86
84
  n = n.to_s.downcase
87
85
  if VCS_PATH.executable?
88
- puts "alias #{n}=#{VCS_PATH}-#{n}"
86
+ puts "alias #{n}=#{VCS_PATH}-#{n} ;"
89
87
  else
90
- puts "alias #{n}=vcs-#{n}"
88
+ puts "alias #{n}=vcs-#{n} ;"
91
89
  end
92
90
  end
93
91
  exit
@@ -95,17 +93,18 @@ OPTS = OptionParser.new do |opts|
95
93
 
96
94
  opts.on('-C', '--[no-]check', 'Check your vcs configuration') do |check|
97
95
  if check
98
- Vcs.new('').call_conf_checkers
96
+ Vcs.new('vcs').call_conf_checkers
99
97
  exit
100
98
  end
101
99
  end
102
100
 
103
- opts.on('-d', '--debug LEVEL', Integer, 'Set debug level') do |anInteger|
104
- $debug = anInteger
101
+ opts.on('-d', '--debug LEVEL', 'Set debug level') do |severity|
102
+ LOG.level = Logger.const_get(severity.upcase)
105
103
  end
106
104
 
107
105
  opts.on_tail('-h', '--help', 'Show this message') do |test|
108
106
  STDERR.puts OPTS
107
+ STDERR.puts "\n\nReport bugs to <ertai@lrde.epita.fr>."
109
108
  exit
110
109
  end
111
110
 
@@ -116,6 +115,7 @@ OPTS = OptionParser.new do |opts|
116
115
 
117
116
  end
118
117
 
118
+ ENV['LC_ALL'] = 'C'
119
119
  if ENV.has_key? 'FULLNAME'
120
120
  FULLNAME = ENV['FULLNAME']
121
121
  else
@@ -125,7 +125,9 @@ else
125
125
  end
126
126
  env = %w[ EMAIL FULLNAME EDITOR PAGER ]
127
127
  if env.all? { |s| ENV[s] }
128
- env.each { |s| Kernel.const_set(s, ENV[s]) }
128
+ EDITOR = ENV['EDITOR'].to_cmd
129
+ PAGER = ENV['PAGER'].to_cmd
130
+ EMAIL = ENV['EMAIL']
129
131
  else
130
132
  env.each { |s| LOG.error "Need #{s} in the environement" unless ENV[s] }
131
133
  exit
@@ -0,0 +1,164 @@
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
+ # Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
3
+ # License:: GNU General Public License (GPL).
4
+ # Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $
5
+
6
+ require 'vcs/vcs'
7
+ require 'vcs/svn'
8
+
9
+ class Svn
10
+
11
+ @@file_st =
12
+ {
13
+ 'A' => 'New',
14
+ 'D' => 'Remove',
15
+ }
16
+ @@file_st.default = ''
17
+
18
+ @@prop_st =
19
+ {
20
+ 'M' => 'Changed property'
21
+ }
22
+
23
+ def mkchangelog_from_status ( *args )
24
+ result = []
25
+ from_status(*args) do |line, file_st, prop_st, copy_st, file|
26
+ next if file_st =~ /[?X]/
27
+ next if file == 'ChangeLog'
28
+ ls = []
29
+ ls << @@file_st[file_st] if @@file_st.has_key? file_st
30
+ ls << @@prop_st[prop_st].downcase if @@prop_st.has_key? prop_st
31
+ result << [file, ls.join(', ')]
32
+ end
33
+ raise Failure, 'No changes, so no ChangeLog entry.' if result.empty?
34
+ result
35
+ end
36
+ private :mkchangelog_from_status
37
+
38
+ end # class Svn
39
+
40
+
41
+ class Vcs
42
+
43
+ class MustBeFilled < Exception
44
+ attr_reader :file
45
+ def initialize ( file )
46
+ @file = file
47
+ super("You must fill this file: `#{file.to_s}'")
48
+ end
49
+ end
50
+
51
+ @@subject_format = '<%= rev %>: <%= title %>'
52
+
53
+ def mkchangelog! ( *args )
54
+ error_handling :changelog_failed
55
+
56
+ unless CL.exist?
57
+ raise Failure, "No `#{CL}', you are probably not in a valid directory."
58
+ end
59
+
60
+ cl = ADD_CL
61
+
62
+ # Already filled if ,ChangeLog.add exists and not begin by ---
63
+ if cl.exist?
64
+ raise MustBeFilled, cl if cl.read =~ /\A---/
65
+ require 'erb'
66
+ ls = []
67
+ YAML.each_document("--- |\n" + cl.read) { |x| (ls.size == 2)? break : ls << x }
68
+ title_subject, input = ls
69
+ header = { 'title' => title_subject[/^title: (.*)$/, 1],
70
+ 'subject' => title_subject[/^subject: (.*)$/, 1] }
71
+ rev = revision.read.to_i + 1
72
+ header.merge!('rev' => rev, 'revision' => rev)
73
+ raise "no title: reopen #{ADD_CL}" if header['title'].nil?
74
+ header['title'].sub!(/\.$/, '')
75
+ b = getBinding(header)
76
+ header = ERB.new(header.to_yaml, $SAFE, '<-%->', '$erbout_').result(b)
77
+ META.open('w') { |f| f.puts header }
78
+ output = ERB.new(input, $SAFE, '<-%->', '$erbout_').result(b)
79
+ return output
80
+ end
81
+
82
+ cl_add = mkchangelog_from_status(*args)
83
+ LOG.info "Creating a new `#{cl}' file"
84
+ cl.open('w') do |f|
85
+ head = Time.now.strftime("%Y-%m-%d #{FULL_EMAIL}")
86
+ f.puts "
87
+ |--- | ########## Fill this file correctly and remove this line ########## | ---
88
+ |title:
89
+ |subject: #{@@subject_format}.
90
+ |
91
+ |--- | ###################### Your ChangeLog entrie ###################### | ---
92
+ |#{head}
93
+ |
94
+ |\t<%= title %>.
95
+ |
96
+ |".head_cut!
97
+
98
+ cl_add.each do |file, str|
99
+ f.puts "\t* #{file}: #{str}."
100
+ end
101
+
102
+ f.puts "|
103
+ |--- | ########### This line, and those below, will be ignored ########### | ---
104
+ |Instructions:
105
+ |\t* The first line must be removed when this file is filled.
106
+ |\t* After you must specify a title, for the news/mail subject.
107
+ |\t* The line containing <%= title %> will be replaced by your title,
108
+ |\t <%= subject %> by the subject line, <%= rev %> by the revision...
109
+ |\t* Everywhere in the document you can get/compute some values with
110
+ |\t these tags <%= aRubyExpression %> even some vcs specific call.
111
+ |\t For example <%= status.read %> will include the `svn status' output.
112
+ |
113
+ |".head_cut!
114
+ with(f).diff!(*args)
115
+ end
116
+
117
+ raise MustBeFilled, cl
118
+ end
119
+
120
+ def concat_changelog! ( *args )
121
+ error_handling :changelog_failed
122
+
123
+ if cl_entry = mkchangelog(*args)
124
+
125
+ unless TMP_CL.exist?
126
+ LOG.info "Moving `#{CL}' to `#{TMP_CL}' ..."
127
+ CL.rename(TMP_CL)
128
+ end
129
+
130
+ CL.open('w') do |file|
131
+ LOG.info "Prepending `#{ADD_CL}' to `#{CL}' ..."
132
+ file.print cl_entry
133
+ file.puts
134
+ file.print TMP_CL.read
135
+ end
136
+
137
+ return cl_entry
138
+
139
+ end
140
+ end
141
+
142
+ def changelog_failed
143
+ if TMP_CL.exist?
144
+ LOG.info "Restoring `#{CL}' from `#{TMP_CL}' ..."
145
+ TMP_CL.rename(CL)
146
+ end
147
+ LOG.info "#{ADD_CL}: Contains your ChangeLog entry" if ADD_CL.exist?
148
+ end
149
+
150
+ def getBinding ( header )
151
+ code = []
152
+ header.each do |k, v|
153
+ code << "#{k} = #{v.inspect}"
154
+ end
155
+ code << 'binding'
156
+ eval(code.join('; '))
157
+ end
158
+ protected :getBinding
159
+
160
+ alias_command :mkcl, :mkchangelog
161
+ alias_command :ctcl, :concat_changelog
162
+
163
+ end # class Vcs
164
+