amp 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. data/.gitignore +12 -0
  2. data/.hgignore +3 -0
  3. data/AUTHORS +1 -1
  4. data/Manifest.txt +99 -38
  5. data/README.md +3 -3
  6. data/Rakefile +53 -18
  7. data/SCHEDULE.markdown +5 -1
  8. data/TODO.markdown +120 -149
  9. data/ampfile.rb +3 -1
  10. data/bin/amp +4 -1
  11. data/ext/amp/bz2/extconf.rb +1 -1
  12. data/ext/amp/mercurial_patch/extconf.rb +1 -1
  13. data/ext/amp/mercurial_patch/mpatch.c +4 -3
  14. data/ext/amp/priority_queue/extconf.rb +1 -1
  15. data/ext/amp/support/extconf.rb +1 -1
  16. data/ext/amp/support/support.c +1 -1
  17. data/lib/amp.rb +125 -67
  18. data/lib/amp/commands/command.rb +12 -10
  19. data/lib/amp/commands/command_support.rb +8 -1
  20. data/lib/amp/commands/commands/help.rb +2 -20
  21. data/lib/amp/commands/commands/init.rb +14 -2
  22. data/lib/amp/commands/commands/templates.rb +6 -4
  23. data/lib/amp/commands/commands/version.rb +15 -1
  24. data/lib/amp/commands/commands/workflow.rb +3 -3
  25. data/lib/amp/commands/commands/workflows/git/add.rb +3 -3
  26. data/lib/amp/commands/commands/workflows/git/copy.rb +1 -1
  27. data/lib/amp/commands/commands/workflows/git/rm.rb +4 -2
  28. data/lib/amp/commands/commands/workflows/hg/add.rb +1 -1
  29. data/lib/amp/commands/commands/workflows/hg/addremove.rb +2 -2
  30. data/lib/amp/commands/commands/workflows/hg/annotate.rb +8 -2
  31. data/lib/amp/commands/commands/workflows/hg/bisect.rb +253 -0
  32. data/lib/amp/commands/commands/workflows/hg/branch.rb +1 -1
  33. data/lib/amp/commands/commands/workflows/hg/branches.rb +3 -3
  34. data/lib/amp/commands/commands/workflows/hg/bundle.rb +3 -3
  35. data/lib/amp/commands/commands/workflows/hg/clone.rb +4 -5
  36. data/lib/amp/commands/commands/workflows/hg/commit.rb +37 -1
  37. data/lib/amp/commands/commands/workflows/hg/copy.rb +2 -1
  38. data/lib/amp/commands/commands/workflows/hg/debug/index.rb +1 -1
  39. data/lib/amp/commands/commands/workflows/hg/diff.rb +3 -8
  40. data/lib/amp/commands/commands/workflows/hg/forget.rb +5 -4
  41. data/lib/amp/commands/commands/workflows/hg/identify.rb +6 -6
  42. data/lib/amp/commands/commands/workflows/hg/import.rb +1 -1
  43. data/lib/amp/commands/commands/workflows/hg/incoming.rb +2 -2
  44. data/lib/amp/commands/commands/workflows/hg/log.rb +5 -4
  45. data/lib/amp/commands/commands/workflows/hg/merge.rb +1 -1
  46. data/lib/amp/commands/commands/workflows/hg/move.rb +5 -3
  47. data/lib/amp/commands/commands/workflows/hg/outgoing.rb +1 -1
  48. data/lib/amp/commands/commands/workflows/hg/push.rb +6 -7
  49. data/lib/amp/commands/commands/workflows/hg/remove.rb +2 -2
  50. data/lib/amp/commands/commands/workflows/hg/resolve.rb +6 -23
  51. data/lib/amp/commands/commands/workflows/hg/root.rb +1 -2
  52. data/lib/amp/commands/commands/workflows/hg/status.rb +21 -12
  53. data/lib/amp/commands/commands/workflows/hg/tag.rb +2 -2
  54. data/lib/amp/commands/commands/workflows/hg/untrack.rb +12 -0
  55. data/lib/amp/commands/commands/workflows/hg/verify.rb +13 -3
  56. data/lib/amp/commands/commands/workflows/hg/what_changed.rb +18 -0
  57. data/lib/amp/commands/dispatch.rb +12 -13
  58. data/lib/amp/dependencies/amp_support.rb +1 -1
  59. data/lib/amp/dependencies/amp_support/ruby_amp_support.rb +1 -0
  60. data/lib/amp/dependencies/maruku.rb +136 -0
  61. data/lib/amp/dependencies/maruku/attributes.rb +227 -0
  62. data/lib/amp/dependencies/maruku/defaults.rb +71 -0
  63. data/lib/amp/dependencies/maruku/errors_management.rb +92 -0
  64. data/lib/amp/dependencies/maruku/helpers.rb +260 -0
  65. data/lib/amp/dependencies/maruku/input/charsource.rb +326 -0
  66. data/lib/amp/dependencies/maruku/input/extensions.rb +69 -0
  67. data/lib/amp/dependencies/maruku/input/html_helper.rb +189 -0
  68. data/lib/amp/dependencies/maruku/input/linesource.rb +111 -0
  69. data/lib/amp/dependencies/maruku/input/parse_block.rb +615 -0
  70. data/lib/amp/dependencies/maruku/input/parse_doc.rb +234 -0
  71. data/lib/amp/dependencies/maruku/input/parse_span_better.rb +746 -0
  72. data/lib/amp/dependencies/maruku/input/rubypants.rb +225 -0
  73. data/lib/amp/dependencies/maruku/input/type_detection.rb +147 -0
  74. data/lib/amp/dependencies/maruku/input_textile2/t2_parser.rb +163 -0
  75. data/lib/amp/dependencies/maruku/maruku.rb +33 -0
  76. data/lib/amp/dependencies/maruku/output/to_ansi.rb +223 -0
  77. data/lib/amp/dependencies/maruku/output/to_html.rb +991 -0
  78. data/lib/amp/dependencies/maruku/output/to_markdown.rb +164 -0
  79. data/lib/amp/dependencies/maruku/output/to_s.rb +56 -0
  80. data/lib/amp/dependencies/maruku/string_utils.rb +191 -0
  81. data/lib/amp/dependencies/maruku/structures.rb +167 -0
  82. data/lib/amp/dependencies/maruku/structures_inspect.rb +87 -0
  83. data/lib/amp/dependencies/maruku/structures_iterators.rb +61 -0
  84. data/lib/amp/dependencies/maruku/textile2.rb +1 -0
  85. data/lib/amp/dependencies/maruku/toc.rb +199 -0
  86. data/lib/amp/dependencies/maruku/usage/example1.rb +33 -0
  87. data/lib/amp/dependencies/maruku/version.rb +40 -0
  88. data/lib/amp/dependencies/priority_queue.rb +2 -1
  89. data/lib/amp/dependencies/python_config.rb +2 -1
  90. data/lib/amp/graphs/ancestor.rb +2 -1
  91. data/lib/amp/graphs/copies.rb +236 -233
  92. data/lib/amp/help/entries/__default__.erb +31 -0
  93. data/lib/amp/help/entries/commands.erb +6 -0
  94. data/lib/amp/help/entries/mdtest.md +35 -0
  95. data/lib/amp/help/entries/silly +3 -0
  96. data/lib/amp/help/help.rb +288 -0
  97. data/lib/amp/profiling_hacks.rb +5 -3
  98. data/lib/amp/repository/abstract/abstract_changeset.rb +97 -0
  99. data/lib/amp/repository/abstract/abstract_local_repo.rb +181 -0
  100. data/lib/amp/repository/abstract/abstract_staging_area.rb +180 -0
  101. data/lib/amp/repository/abstract/abstract_versioned_file.rb +100 -0
  102. data/lib/amp/repository/abstract/common_methods/changeset.rb +75 -0
  103. data/lib/amp/repository/abstract/common_methods/local_repo.rb +277 -0
  104. data/lib/amp/repository/abstract/common_methods/staging_area.rb +233 -0
  105. data/lib/amp/repository/abstract/common_methods/versioned_file.rb +71 -0
  106. data/lib/amp/repository/generic_repo_picker.rb +78 -0
  107. data/lib/amp/repository/git/repo_format/changeset.rb +336 -0
  108. data/lib/amp/repository/git/repo_format/staging_area.rb +192 -0
  109. data/lib/amp/repository/git/repo_format/versioned_file.rb +119 -0
  110. data/lib/amp/repository/git/repositories/local_repository.rb +164 -0
  111. data/lib/amp/repository/git/repository.rb +41 -0
  112. data/lib/amp/repository/mercurial/encoding/mercurial_diff.rb +382 -0
  113. data/lib/amp/repository/mercurial/encoding/mercurial_patch.rb +1 -0
  114. data/lib/amp/repository/mercurial/encoding/patch.rb +294 -0
  115. data/lib/amp/repository/mercurial/encoding/pure_ruby/ruby_mercurial_patch.rb +124 -0
  116. data/lib/amp/repository/mercurial/merging/merge_ui.rb +327 -0
  117. data/lib/amp/repository/mercurial/merging/simple_merge.rb +452 -0
  118. data/lib/amp/repository/mercurial/repo_format/branch_manager.rb +266 -0
  119. data/lib/amp/repository/mercurial/repo_format/changeset.rb +768 -0
  120. data/lib/amp/repository/mercurial/repo_format/dir_state.rb +716 -0
  121. data/lib/amp/repository/mercurial/repo_format/journal.rb +218 -0
  122. data/lib/amp/repository/mercurial/repo_format/lock.rb +210 -0
  123. data/lib/amp/repository/mercurial/repo_format/merge_state.rb +228 -0
  124. data/lib/amp/repository/mercurial/repo_format/staging_area.rb +367 -0
  125. data/lib/amp/repository/mercurial/repo_format/store.rb +487 -0
  126. data/lib/amp/repository/mercurial/repo_format/tag_manager.rb +322 -0
  127. data/lib/amp/repository/mercurial/repo_format/updatable.rb +543 -0
  128. data/lib/amp/repository/mercurial/repo_format/updater.rb +848 -0
  129. data/lib/amp/repository/mercurial/repo_format/verification.rb +433 -0
  130. data/lib/amp/repository/mercurial/repositories/bundle_repository.rb +216 -0
  131. data/lib/amp/repository/mercurial/repositories/http_repository.rb +386 -0
  132. data/lib/amp/repository/mercurial/repositories/local_repository.rb +2034 -0
  133. data/lib/amp/repository/mercurial/repository.rb +119 -0
  134. data/lib/amp/repository/mercurial/revlogs/bundle_revlogs.rb +249 -0
  135. data/lib/amp/repository/mercurial/revlogs/changegroup.rb +217 -0
  136. data/lib/amp/repository/mercurial/revlogs/changelog.rb +339 -0
  137. data/lib/amp/repository/mercurial/revlogs/file_log.rb +152 -0
  138. data/lib/amp/repository/mercurial/revlogs/index.rb +500 -0
  139. data/lib/amp/repository/mercurial/revlogs/manifest.rb +201 -0
  140. data/lib/amp/repository/mercurial/revlogs/node.rb +20 -0
  141. data/lib/amp/repository/mercurial/revlogs/revlog.rb +1026 -0
  142. data/lib/amp/repository/mercurial/revlogs/revlog_support.rb +129 -0
  143. data/lib/amp/repository/mercurial/revlogs/versioned_file.rb +597 -0
  144. data/lib/amp/repository/repository.rb +11 -88
  145. data/lib/amp/server/extension/amp_extension.rb +3 -3
  146. data/lib/amp/server/fancy_http_server.rb +1 -1
  147. data/lib/amp/server/fancy_views/_browser.haml +1 -1
  148. data/lib/amp/server/fancy_views/_diff_file.haml +1 -8
  149. data/lib/amp/server/fancy_views/changeset.haml +2 -2
  150. data/lib/amp/server/fancy_views/file.haml +1 -1
  151. data/lib/amp/server/fancy_views/file_diff.haml +1 -1
  152. data/lib/amp/support/amp_ui.rb +13 -29
  153. data/lib/amp/support/generator.rb +1 -1
  154. data/lib/amp/support/loaders.rb +1 -2
  155. data/lib/amp/support/logger.rb +10 -16
  156. data/lib/amp/support/match.rb +18 -4
  157. data/lib/amp/support/mercurial/ignore.rb +151 -0
  158. data/lib/amp/support/openers.rb +8 -3
  159. data/lib/amp/support/support.rb +91 -46
  160. data/lib/amp/templates/{blank.commit.erb → mercurial/blank.commit.erb} +0 -0
  161. data/lib/amp/templates/{blank.log.erb → mercurial/blank.log.erb} +0 -0
  162. data/lib/amp/templates/{default.commit.erb → mercurial/default.commit.erb} +0 -0
  163. data/lib/amp/templates/{default.log.erb → mercurial/default.log.erb} +0 -0
  164. data/lib/amp/templates/template.rb +18 -18
  165. data/man/amp.1 +51 -0
  166. data/site/src/about/commands.haml +1 -1
  167. data/site/src/css/amp.css +1 -1
  168. data/site/src/index.haml +3 -3
  169. data/tasks/man.rake +39 -0
  170. data/tasks/stats.rake +1 -10
  171. data/tasks/yard.rake +1 -50
  172. data/test/dirstate_tests/test_dir_state.rb +10 -8
  173. data/test/functional_tests/annotate.out +31 -0
  174. data/test/functional_tests/test_functional.rb +155 -63
  175. data/test/localrepo_tests/ampfile.rb +12 -0
  176. data/test/localrepo_tests/test_local_repo.rb +56 -57
  177. data/test/manifest_tests/test_manifest.rb +3 -5
  178. data/test/merge_tests/test_merge.rb +3 -3
  179. data/test/revlog_tests/test_revlog.rb +14 -6
  180. data/test/store_tests/test_fncache_store.rb +19 -19
  181. data/test/test_19_compatibility.rb +46 -0
  182. data/test/test_base85.rb +2 -2
  183. data/test/test_bdiff.rb +2 -2
  184. data/test/test_changegroup.rb +59 -0
  185. data/test/test_commands.rb +2 -2
  186. data/test/test_difflib.rb +2 -2
  187. data/test/test_generator.rb +34 -0
  188. data/test/test_ignore.rb +203 -0
  189. data/test/test_journal.rb +18 -13
  190. data/test/test_match.rb +2 -2
  191. data/test/test_mdiff.rb +3 -3
  192. data/test/test_mpatch.rb +3 -3
  193. data/test/test_multi_io.rb +40 -0
  194. data/test/test_support.rb +18 -2
  195. data/test/test_templates.rb +38 -0
  196. data/test/test_ui.rb +79 -0
  197. data/test/testutilities.rb +56 -0
  198. metadata +168 -49
  199. data/ext/amp/bz2/mkmf.log +0 -38
  200. data/lib/amp/encoding/mercurial_diff.rb +0 -378
  201. data/lib/amp/encoding/mercurial_patch.rb +0 -1
  202. data/lib/amp/encoding/patch.rb +0 -292
  203. data/lib/amp/encoding/pure_ruby/ruby_mercurial_patch.rb +0 -123
  204. data/lib/amp/merges/merge_state.rb +0 -164
  205. data/lib/amp/merges/merge_ui.rb +0 -322
  206. data/lib/amp/merges/simple_merge.rb +0 -450
  207. data/lib/amp/repository/branch_manager.rb +0 -234
  208. data/lib/amp/repository/dir_state.rb +0 -950
  209. data/lib/amp/repository/journal.rb +0 -203
  210. data/lib/amp/repository/lock.rb +0 -207
  211. data/lib/amp/repository/repositories/bundle_repository.rb +0 -214
  212. data/lib/amp/repository/repositories/http_repository.rb +0 -377
  213. data/lib/amp/repository/repositories/local_repository.rb +0 -2661
  214. data/lib/amp/repository/store.rb +0 -485
  215. data/lib/amp/repository/tag_manager.rb +0 -319
  216. data/lib/amp/repository/updatable.rb +0 -532
  217. data/lib/amp/repository/verification.rb +0 -431
  218. data/lib/amp/repository/versioned_file.rb +0 -475
  219. data/lib/amp/revlogs/bundle_revlogs.rb +0 -246
  220. data/lib/amp/revlogs/changegroup.rb +0 -217
  221. data/lib/amp/revlogs/changelog.rb +0 -338
  222. data/lib/amp/revlogs/changeset.rb +0 -521
  223. data/lib/amp/revlogs/file_log.rb +0 -165
  224. data/lib/amp/revlogs/index.rb +0 -493
  225. data/lib/amp/revlogs/manifest.rb +0 -195
  226. data/lib/amp/revlogs/node.rb +0 -18
  227. data/lib/amp/revlogs/revlog.rb +0 -1045
  228. data/lib/amp/revlogs/revlog_support.rb +0 -126
  229. data/lib/amp/support/ignore.rb +0 -144
  230. data/site/Rakefile +0 -38
  231. data/test/test_amp.rb +0 -9
  232. data/test/test_helper.rb +0 -15
@@ -19,7 +19,7 @@ module Amp
19
19
  def initialize(base)
20
20
  @root = File.expand_path base
21
21
  @create_mode = nil
22
- @default = nil
22
+ @default = :open_hg
23
23
  end
24
24
 
25
25
  ##
@@ -27,10 +27,15 @@ module Amp
27
27
  #
28
28
  # @return path to the opener's root, as an absolute path.
29
29
  def path
30
- if @default == :open_file
30
+ case @default
31
+ when :open_file
31
32
  "#{root}/"
32
- else
33
+ when :open_hg
33
34
  "#{root}/.hg/"
35
+ when :open_git
36
+ "#{root}/.git"
37
+ else
38
+ abort "Unknown opener format #{@default.inspect}"
34
39
  end
35
40
  end
36
41
 
@@ -1,7 +1,6 @@
1
-
2
1
  require 'digest'
3
2
 
4
- if RUBY_VERSION < "1.9"
3
+ if RUBY_VERSION < "1.9" || RUBY_VERSION >= "1.9.2"
5
4
  require 'ftools'
6
5
 
7
6
  autoload :Etc, 'etc'
@@ -9,6 +8,7 @@ if RUBY_VERSION < "1.9"
9
8
  autoload :Tempfile, 'tempfile'
10
9
  autoload :Socket, 'socket'
11
10
  autoload :WeakRef, 'weakref'
11
+ autoload :Find, 'find'
12
12
  else
13
13
  require 'fileutils'
14
14
  require 'socket'
@@ -16,6 +16,7 @@ else
16
16
  require 'etc'
17
17
  require 'tempfile'
18
18
  require 'weakref'
19
+ require 'find'
19
20
  end
20
21
  autoload :ERB, 'erb'
21
22
 
@@ -41,12 +42,6 @@ class AbortError < StandardError
41
42
  end
42
43
  end
43
44
 
44
- module Kernel
45
- def abort(str)
46
- AbortError.new str
47
- end
48
- end
49
-
50
45
  class LockError < StandardError
51
46
  attr_reader :errno, :filename, :desc
52
47
  def initialize(errno, strerror, filename, desc)
@@ -187,6 +182,30 @@ class Module
187
182
  end
188
183
  self
189
184
  end
185
+
186
+ ##
187
+ # Creates an opposite method based on a defined method:
188
+ # one that returns true if the base method returns false, and vice-versa.
189
+ #
190
+ # @param [Symbol] new_method The new method to define
191
+ # @param [Symbol] base_method the base method we use to define the opposite
192
+ # method
193
+ def opposite_method(new_method, base_method)
194
+ class_eval <<-EOF
195
+ def #{new_method}(*args, &block)
196
+ not #{base_method}(*args, &block)
197
+ end
198
+ EOF
199
+ end
200
+ end
201
+
202
+ class Object
203
+
204
+ ##
205
+ # Because tap isn't defined in 1.8.6
206
+ def tap
207
+ yield self
208
+ end unless defined?(tap)
190
209
  end
191
210
 
192
211
  module Kernel
@@ -216,23 +235,32 @@ module Kernel
216
235
  #
217
236
  # @yield The block is run, and any exceptions raised print their full backtrace.
218
237
  def full_backtrace_please
219
- message = ["***** Left engine failure *****",
220
- "***** Ejection system error *****",
221
- "***** Vaccuum in booster engine *****"
222
- ][rand(3)]
223
238
  begin
224
239
  yield
225
240
  rescue AbortError => e
226
241
  Amp::UI.say "Operation aborted."
227
242
  raise
228
243
  rescue StandardError => e
244
+ message = ["***** Left engine failure *****",
245
+ "***** Ejection system error *****",
246
+ "***** Vaccuum in booster engine *****"
247
+ ][rand(3)]
229
248
  Amp::UI.say message
230
249
  Amp::UI.say e.to_s
231
250
  e.backtrace.each {|err| Amp::UI.say "\tfrom #{err}" }
232
- exit
251
+ return
233
252
  end
234
253
  end
235
254
 
255
+ def amp_pause
256
+ Amp::UI.say "Amp is paused. Type 'go' and hit enter to continue"
257
+ until gets.strip == 'go'
258
+ end
259
+ end
260
+
261
+ def abort(str)
262
+ AbortError.new str
263
+ end
236
264
  end
237
265
 
238
266
  class Dir
@@ -464,6 +492,7 @@ class File
464
492
  # @param [Boolean] empty whether or not to return an empty string as well
465
493
  # @return [Array] the directories leading up to this path
466
494
  def self.amp_directories_to(path, empty=false)
495
+ path = File.expand_path(path)
467
496
  dirs = path.split('/')[0..-2]
468
497
  ret = []
469
498
 
@@ -548,25 +577,41 @@ class Hash
548
577
  # @param [Object] value (true) the value to assign each key to in the resultant hash
549
578
  # @return [Hash] a hash with keys from +iterable+, all set to +value+
550
579
  def self.with_keys(iterable, value=true)
551
- iterable.inject({}) {|h, k| h.merge!(k => value) }
580
+ # we try to be functional when it doesn't fuck us over
581
+ # here, the list of keys will never be ridiculous
582
+ # so we go fuctional
583
+ iterable.inject({}) {|h, k| h[k] = value; h }
552
584
  end
553
585
 
554
586
  ##
555
587
  # Create a subset of +self+ with keys +keys+.
556
588
  def pick(*keys)
557
- keys.inject({}) {|h, (k, v)| h[k] = v }
589
+ keys.inject({}) {|h, (k, v)| h[k] = v; h }
558
590
  end
559
591
 
592
+ ##
593
+ # Construct a new hash with only the specified +keyz+
594
+ #
595
+ # @return [Hash]
596
+ def only(*keyz)
597
+ keyz.inject({}) {|h, k| h[k] = self[k]; h }
598
+ end
560
599
  end
561
600
 
562
601
  class Array
563
602
 
564
603
  ##
565
- # Sums all the items in the array
604
+ # Sums all the items in the array.
605
+ #
606
+ # From activesupport-2.3.5, activesupport/lib/active_support/core_ext/enumerable.rb, line 57
566
607
  #
567
608
  # @return [Array] the items summed
568
- def sum
569
- inject(0) {|sum, x| sum + x }
609
+ def sum(identity=0, &block)
610
+ if block_given?
611
+ map(&block).sum(identity)
612
+ else
613
+ inject { |sum, element| sum + element } || identity
614
+ end
570
615
  end
571
616
 
572
617
  ##
@@ -587,7 +632,7 @@ class Array
587
632
  end
588
633
 
589
634
  def to_hash
590
- inject({}) {|h, (k, v)| h.merge k => v }
635
+ inject({}) {|h, (k, v)| h[k] = v; h }
591
636
  end
592
637
 
593
638
  def short_hex
@@ -627,18 +672,6 @@ class Integer
627
672
  alias_method :gigabyte, :gigabytes
628
673
  alias_method :gb, :gigabytes
629
674
 
630
-
631
- ##
632
- # Forces this integer to be negative if it's supposed to be!
633
- #
634
- # @param [Fixnum] bits the number of bits to use - signed shorts are different from
635
- # signed longs!
636
- def to_signed(bits)
637
- return to_signed_16 if bits == 16
638
- return to_signed_32 if bits == 32
639
- raise "Unexpected number of bits: #{bits}"
640
- end
641
-
642
675
  end
643
676
 
644
677
  class String
@@ -648,18 +681,32 @@ class String
648
681
  # @param [String] color_code a TTY color code
649
682
  # @return [String] the string wrapped in non-printing characters to make the text
650
683
  # appear in a given color
651
- def colorize(color_code)
652
- "#{color_code}#{self}\e[0m"
684
+ def colorize(color_code, closing_tag = 39)
685
+ "\e[#{color_code}m#{self}\e[#{closing_tag}m"
686
+ end
687
+
688
+ [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white].tap do |list|
689
+ list.each_with_index do |arg, idx|
690
+ define_method(arg) { colorize(30 + idx, 39) }
691
+ define_method("on_#{arg}") { colorize(40 + idx, 49) }
692
+ end
693
+ define_method :color do |*args|
694
+ result = self
695
+ args.each do |arg|
696
+ if arg.to_s[0,3] == "on_"
697
+ then base = 40; arg = arg.to_s[3..-1].to_sym
698
+ else base = 30
699
+ end
700
+ result = result.colorize(base + list.index(arg), base + 9)
701
+ end
702
+ result
703
+ end
653
704
  end
654
705
 
655
706
  # Returns the string, colored red.
656
- def red; colorize("\e[31m"); end
657
- def green; colorize("\e[32m"); end
658
- def yellow; colorize("\e[33m"); end
659
- def blue; colorize("\e[34m"); end
660
- def magenta; colorize("\e[35m"); end
661
- def cyan; colorize("\e[36m"); end
662
- def white; colorize("\e[37m"); end
707
+ def bold; colorize(1, 22); end
708
+ def underline; colorize(4, 24); end
709
+ def blink; colorize(5, 25); end
663
710
 
664
711
  ##
665
712
  # Returns the path from +root+ to the path represented by the string. Will fail
@@ -677,12 +724,12 @@ class String
677
724
 
678
725
  # Am I equal to the NULL_ID used in revision logs?
679
726
  def null?
680
- self == Amp::RevlogSupport::Node::NULL_ID
727
+ self == Amp::Mercurial::RevlogSupport::Node::NULL_ID
681
728
  end
682
729
 
683
730
  # Am I not equal to the NULL_ID used in revision logs?
684
731
  def not_null?
685
- !(null?)
732
+ !null?
686
733
  end
687
734
 
688
735
  ##
@@ -1081,11 +1128,9 @@ module Amp
1081
1128
  # architecture, and upates the SYSTEM[] hash in the Support module.
1082
1129
  def self.determine_endianness
1083
1130
  num = 0x12345678
1084
- little = '78563412'
1085
- big = '12345678'
1086
1131
  native = [num].pack('l')
1087
- netunpack = native.unpack('N')
1088
- if native == netunpack
1132
+ netunpack = native.unpack('N')[0]
1133
+ if num == netunpack
1089
1134
  SYSTEM[:endian] = :big
1090
1135
  else
1091
1136
  SYSTEM[:endian] = :little
@@ -7,7 +7,7 @@ module Amp
7
7
  # Class representing a template in the amp system
8
8
  class Template
9
9
 
10
- @all_templates = {}
10
+ @all_templates = Hash.new {|h, k| h[k] = {} }
11
11
  class << self
12
12
  attr_accessor :all_templates
13
13
 
@@ -16,9 +16,9 @@ module Amp
16
16
  #
17
17
  # @param [String, Symbol, #to_sym] template the name of the template to retrieve
18
18
  # @return [Template] the template with the given name
19
- def [](template)
19
+ def [](type, template)
20
20
  ensure_templates_loaded
21
- return all_templates[template.to_sym]
21
+ return all_templates[type.to_sym][template.to_sym]
22
22
  end
23
23
 
24
24
  ##
@@ -26,8 +26,8 @@ module Amp
26
26
  #
27
27
  # @param [String, Symbol, #to_sym] name the name of the template. Should be unique.
28
28
  # @param [Template] template the template to register.
29
- def register(name, template)
30
- all_templates[name.to_sym] = template
29
+ def register(type, name, template)
30
+ all_templates[type.to_sym][name.to_sym] = template
31
31
  end
32
32
 
33
33
  ##
@@ -36,9 +36,9 @@ module Amp
36
36
  #
37
37
  # @param [String, Symbol, #to_sym] name the name of the template to remove from
38
38
  # the system.
39
- def unregister(name)
40
- raise ArgumentError.new("Unknown template: #{name}") unless all_templates[name.to_sym]
41
- all_templates.delete name.to_sym
39
+ def unregister(type, name)
40
+ raise ArgumentError.new("Unknown template: #{name}") unless all_templates[type.to_sym][name.to_sym]
41
+ all_templates[type.to_sym].delete name.to_sym
42
42
  end
43
43
 
44
44
  ##
@@ -53,9 +53,10 @@ module Amp
53
53
  # Registers the default templates. Separated into a method (instead of automatically
54
54
  # run) because templates aren't used enough to justify the IO hit from loading them in.
55
55
  def load_default_templates
56
- Dir[File.expand_path(File.join(File.dirname(__FILE__), "*.erb"))].each do |f|
56
+ Dir[File.expand_path(File.join(File.dirname(__FILE__), "**/*.erb"))].each do |f|
57
57
  name = f.split('/').last.chomp('.erb').sub('.','-')
58
- FileTemplate.new(name, f)
58
+ type = f.split('/')[-2]
59
+ FileTemplate.new(type, name, f)
59
60
  end
60
61
  end
61
62
 
@@ -69,6 +70,7 @@ module Amp
69
70
  instance_eval do
70
71
  def ensure_templates_loaded; end
71
72
  end
73
+ true
72
74
  end
73
75
  end
74
76
 
@@ -83,9 +85,9 @@ module Amp
83
85
  # @param [Symbol] type the type of the template. Indicates the renderer used.
84
86
  # @param [String] text the text of the template, which presumably has some templating
85
87
  # code to substitute in local variables and make a nice output system.
86
- def initialize(name, renderer = :erb, text = "")
88
+ def initialize(type, name, renderer = :erb, text = "")
87
89
  @name, @renderer, @text = name, renderer, text
88
- Template.register(name, self)
90
+ Template.register(type, name, self)
89
91
  end
90
92
 
91
93
  ##
@@ -103,7 +105,7 @@ module Amp
103
105
  case renderer.to_sym
104
106
  when :erb
105
107
  require 'erb'
106
- locals_assigns = locals.to_a.collect { |k,v| "#{k} = locals[:#{k}]" }
108
+ locals_assigns = locals.map { |k,v| "#{k} = locals[:#{k}]" }
107
109
  eval locals_assigns.join("\n"), render_binding
108
110
 
109
111
  erb = ERB.new(text, 0, "-")
@@ -128,17 +130,17 @@ module Amp
128
130
  class FileTemplate < Template
129
131
  KNOWN_EXTENSIONS = ["erb", "haml"]
130
132
 
131
- attr_accessor :file
133
+ attr_accessor :file
132
134
 
133
135
  ##
134
136
  # Initializes a new FileTemplate with different
135
- def initialize(name, file, renderer = nil)
137
+ def initialize(type, name, file, renderer = nil)
136
138
  if renderer.nil?
137
139
  renderer = KNOWN_EXTENSIONS.select {|ext| file.end_with? ext}.first
138
140
  end
139
141
  raise ArgumentError.new("No renderer specified for #{file.inspect}") if renderer.nil?
140
142
  @file = file
141
- super(name, renderer, File.read(file))
143
+ super(type, name, renderer, File.read(file))
142
144
  end
143
145
 
144
146
  def save!
@@ -146,8 +148,6 @@ module Amp
146
148
  end
147
149
  end
148
150
 
149
-
150
-
151
151
  end
152
152
  end
153
153
 
@@ -0,0 +1,51 @@
1
+ .Dd January 10, 2010
2
+ .Os
3
+ .Dt amp 1
4
+ .Sh NAME
5
+ .Nm amp
6
+ .Nd Ruby-based VCS engine
7
+ .Sh SYNOPSIS
8
+ .Nm
9
+ .Op Fl d
10
+ .Op Fl verbose
11
+ .Op Fl profile
12
+ .Op Fl R Ar repo_dir
13
+ .Op Fl pure-ruby
14
+ .Op Fl testing
15
+ .Ar command ...
16
+ .Sh DESCRIPTION
17
+ Amp is a revolutionary change in how we approach version control systems. Not only does it re-implement
18
+ Mercurial's core in Ruby, but re-thinks how we interact with version control. It intends to wrap multiple
19
+ VCS systems - git, hg, svn - under the same API, allowing the unique Amp command system to work with all
20
+ repositories in the same manner.
21
+
22
+ Amp currently implements Mercurial and a large subset of the Mercurial command-set.
23
+ .Bl -tag -width "mmmmmmmmmm" -compact
24
+ .Pp
25
+ .It Fl verbose
26
+ Enables verbose output for the entire Amp process.
27
+ .Pp
28
+ .It Fl d
29
+ Prings a variety of debug information about the arguments and options passed into amp.
30
+ .Pp
31
+ .It Fl profile
32
+ Profiles the amp process as it runs the requested command. Deprecated and unwise.
33
+ .Pp
34
+ .It Fl R Ar repo_dir
35
+ The path to the repository to use
36
+ .Pp
37
+ .It Fl pure-ruby
38
+ Use only pure ruby (no C-extensions)
39
+ .Pp
40
+ .It Fl testing
41
+ Running a test. Don't touch this.
42
+ .El
43
+ .Pp
44
+ .Sh SEE ALSO
45
+ .Xr git 1
46
+ .Xr hg 1
47
+ .Xr ruby 1
48
+ .Xr amprc 5
49
+ .Sh AUTHORS
50
+ .An "Michael Edgar" Aq adgar@carboni.ca
51
+ .An "Ari Brown" Aq seydar@carboni.ca