amp 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. data/.gitignore +1 -0
  2. data/.hgignore +26 -0
  3. data/AUTHORS +2 -0
  4. data/History.txt +6 -0
  5. data/LICENSE +37 -0
  6. data/MANIFESTO +7 -0
  7. data/Manifest.txt +294 -0
  8. data/README.md +129 -0
  9. data/Rakefile +102 -0
  10. data/SCHEDULE.markdown +12 -0
  11. data/STYLE +27 -0
  12. data/TODO.markdown +149 -0
  13. data/ampfile.rb +47 -0
  14. data/bin/amp +30 -0
  15. data/bin/amp1.9 +30 -0
  16. data/ext/amp/bz2/README.txt +39 -0
  17. data/ext/amp/bz2/bz2.c +1582 -0
  18. data/ext/amp/bz2/extconf.rb +77 -0
  19. data/ext/amp/bz2/mkmf.log +29 -0
  20. data/ext/amp/mercurial_patch/extconf.rb +5 -0
  21. data/ext/amp/mercurial_patch/mpatch.c +405 -0
  22. data/ext/amp/priority_queue/extconf.rb +5 -0
  23. data/ext/amp/priority_queue/priority_queue.c +947 -0
  24. data/ext/amp/support/extconf.rb +5 -0
  25. data/ext/amp/support/support.c +250 -0
  26. data/lib/amp.rb +200 -0
  27. data/lib/amp/commands/command.rb +507 -0
  28. data/lib/amp/commands/command_support.rb +137 -0
  29. data/lib/amp/commands/commands/config.rb +143 -0
  30. data/lib/amp/commands/commands/help.rb +29 -0
  31. data/lib/amp/commands/commands/init.rb +10 -0
  32. data/lib/amp/commands/commands/templates.rb +137 -0
  33. data/lib/amp/commands/commands/version.rb +7 -0
  34. data/lib/amp/commands/commands/workflow.rb +28 -0
  35. data/lib/amp/commands/commands/workflows/git/add.rb +65 -0
  36. data/lib/amp/commands/commands/workflows/git/copy.rb +27 -0
  37. data/lib/amp/commands/commands/workflows/git/mv.rb +23 -0
  38. data/lib/amp/commands/commands/workflows/git/rm.rb +60 -0
  39. data/lib/amp/commands/commands/workflows/hg/add.rb +53 -0
  40. data/lib/amp/commands/commands/workflows/hg/addremove.rb +86 -0
  41. data/lib/amp/commands/commands/workflows/hg/annotate.rb +46 -0
  42. data/lib/amp/commands/commands/workflows/hg/archive.rb +126 -0
  43. data/lib/amp/commands/commands/workflows/hg/branch.rb +28 -0
  44. data/lib/amp/commands/commands/workflows/hg/branches.rb +30 -0
  45. data/lib/amp/commands/commands/workflows/hg/bundle.rb +115 -0
  46. data/lib/amp/commands/commands/workflows/hg/clone.rb +95 -0
  47. data/lib/amp/commands/commands/workflows/hg/commit.rb +42 -0
  48. data/lib/amp/commands/commands/workflows/hg/copy.rb +31 -0
  49. data/lib/amp/commands/commands/workflows/hg/debug/dirstate.rb +32 -0
  50. data/lib/amp/commands/commands/workflows/hg/debug/index.rb +36 -0
  51. data/lib/amp/commands/commands/workflows/hg/default.rb +9 -0
  52. data/lib/amp/commands/commands/workflows/hg/diff.rb +30 -0
  53. data/lib/amp/commands/commands/workflows/hg/forget.rb +11 -0
  54. data/lib/amp/commands/commands/workflows/hg/heads.rb +25 -0
  55. data/lib/amp/commands/commands/workflows/hg/identify.rb +23 -0
  56. data/lib/amp/commands/commands/workflows/hg/import.rb +135 -0
  57. data/lib/amp/commands/commands/workflows/hg/incoming.rb +85 -0
  58. data/lib/amp/commands/commands/workflows/hg/info.rb +18 -0
  59. data/lib/amp/commands/commands/workflows/hg/log.rb +21 -0
  60. data/lib/amp/commands/commands/workflows/hg/manifest.rb +13 -0
  61. data/lib/amp/commands/commands/workflows/hg/merge.rb +53 -0
  62. data/lib/amp/commands/commands/workflows/hg/move.rb +28 -0
  63. data/lib/amp/commands/commands/workflows/hg/outgoing.rb +61 -0
  64. data/lib/amp/commands/commands/workflows/hg/pull.rb +74 -0
  65. data/lib/amp/commands/commands/workflows/hg/push.rb +20 -0
  66. data/lib/amp/commands/commands/workflows/hg/remove.rb +45 -0
  67. data/lib/amp/commands/commands/workflows/hg/resolve.rb +83 -0
  68. data/lib/amp/commands/commands/workflows/hg/revert.rb +53 -0
  69. data/lib/amp/commands/commands/workflows/hg/root.rb +13 -0
  70. data/lib/amp/commands/commands/workflows/hg/serve.rb +38 -0
  71. data/lib/amp/commands/commands/workflows/hg/status.rb +116 -0
  72. data/lib/amp/commands/commands/workflows/hg/tag.rb +69 -0
  73. data/lib/amp/commands/commands/workflows/hg/tags.rb +27 -0
  74. data/lib/amp/commands/commands/workflows/hg/tip.rb +13 -0
  75. data/lib/amp/commands/commands/workflows/hg/update.rb +27 -0
  76. data/lib/amp/commands/commands/workflows/hg/verify.rb +9 -0
  77. data/lib/amp/commands/commands/workflows/hg/view.rb +36 -0
  78. data/lib/amp/commands/dispatch.rb +181 -0
  79. data/lib/amp/commands/hooks.rb +81 -0
  80. data/lib/amp/dependencies/amp_support.rb +1 -0
  81. data/lib/amp/dependencies/amp_support/ruby_amp_support.rb +103 -0
  82. data/lib/amp/dependencies/minitar.rb +979 -0
  83. data/lib/amp/dependencies/priority_queue.rb +18 -0
  84. data/lib/amp/dependencies/priority_queue/c_priority_queue.rb +1 -0
  85. data/lib/amp/dependencies/priority_queue/poor_priority_queue.rb +46 -0
  86. data/lib/amp/dependencies/priority_queue/ruby_priority_queue.rb +525 -0
  87. data/lib/amp/dependencies/python_config.rb +211 -0
  88. data/lib/amp/dependencies/trollop.rb +713 -0
  89. data/lib/amp/dependencies/zip/ioextras.rb +155 -0
  90. data/lib/amp/dependencies/zip/stdrubyext.rb +111 -0
  91. data/lib/amp/dependencies/zip/tempfile_bugfixed.rb +186 -0
  92. data/lib/amp/dependencies/zip/zip.rb +1850 -0
  93. data/lib/amp/dependencies/zip/zipfilesystem.rb +609 -0
  94. data/lib/amp/dependencies/zip/ziprequire.rb +90 -0
  95. data/lib/amp/encoding/base85.rb +97 -0
  96. data/lib/amp/encoding/binary_diff.rb +82 -0
  97. data/lib/amp/encoding/difflib.rb +166 -0
  98. data/lib/amp/encoding/mercurial_diff.rb +378 -0
  99. data/lib/amp/encoding/mercurial_patch.rb +1 -0
  100. data/lib/amp/encoding/patch.rb +292 -0
  101. data/lib/amp/encoding/pure_ruby/ruby_mercurial_patch.rb +123 -0
  102. data/lib/amp/extensions/ditz.rb +41 -0
  103. data/lib/amp/extensions/lighthouse.rb +167 -0
  104. data/lib/amp/graphs/ancestor.rb +147 -0
  105. data/lib/amp/graphs/copies.rb +261 -0
  106. data/lib/amp/merges/merge_state.rb +164 -0
  107. data/lib/amp/merges/merge_ui.rb +322 -0
  108. data/lib/amp/merges/simple_merge.rb +450 -0
  109. data/lib/amp/profiling_hacks.rb +36 -0
  110. data/lib/amp/repository/branch_manager.rb +234 -0
  111. data/lib/amp/repository/dir_state.rb +950 -0
  112. data/lib/amp/repository/journal.rb +203 -0
  113. data/lib/amp/repository/lock.rb +207 -0
  114. data/lib/amp/repository/repositories/bundle_repository.rb +214 -0
  115. data/lib/amp/repository/repositories/http_repository.rb +377 -0
  116. data/lib/amp/repository/repositories/local_repository.rb +2661 -0
  117. data/lib/amp/repository/repository.rb +94 -0
  118. data/lib/amp/repository/store.rb +485 -0
  119. data/lib/amp/repository/tag_manager.rb +319 -0
  120. data/lib/amp/repository/updatable.rb +532 -0
  121. data/lib/amp/repository/verification.rb +431 -0
  122. data/lib/amp/repository/versioned_file.rb +475 -0
  123. data/lib/amp/revlogs/bundle_revlogs.rb +246 -0
  124. data/lib/amp/revlogs/changegroup.rb +217 -0
  125. data/lib/amp/revlogs/changelog.rb +338 -0
  126. data/lib/amp/revlogs/changeset.rb +521 -0
  127. data/lib/amp/revlogs/file_log.rb +165 -0
  128. data/lib/amp/revlogs/index.rb +493 -0
  129. data/lib/amp/revlogs/manifest.rb +195 -0
  130. data/lib/amp/revlogs/node.rb +18 -0
  131. data/lib/amp/revlogs/revlog.rb +1032 -0
  132. data/lib/amp/revlogs/revlog_support.rb +126 -0
  133. data/lib/amp/server/amp_user.rb +44 -0
  134. data/lib/amp/server/extension/amp_extension.rb +396 -0
  135. data/lib/amp/server/extension/authorization.rb +201 -0
  136. data/lib/amp/server/fancy_http_server.rb +252 -0
  137. data/lib/amp/server/fancy_views/_browser.haml +28 -0
  138. data/lib/amp/server/fancy_views/_diff_file.haml +13 -0
  139. data/lib/amp/server/fancy_views/_navbar.haml +17 -0
  140. data/lib/amp/server/fancy_views/changeset.haml +31 -0
  141. data/lib/amp/server/fancy_views/commits.haml +32 -0
  142. data/lib/amp/server/fancy_views/file.haml +35 -0
  143. data/lib/amp/server/fancy_views/file_diff.haml +23 -0
  144. data/lib/amp/server/fancy_views/harshcss/all_hallows_eve.css +72 -0
  145. data/lib/amp/server/fancy_views/harshcss/amy.css +147 -0
  146. data/lib/amp/server/fancy_views/harshcss/twilight.css +138 -0
  147. data/lib/amp/server/fancy_views/stylesheet.sass +175 -0
  148. data/lib/amp/server/http_server.rb +140 -0
  149. data/lib/amp/server/repo_user_management.rb +287 -0
  150. data/lib/amp/support/amp_config.rb +164 -0
  151. data/lib/amp/support/amp_ui.rb +287 -0
  152. data/lib/amp/support/docs.rb +54 -0
  153. data/lib/amp/support/generator.rb +78 -0
  154. data/lib/amp/support/ignore.rb +144 -0
  155. data/lib/amp/support/loaders.rb +93 -0
  156. data/lib/amp/support/logger.rb +103 -0
  157. data/lib/amp/support/match.rb +151 -0
  158. data/lib/amp/support/multi_io.rb +87 -0
  159. data/lib/amp/support/openers.rb +121 -0
  160. data/lib/amp/support/ruby_19_compatibility.rb +66 -0
  161. data/lib/amp/support/support.rb +1095 -0
  162. data/lib/amp/templates/blank.commit.erb +23 -0
  163. data/lib/amp/templates/blank.log.erb +18 -0
  164. data/lib/amp/templates/default.commit.erb +23 -0
  165. data/lib/amp/templates/default.log.erb +26 -0
  166. data/lib/amp/templates/template.rb +165 -0
  167. data/site/Rakefile +24 -0
  168. data/site/src/about/ampfile.haml +57 -0
  169. data/site/src/about/commands.haml +106 -0
  170. data/site/src/about/index.haml +33 -0
  171. data/site/src/about/performance.haml +31 -0
  172. data/site/src/about/workflows.haml +34 -0
  173. data/site/src/contribute/index.haml +65 -0
  174. data/site/src/contribute/style.haml +297 -0
  175. data/site/src/css/active4d.css +114 -0
  176. data/site/src/css/all_hallows_eve.css +72 -0
  177. data/site/src/css/all_themes.css +3299 -0
  178. data/site/src/css/amp.css +260 -0
  179. data/site/src/css/amy.css +147 -0
  180. data/site/src/css/blackboard.css +88 -0
  181. data/site/src/css/brilliance_black.css +605 -0
  182. data/site/src/css/brilliance_dull.css +599 -0
  183. data/site/src/css/cobalt.css +149 -0
  184. data/site/src/css/cur_amp.css +185 -0
  185. data/site/src/css/dawn.css +121 -0
  186. data/site/src/css/eiffel.css +121 -0
  187. data/site/src/css/espresso_libre.css +109 -0
  188. data/site/src/css/idle.css +62 -0
  189. data/site/src/css/iplastic.css +80 -0
  190. data/site/src/css/lazy.css +73 -0
  191. data/site/src/css/mac_classic.css +123 -0
  192. data/site/src/css/magicwb_amiga.css +104 -0
  193. data/site/src/css/pastels_on_dark.css +188 -0
  194. data/site/src/css/reset.css +55 -0
  195. data/site/src/css/slush_poppies.css +85 -0
  196. data/site/src/css/spacecadet.css +51 -0
  197. data/site/src/css/sunburst.css +180 -0
  198. data/site/src/css/twilight.css +137 -0
  199. data/site/src/css/zenburnesque.css +91 -0
  200. data/site/src/get/index.haml +32 -0
  201. data/site/src/helpers.rb +121 -0
  202. data/site/src/images/amp_logo.png +0 -0
  203. data/site/src/images/carbonica.png +0 -0
  204. data/site/src/images/revolution.png +0 -0
  205. data/site/src/images/tab-bg.png +0 -0
  206. data/site/src/images/tab-sliding-left.png +0 -0
  207. data/site/src/images/tab-sliding-right.png +0 -0
  208. data/site/src/include/_footer.haml +22 -0
  209. data/site/src/include/_header.haml +17 -0
  210. data/site/src/index.haml +104 -0
  211. data/site/src/learn/index.haml +46 -0
  212. data/site/src/scripts/jquery-1.3.2.min.js +19 -0
  213. data/site/src/scripts/jquery.cookie.js +96 -0
  214. data/tasks/stats.rake +155 -0
  215. data/tasks/yard.rake +171 -0
  216. data/test/dirstate_tests/dirstate +0 -0
  217. data/test/dirstate_tests/hgrc +5 -0
  218. data/test/dirstate_tests/test_dir_state.rb +192 -0
  219. data/test/functional_tests/resources/.hgignore +2 -0
  220. data/test/functional_tests/resources/STYLE.txt +25 -0
  221. data/test/functional_tests/resources/command.rb +372 -0
  222. data/test/functional_tests/resources/commands/annotate.rb +57 -0
  223. data/test/functional_tests/resources/commands/experimental/lolcats.rb +17 -0
  224. data/test/functional_tests/resources/commands/heads.rb +22 -0
  225. data/test/functional_tests/resources/commands/manifest.rb +12 -0
  226. data/test/functional_tests/resources/commands/status.rb +90 -0
  227. data/test/functional_tests/resources/version2/.hgignore +5 -0
  228. data/test/functional_tests/resources/version2/STYLE.txt +25 -0
  229. data/test/functional_tests/resources/version2/command.rb +372 -0
  230. data/test/functional_tests/resources/version2/commands/annotate.rb +45 -0
  231. data/test/functional_tests/resources/version2/commands/experimental/lolcats.rb +17 -0
  232. data/test/functional_tests/resources/version2/commands/heads.rb +22 -0
  233. data/test/functional_tests/resources/version2/commands/manifest.rb +12 -0
  234. data/test/functional_tests/resources/version2/commands/status.rb +90 -0
  235. data/test/functional_tests/resources/version3/.hgignore +5 -0
  236. data/test/functional_tests/resources/version3/STYLE.txt +31 -0
  237. data/test/functional_tests/resources/version3/command.rb +376 -0
  238. data/test/functional_tests/resources/version3/commands/annotate.rb +45 -0
  239. data/test/functional_tests/resources/version3/commands/experimental/lolcats.rb +17 -0
  240. data/test/functional_tests/resources/version3/commands/heads.rb +22 -0
  241. data/test/functional_tests/resources/version3/commands/manifest.rb +12 -0
  242. data/test/functional_tests/resources/version3/commands/status.rb +90 -0
  243. data/test/functional_tests/resources/version4/.hgignore +5 -0
  244. data/test/functional_tests/resources/version4/STYLE.txt +31 -0
  245. data/test/functional_tests/resources/version4/command.rb +376 -0
  246. data/test/functional_tests/resources/version4/commands/experimental/lolcats.rb +17 -0
  247. data/test/functional_tests/resources/version4/commands/heads.rb +22 -0
  248. data/test/functional_tests/resources/version4/commands/manifest.rb +12 -0
  249. data/test/functional_tests/resources/version4/commands/stats.rb +25 -0
  250. data/test/functional_tests/resources/version4/commands/status.rb +90 -0
  251. data/test/functional_tests/resources/version5_1/.hgignore +5 -0
  252. data/test/functional_tests/resources/version5_1/STYLE.txt +2 -0
  253. data/test/functional_tests/resources/version5_1/command.rb +374 -0
  254. data/test/functional_tests/resources/version5_1/commands/experimental/lolcats.rb +17 -0
  255. data/test/functional_tests/resources/version5_1/commands/heads.rb +22 -0
  256. data/test/functional_tests/resources/version5_1/commands/manifest.rb +12 -0
  257. data/test/functional_tests/resources/version5_1/commands/stats.rb +25 -0
  258. data/test/functional_tests/resources/version5_1/commands/status.rb +90 -0
  259. data/test/functional_tests/resources/version5_2/.hgignore +5 -0
  260. data/test/functional_tests/resources/version5_2/STYLE.txt +14 -0
  261. data/test/functional_tests/resources/version5_2/command.rb +376 -0
  262. data/test/functional_tests/resources/version5_2/commands/experimental/lolcats.rb +17 -0
  263. data/test/functional_tests/resources/version5_2/commands/manifest.rb +12 -0
  264. data/test/functional_tests/resources/version5_2/commands/newz.rb +12 -0
  265. data/test/functional_tests/resources/version5_2/commands/stats.rb +25 -0
  266. data/test/functional_tests/resources/version5_2/commands/status.rb +90 -0
  267. data/test/functional_tests/test_functional.rb +604 -0
  268. data/test/localrepo_tests/test_local_repo.rb +121 -0
  269. data/test/localrepo_tests/testrepo.tar.gz +0 -0
  270. data/test/manifest_tests/00manifest.i +0 -0
  271. data/test/manifest_tests/test_manifest.rb +72 -0
  272. data/test/merge_tests/base.txt +10 -0
  273. data/test/merge_tests/expected.local.txt +16 -0
  274. data/test/merge_tests/local.txt +11 -0
  275. data/test/merge_tests/remote.txt +11 -0
  276. data/test/merge_tests/test_merge.rb +26 -0
  277. data/test/revlog_tests/00changelog.i +0 -0
  278. data/test/revlog_tests/revision_added_changelog.i +0 -0
  279. data/test/revlog_tests/test_adding_index.i +0 -0
  280. data/test/revlog_tests/test_revlog.rb +333 -0
  281. data/test/revlog_tests/testindex.i +0 -0
  282. data/test/store_tests/store.tar.gz +0 -0
  283. data/test/store_tests/test_fncache_store.rb +122 -0
  284. data/test/test_amp.rb +9 -0
  285. data/test/test_base85.rb +14 -0
  286. data/test/test_bdiff.rb +42 -0
  287. data/test/test_commands.rb +122 -0
  288. data/test/test_difflib.rb +50 -0
  289. data/test/test_helper.rb +15 -0
  290. data/test/test_journal.rb +29 -0
  291. data/test/test_match.rb +134 -0
  292. data/test/test_mdiff.rb +74 -0
  293. data/test/test_mpatch.rb +14 -0
  294. data/test/test_support.rb +24 -0
  295. metadata +385 -0
@@ -0,0 +1,122 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
3
+
4
+ class TestFilenameCacheStore < Test::Unit::TestCase
5
+ STORE_PATH = File.expand_path(File.join(File.dirname(__FILE__)))
6
+ def setup
7
+ @store = Amp::Repositories::Stores.pick(['store','fncache'], STORE_PATH, Amp::Opener)
8
+ end
9
+
10
+ def test_load_manifest
11
+ assert_not_nil @store
12
+ assert_instance_of Amp::Repositories::Stores::FilenameCacheStore, @store
13
+ end
14
+
15
+ def test_hybrid_encode
16
+ result = Amp::Repositories::Stores.hybrid_encode("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
17
+ "A????WHHHHHHHHHHHAAAAAAAAATTTTTTTTTT/"+
18
+ "lolzorZ?.rb")
19
+ expected = "dh/abcdefgh/hahaha~3/lolzorz~3f.rb0d132fe8aa79af42d3d3c11038"+
20
+ "3007e9f5bd43d4.rb"
21
+ assert_equal expected, result
22
+
23
+ result = Amp::Repositories::Stores.hybrid_encode("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
24
+ "A????WHHHHTT/lolzorZ?.rb")
25
+ expected = "data/_a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z/_h"+
26
+ "_a_h_a_h_a~3f~3f~3f~3f_w_h_h_h_h_t_t/lolzor_z~3f.rb"
27
+ assert_equal expected, result
28
+
29
+ result = Amp::Repositories::Stores.hybrid_encode("data///../.././//lolzorZ?.rb")
30
+ expected = "data///.~2e/.~2e/~2e///lolzor_z~3f.rb"
31
+ assert_equal expected, result
32
+ end
33
+
34
+ def test_normal_encode
35
+ result = Amp::Repositories::Stores.encode_filename("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
36
+ "A????WHHHHHHHHHHHAAAAAAAAATTTTTTTTTT/"+
37
+ "lolzorZ?.rb")
38
+ expected = "data/_a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z/_h_"+
39
+ "a_h_a_h_a~3f~3f~3f~3f_w_h_h_h_h_h_h_h_h_h_h_h_a_a_a_a_a_a_a_a"+
40
+ "_a_t_t_t_t_t_t_t_t_t_t/lolzor_z~3f.rb"
41
+ assert_equal expected, result
42
+
43
+ result = Amp::Repositories::Stores.encode_filename("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
44
+ "A????WHHHHTT/lolzorZ?.rb")
45
+ expected = "data/_a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z/_h_"+
46
+ "a_h_a_h_a~3f~3f~3f~3f_w_h_h_h_h_t_t/lolzor_z~3f.rb"
47
+ assert_equal expected, result
48
+
49
+ result = Amp::Repositories::Stores.encode_filename("data///../.././//lolzorZ?.rb")
50
+ expected = "data///../.././//lolzor_z~3f.rb"
51
+ assert_equal expected, result
52
+ end
53
+
54
+ def test_normal_decode
55
+ result = Amp::Repositories::Stores.decode_filename(
56
+ "data/_a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z/_h_"+
57
+ "a_h_a_h_a~3f~3f~3f~3f_w_h_h_h_h_h_h_h_h_h_h_h_a_a_a_a_a_a_a_a"+
58
+ "_a_t_t_t_t_t_t_t_t_t_t/lolzor_z~3f.rb")
59
+
60
+ expected = "data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
61
+ "A????WHHHHHHHHHHHAAAAAAAAATTTTTTTTTT/"+
62
+ "lolzorZ?.rb"
63
+ assert_equal expected, result
64
+
65
+ result = Amp::Repositories::Stores.decode_filename(
66
+ "data/_a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z/_h_"+
67
+ "a_h_a_h_a~3f~3f~3f~3f_w_h_h_h_h_t_t/lolzor_z~3f.rb")
68
+ expected = "data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAHA????WHHHHTT/lolzorZ?.rb"
69
+ assert_equal expected, result
70
+
71
+ result = Amp::Repositories::Stores.decode_filename("data///../.././//lolzor_z~3f.rb")
72
+ expected = "data///../.././//lolzorZ?.rb"
73
+ assert_equal expected, result
74
+ end
75
+
76
+ def test_custom_pathjoiner
77
+ tempstore = @store.path_joiner
78
+ @store.path_joiner = proc {|*args| args.join "LOLCATS"}
79
+ result = @store.join "teh_file_namez"
80
+ expected = TestFilenameCacheStore::STORE_PATH + "/store" + "LOLCATS" + "teh_file_namez"
81
+ assert_equal expected, result
82
+ end
83
+
84
+ def test_walk
85
+ # alright.... the list is just too fucking huge to have it compare
86
+ # against the whole thing. So we're going to pick 10 and make sure
87
+ # that they're in there. These are some pretty good edge cases, too.
88
+ expected = [['data/lib/commands/dispatch.rb.i', 'data/lib/commands/dispatch.rb.i', 1500],
89
+ ['data/test/test_support.rb.i', 'data/test/test__support.rb.i', 640],
90
+ ['data/AUTHORS.i', 'data/_a_u_t_h_o_r_s.i', 64],
91
+ ['data/test/manifest_tests/test_manifest.rb.i', 'data/test/manifest__tests/test__manifest.rb.i', 1865],
92
+ ['data/lib/revlogs/changelog.rb.i', 'data/lib/revlogs/changelog.rb.i', 5386],
93
+ ['data/test/revlog_tests/00changelog.i.i', 'data/test/revlog__tests/00changelog.i.i', 10285],
94
+ ['00manifest.i', '00manifest.i', 43979],
95
+ ['00changelog.i', '00changelog.i', 28785]
96
+ ]
97
+ result = []
98
+ @store.walk do |arr|
99
+ result << arr
100
+ end
101
+
102
+ expected.each do |exp|
103
+ flunk "Couldn't find #{exp.inspect} in walked list." unless result.include? exp
104
+ end
105
+ assert true
106
+ end
107
+
108
+ def test_picker_works
109
+ requirements = []
110
+ store = Amp::Repositories::Stores.pick(requirements, STORE_PATH, Amp::Opener)
111
+ assert_instance_of Amp::Repositories::Stores::BasicStore, store
112
+
113
+ requirements = ['store']
114
+ store = Amp::Repositories::Stores.pick(requirements, STORE_PATH, Amp::Opener)
115
+ assert_instance_of Amp::Repositories::Stores::EncodedStore, store
116
+
117
+ requirements = ['store', 'fncache']
118
+ store = Amp::Repositories::Stores.pick(requirements, STORE_PATH, Amp::Opener)
119
+ assert_instance_of Amp::Repositories::Stores::FilenameCacheStore, store
120
+
121
+ end
122
+ end
@@ -0,0 +1,9 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
+
4
+ class TestAmp < Test::Unit::TestCase
5
+
6
+ def test_truth
7
+ assert true
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
+
4
+ class TestBase85 < Test::Unit::TestCase
5
+ def test_encode
6
+ assert_equal("Xk~0{Zy<DNWpZUKAZ>XdZeeX@AZc?TZE0g@VP$L~AZTxQAYpQ4AbD?fAarkJVR=6",
7
+ Amp::Encoding::Base85.encode("hello there, my name is michael! how are you today?"))
8
+ end
9
+
10
+ def test_decode
11
+ assert_equal("hello there, my name is michael! how are you today?",
12
+ Amp::Encoding::Base85.decode("Xk~0{Zy<DNWpZUKAZ>XdZeeX@AZc?TZE0g@VP$L~AZTxQAYpQ4AbD?fAarkJVR=6"))
13
+ end
14
+ end
@@ -0,0 +1,42 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
+
4
+ class TestBdiff < Test::Unit::TestCase
5
+ include Amp::Diffs
6
+
7
+ def test_create_bdiff
8
+ input = "hi there\ni'm cool"
9
+ output = "hi there\ni'm stupid"
10
+ expected_output = "\000\000\000\t\000\000\000\021\000\000\000\ni'm stupid"
11
+ assert_equal(expected_output, BinaryDiff.bdiff(input, output))
12
+ end
13
+
14
+ def test_another_bdiff
15
+ input = "c913df15006c6e06504414acf8acfedd32e5875d\nmichaeledgar@michael-edgars-macbook-pro.local"+
16
+ "\n1248396415 14400\nSTYLE.txt\n\nFirst commit."
17
+ output = "b2a7f7ab636d1dbd06afd90f1bf287dfb92762fb\nmichaeledgar@michael-edgars-macbook-pro.local"+
18
+ "\n1248396417 14400\ncommand.rb\ncommands/annotate.rb\ncommands/heads.rb"+
19
+ "\ncommands/manifest.rb\ncommands/status.rb\n\nSecond commit, added commands"
20
+ expected_output = "\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)b2a7f7ab636d1dbd06afd90f1bf287dfb92762fb"+
21
+ "\n\x00\x00\x00W\x00\x00\x00r\x00\x00\x00k1248396417 14400\ncommand.rb"+
22
+ "\ncommands/annotate.rb\ncommands/heads.rb\ncommands/manifest.rb"+
23
+ "\ncommands/status.rb\n\x00\x00\x00s\x00\x00\x00\x80\x00\x00\x00\x1d"+
24
+ "Second commit, added commands"
25
+ assert_equal(expected_output, BinaryDiff.bdiff(input, output))
26
+ end
27
+
28
+ def test_yet_another_bdiff
29
+ input = "The Amp Commandments Redux:\n\t1. This is intended to genreate a conflict. "+
30
+ "I'm out of witty stuff to put here."
31
+ output = "\t1. This is intended to genreate a conflict. I'm out of witty stuff to put here."
32
+ expected_output = "\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00"
33
+ assert_equal(expected_output, BinaryDiff.bdiff(input, output))
34
+ end
35
+
36
+ def test_create_simple_bdiff
37
+ input = ""
38
+ output = "hi there\ni'm stupid"
39
+ expected_output = "\000\000\000\000\000\000\000\000\000\000\000\x13"+output
40
+ assert_equal expected_output, BinaryDiff.bdiff(input, output)
41
+ end
42
+ end
@@ -0,0 +1,122 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp/commands/command.rb"))
4
+
5
+ class TestCommmands < Test::Unit::TestCase
6
+ include Amp
7
+ include Amp::KernelMethods
8
+ extend Amp::KernelMethods
9
+ @@command = Amp::Command.new :testingzorz do |c|
10
+ c.opt :silly, "Silliness"
11
+ c.opt :shorted, "Shorted", :short => "-s"
12
+ c.opt :stringy, "Stringed", :type => :string
13
+ c.opt :"stop-at-filter", "Testing before filters"
14
+ c.before do |opts, args|
15
+ $_test_before_ran = true
16
+ $_test_ran_on_run = false # reset this one
17
+ if opts[:"stop-at-filter"]
18
+ cut!
19
+ end
20
+ true
21
+ end
22
+
23
+ c.on_run do |opts, args|
24
+ $_test_silly = opts[:silly]
25
+ $_test_silly_given = opts[:silly_given]
26
+ $_test_shorted = opts[:shorted]
27
+ $_test_shorted_given = opts[:shorted_given]
28
+ $_test_stringy = opts[:stringy]
29
+ $_test_stringy_given = opts[:stringy_given]
30
+ $_test_args = args
31
+ $_test_ran_on_run = true
32
+ end
33
+ end
34
+
35
+ def set_argv(new_argv)
36
+ argv = Object.send(:remove_const, :ARGV)
37
+ Object.send(:const_set, :ARGV, new_argv)
38
+ return argv
39
+ end
40
+
41
+ def cloak_argv(temp_argv)
42
+ $break = false
43
+ argv = set_argv(temp_argv)
44
+ yield
45
+ set_argv(argv)
46
+ end
47
+
48
+ def test_anything_runs
49
+ cloak_argv([]) do
50
+ opts = @@command.collect_options
51
+ @@command.run(opts, Object::ARGV)
52
+ end
53
+
54
+ assert $_test_ran_on_run
55
+ assert $_test_before_ran
56
+ end
57
+
58
+ def test_long_option
59
+ cloak_argv(["--silly"]) do
60
+ opts = @@command.collect_options
61
+ @@command.run(opts, Object::ARGV)
62
+ end
63
+
64
+ assert $_test_silly_given
65
+ assert $_test_silly
66
+ end
67
+
68
+ def test_short_option
69
+ cloak_argv(["-s"]) do
70
+ opts = @@command.collect_options
71
+ @@command.run(opts, Object::ARGV)
72
+ end
73
+
74
+ assert $_test_shorted
75
+ assert $_test_shorted_given
76
+ end
77
+
78
+ def test_string_option
79
+ cloak_argv(["--stringy", "thestring"]) do
80
+ opts = @@command.collect_options
81
+ @@command.run(opts, Object::ARGV)
82
+ end
83
+
84
+ assert_equal "thestring", $_test_stringy
85
+ assert $_test_stringy_given
86
+ end
87
+
88
+ def test_extra_args
89
+ cloak_argv(["--stringy", "thestring", "arg1", "arg2"]) do
90
+ opts = @@command.collect_options
91
+ @@command.run(opts, Object::ARGV)
92
+ end
93
+
94
+ assert_equal ["arg1","arg2"], $_test_args
95
+ end
96
+
97
+ def test_break
98
+ cloak_argv(["--stop-at-filter"]) do
99
+ opts = @@command.collect_options
100
+ @@command.run(opts, Object::ARGV)
101
+ end
102
+
103
+ assert $_test_before_ran
104
+ assert_false $_test_ran_on_run
105
+ end
106
+
107
+ def test_maybe_repo
108
+ assert_false Amp::Command::MAYBE_REPO_ALLOWED[:testingzorz]
109
+ @@command.maybe_repo
110
+ assert Amp::Command::MAYBE_REPO_ALLOWED[:testingzorz]
111
+ @@command.maybe_repo = false
112
+ assert_false Amp::Command::MAYBE_REPO_ALLOWED[:testingzorz]
113
+ end
114
+
115
+ def test_no_repo
116
+ assert_false Amp::Command::NO_REPO_ALLOWED[:testingzorz]
117
+ @@command.no_repo
118
+ assert Amp::Command::NO_REPO_ALLOWED[:testingzorz]
119
+ @@command.no_repo = false
120
+ assert_false Amp::Command::NO_REPO_ALLOWED[:testingzorz]
121
+ end
122
+ end
@@ -0,0 +1,50 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
+
4
+
5
+ class TestDifflib < Test::Unit::TestCase
6
+ include Amp::Diffs
7
+ def test_one_match
8
+ matcher = SequenceMatcher.new("hi there my name is mike i hope you like me",
9
+ "hi there my name is joe i hate you like i hate me")
10
+ assert_equal([0,0,20], matcher.find_longest_match(0,43,0,49))
11
+ end
12
+
13
+ def test_full_matching
14
+ matcher = SequenceMatcher.new("hi there my name is mike i hope you like me",
15
+ "hi there my name is joe i hate you like i hate me")
16
+ assert_equal([{:start_a => 0, :start_b => 0, :length => 20}, #match for "hi there my name is "
17
+ {:start_a => 23, :start_b => 22, :length => 5}, #match for "e i ha"
18
+ {:start_a => 30, :start_b => 29, :length => 11}, #match for "e you like "
19
+ {:start_a => 41, :start_b => 47, :length => 2}, #match for "me"
20
+ {:start_a => 43, :start_b => 49, :length => 0}],
21
+ matcher.get_matching_blocks.sort {|a1,a2| a1[:start_a] <=> a2[:start_a]}) #last match is terminator
22
+
23
+ end
24
+
25
+ def test_full_example
26
+ matcher = SequenceMatcher.new(
27
+ ['c913df15006c6e06504414acf8acfedd32e5875d\n', 'michaeledgar@michael-edgars-macbook-pro.local\n',
28
+ '1248396415 14400\n', 'STYLE.txt\n', '\n', 'First commit.'],
29
+ ['b2a7f7ab636d1dbd06afd90f1bf287dfb92762fb\n', 'michaeledgar@michael-edgars-macbook-pro.local\n',
30
+ '1248396417 14400\n', 'command.rb\n', 'commands/annotate.rb\n', 'commands/heads.rb\n',
31
+ 'commands/manifest.rb\n', 'commands/status.rb\n', '\n', 'Second commit, added commands'])
32
+ assert_equal([{:start_a => 1, :start_b => 1, :length => 1}, #match for "michaeledgar@..."
33
+ {:start_a => 4, :start_b => 8, :length => 1}, #match for "\n"
34
+ {:start_a => 6, :start_b => 10, :length => 0}],
35
+ matcher.get_matching_blocks.sort {|a1,a2| a1[:start_a] <=> a2[:start_a]}) #last match is terminator
36
+
37
+ end
38
+
39
+ def test_another_full_example
40
+ matcher = SequenceMatcher.new(
41
+ ['The Amp Commandments Redux:\n',
42
+ "\t1. This is intended to genreate a conflict. I'm out of witty stuff to put here."],
43
+ ["\t1. This is intended to genreate a conflict. I'm out of witty stuff to put here."])
44
+ assert_equal([{:start_a => 1, :start_b => 0, :length => 1}, #match for "michaeledgar@..."
45
+ {:start_a => 2, :start_b => 1, :length => 0}],
46
+ matcher.get_matching_blocks.sort {|a1,a2| a1[:start_a] <=> a2[:start_a]}) #last match is terminator
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,15 @@
1
+ require 'test/unit'
2
+
3
+ def assert_false(val)
4
+ assert_equal(false, !!val)
5
+ end
6
+
7
+ def assert_not_nil(val)
8
+ assert_not_equal(nil, val)
9
+ end
10
+
11
+ def assert_file_contents(file, contents)
12
+ File.open(file,"r") do |f|
13
+ assert_equal f.read, contents
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
+
4
+ class TestJournal < Test::Unit::TestCase
5
+ def test_journal
6
+ tfile = "tempjournal"
7
+ j = Amp::Journal.new(Amp::StandardErrorReporter, tfile, nil)
8
+ j << ["file",12345]
9
+
10
+
11
+ test_open = open(tfile)
12
+ assert_equal("file\0#{12345}\n", test_open.read)
13
+ test_open.close
14
+ j.close
15
+
16
+ assert !File.exists?(tfile)
17
+ end
18
+
19
+ def test_journal_start_mode
20
+ tfile = "tempjournal"
21
+ Amp::Journal.start tfile do |j|
22
+ j << ["file",12345]
23
+ test_open = open(tfile)
24
+ assert_equal("file\0#{12345}\n", test_open.read)
25
+ test_open.close
26
+ end
27
+ assert !File.exists?(tfile)
28
+ end
29
+ end
@@ -0,0 +1,134 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
+
4
+ class TestMatch < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @all_files = ["silly.rb", "code/lib.rb", "code/support.yml", "bin/amp.rb", "test/test_bdiff.rb"]
8
+ @match_files = ["code/support.yml", "bin/amp.rb"]
9
+ @files = ['lib/amp.rb', 'lib/monkey', 'poop']
10
+ @matcher1 = Amp::Match.create :files => @files,
11
+ :includer => "regexp:\\.rbc$\n", # it will come in as such from the command line
12
+ :excluder => /^(.+\/)?\.[^.].*/
13
+ @block = proc {|f| f =~ /\.rbc$/ }
14
+ @matcher2 = Amp::Match.new :files => @files, &@block
15
+
16
+ @matcher3 = Amp::Match.create :includer => "glob: code/ext/*.o"
17
+
18
+ @matcher4 = Amp::Match.create :includer => "glob: code/ext/**/*.o"
19
+ end
20
+ def test_files_match
21
+ matcher = Amp::Match.create(:files => ["code/support.yml", "bin/amp.rb"])
22
+
23
+ assert_false matcher.exact?("silly.rb")
24
+ assert_false matcher.exact?("code/lib.rb")
25
+
26
+ assert matcher.exact?("code/support.yml")
27
+ assert matcher.exact?("bin/amp.rb")
28
+
29
+ assert_false matcher.exact?("test/test_bdiff.rb")
30
+
31
+ end
32
+
33
+ def test_files_basic_approximate
34
+ matcher = Amp::Match.create(:files => @match_files, :includer => "\.rb$")
35
+
36
+ assert matcher.approximate?("silly.rb")
37
+ assert matcher.approximate?("code/lib.rb")
38
+ assert_false matcher.approximate?("code/support.yml")
39
+ assert_false matcher.approximate?("bin/amp.rb") #in :files
40
+ assert matcher.approximate?("test/test_bdiff.rb")
41
+ end
42
+
43
+ def test_call
44
+ assert @matcher1.call('array.rbc')
45
+ assert @matcher1.call('lib/amp.rb')
46
+ assert !@matcher1.call('amp.rb')
47
+ assert @matcher1.call('monkey/poop/sdf/sdf/testy.rbc')
48
+ assert !@matcher1.call('busdfasdf')
49
+ assert !@matcher1.call('.hgignore')
50
+ assert !@matcher1.call('asdf/sdfs/sdf.asdf/sdf.sdf/.vimrc')
51
+
52
+ assert @matcher2.call('array.rbc')
53
+ assert @matcher2.call('lib/amp.rb')
54
+ assert !@matcher2.call('amp.rb')
55
+ assert @matcher2.call('monkey/poop/sdf/sdf/testy.rbc')
56
+ end
57
+
58
+ def test_files_basic_exclude
59
+ matcher = Amp::Match.create(:files => [], :includer => ".*", :excluder => "code")
60
+
61
+ assert_false matcher.failure?("silly.rb")
62
+ assert matcher.failure?("code/lib.rb")
63
+ assert matcher.failure?("code/support.yml")
64
+ assert_false matcher.failure?("bin/amp.rb") #in :files
65
+ assert_false matcher.failure?("test/test_bdiff.rb")
66
+ end
67
+
68
+ def test_approximate
69
+ assert @matcher2.approximate?('testy.rbc')
70
+ assert @matcher2.approximate?('monke/asd/fdf/drty.rbc')
71
+ assert !@matcher2.approximate?('lib/amp.rb')
72
+ assert !@matcher2.approximate?('buttmucnhc')
73
+ end
74
+
75
+ def test_globs
76
+ assert @matcher3.call('code/ext/asdf.o')
77
+ assert !@matcher3.call('code/ext/asdf.c')
78
+ assert !@matcher3.call('code/ext/monkey/asdf.c')
79
+ assert !@matcher3.call('code/ext/monkey/asdf.o')
80
+
81
+ assert @matcher4.call('code/ext/asdf.o')
82
+ assert !@matcher4.call('code/ext/asdf.c')
83
+ assert !@matcher4.call('code/ext/monkey/asdf.c')
84
+ assert @matcher4.call('code/ext/monkey/asdf.o')
85
+ end
86
+
87
+ def test_overall_match
88
+ matcher = Amp::Match.create(:files => "code/support.yml", :includer => "\\.rb$", :excluder => "code")
89
+
90
+ assert matcher.call("silly.rb") #include wins
91
+ assert_false matcher.call("code/lib.rb") #exclude overrides include
92
+ assert_raises StandardError do
93
+ matcher.call("code/support.yml")
94
+ end
95
+ assert matcher.call("bin/amp.rb")
96
+ assert matcher.call("test/test_bdiff.rb")
97
+ end
98
+
99
+ def test_block
100
+ assert_equal @block, @matcher2.block
101
+ end
102
+
103
+ def test_exact?
104
+ assert @matcher1.exact?('lib/amp.rb')
105
+ assert @matcher1.exact?('poop')
106
+ assert !@matcher1.exact?('monkey.rbc')
107
+ end
108
+
109
+ def test_exclude
110
+ assert_equal([/^(.+\/)?\.[^.].*/], @matcher1.exclude)
111
+ end
112
+
113
+ def test_failure?
114
+ assert @matcher1.failure?('.hgignore')
115
+ assert @matcher1.failure?('lib/.vimrc')
116
+ assert @matcher1.failure?('lib/.array.rbc')
117
+ end
118
+
119
+ def test_files
120
+ assert_equal @files, @matcher1.files
121
+ end
122
+
123
+ # Uh, compare procs? wtf?
124
+ def test_include
125
+ assert_equal([/\.rbc$/], @matcher1.include)
126
+ end
127
+
128
+ def test_included
129
+ assert @matcher1.included?('monkey.rbc')
130
+ assert @matcher1.included?('asdf/sdf/sdf/s/array.rbc')
131
+ assert @matcher1.included?('asd/.kernel.rbc') # shouldn't care about the excludes
132
+ end
133
+
134
+ end