amp-pure 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 +116 -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 +382 -0
@@ -0,0 +1,17 @@
1
+ command :lolcats do |c|
2
+ c.opt :cheezburger, "Add cheezburger to lolcat"
3
+ c.on_run do |opts, args|
4
+ puts "lolcats!"
5
+ puts "lolcats!"
6
+ puts "lolcats!"
7
+ puts "lolcats!"
8
+ puts "lolcats!"
9
+ end
10
+
11
+ c.before do |opts, args|
12
+ puts "Before lolcats...."
13
+ end
14
+ c.after do |opts, args|
15
+ puts "After lolcats!"
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ command :manifest do |c|
2
+ c.desc "Prints the manifest at a given revision (defaults to working directory)"
3
+ c.add_opt :rev, "Specifies the revision to check", {:short => "-r", :type => :integer}
4
+ c.on_run do |options, arguments|
5
+ revision = options[:rev]
6
+ repo = options[:repository]
7
+
8
+ repo[revision].each do |k, v|
9
+ puts "#{k}"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ command :newz do |c|
2
+ c.desc "Prints the newz at a given revision (defaults to working directory)"
3
+ c.add_opt :rev, "Specifies the revision to check", {:short => "-r", :type => :integer}
4
+ c.on_run do |options, arguments|
5
+ revision = options[:rev]
6
+ repo = options[:repository]
7
+
8
+ repo[revision].each do |k, v|
9
+ puts "#{k}"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ command :stats do |c|
2
+ c.desc "Prints the stats at a given revision (defaults to working directory)"
3
+ c.add_opt :rev, "Specifies the revision to check", {:short => "-r", :type => :integer}
4
+ c.on_run do |options, arguments|
5
+ revision = options[:rev]
6
+ repo = options[:repository]
7
+
8
+ repo[revision].each do |k, v|
9
+ puts "#{k}"
10
+ end
11
+ end
12
+ end
13
+
14
+ command :stats do |c|
15
+ c.desc "Prints the stats at a given revision (defaults to working directory)"
16
+ c.add_opt :rev, "Specifies the revision to check", {:short => "-r", :type => :integer}
17
+ c.on_run do |options, arguments|
18
+ revision = options[:rev]
19
+ repo = options[:repository]
20
+
21
+ repo[revision].each do |k, v|
22
+ puts "#{k}"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,90 @@
1
+ command :status do |c|
2
+ c.desc "Prints the status of the working directory (or another revision)"
3
+ c.add_opt :all, "Show all files", {:short => "-A"}
4
+ c.add_opt :modified, "Show only modified files", {:short => "-m"}
5
+ c.add_opt :added, "Show only added files", {:short => "-a"}
6
+ c.add_opt :deleted, "Show only deleted files", {:short => "-D"}
7
+ c.add_opt :removed, "Show only removed files", {:short => "-R"}
8
+ c.add_opt :clean, "Show only files without changes", {:short => "-c"}
9
+ c.add_opt :unknown, "Show only untracked files", {:short => "-u"}
10
+ c.add_opt :ignored, "Show only ignored files", {:short => "-i"}
11
+ c.add_opt :rev, "Selects which revision to use", {:short => "-r", :type => :string, :multi => true}
12
+ c.add_opt :hg, "Print the information in hg's style"
13
+ c.add_opt :"no-color","Don't use color to categorize the output"
14
+ c.synonym :st
15
+
16
+ c.on_run do |options, args|
17
+ repo = options[:repository]
18
+ node1, node2 = c.revision_pair(repo, options[:rev])
19
+ cwd = "" # use patterns later
20
+ stop = "\n"
21
+ copy = {}
22
+ colors = {'modified' => :cyan,
23
+ 'added' => :blue,
24
+ 'removed' => :red,
25
+ 'deleted' => :magenta,
26
+ 'unknown' => :green,
27
+ 'ignored' => :yellow,
28
+ 'clean' => :white
29
+ }
30
+ states = ['modified',
31
+ 'added' ,
32
+ 'removed' ,
33
+ 'deleted' ,
34
+ 'unknown' ,
35
+ 'ignored' ,
36
+ 'clean' ]
37
+ show = states.select {|k| options[k.to_sym]} # filter the list down
38
+
39
+ show = states if options[:all]
40
+ show = states[0..4] if show.empty?
41
+
42
+ statopts = {:node_1 => node1, :node_2 => node2 }
43
+
44
+ show.each {|switch| statopts[switch.to_sym] = true }
45
+
46
+ status = repo.status statopts
47
+
48
+ # PRINTING TIME!!!!!!!!
49
+
50
+ if options[:hg]
51
+ status_as_array = [status[:modified],
52
+ status[:added],
53
+ status[:removed],
54
+ status[:deleted],
55
+ status[:unknown],
56
+ status[:ignored],
57
+ status[:clean]
58
+ ]
59
+ changestates = states.zip("MAR!?IC".split(""), status_as_array)
60
+ changestates.each do |state, char, files|
61
+ if show.include? state
62
+ files.each do |f|
63
+ if options[:"no-color"]
64
+ Amp::UI.say "#{char} #{File.join(cwd, f.to_s)[1..-1]}#{stop}" unless f.nil?
65
+ else
66
+ Amp::UI.say "#{char.send colors[state]} #{File.join(cwd, f.to_s)[1..-1]}#{stop}" unless f.nil?
67
+ end
68
+ end
69
+ end
70
+ end
71
+ else
72
+ # print it our way
73
+
74
+ show.each do |state|
75
+ next if status[state.to_sym].empty?
76
+ num_of_files = status[state.to_sym].size
77
+
78
+ Amp::UI.say("#{state.upcase.send colors[state]}" +
79
+ " => #{num_of_files} file#{num_of_files > 1 ? 's' : ''}")
80
+
81
+ status[state.to_sym].each do |file|
82
+ Amp::UI.say "\t#{File.join(cwd, file)[1..-1]}"
83
+ end
84
+
85
+ puts
86
+ end
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,604 @@
1
+ require 'test/unit'
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../test_helper"))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
4
+
5
+ # easyness
6
+ class String
7
+ def fun_local; File.join($current_basedir, self); end
8
+ end
9
+
10
+ class TestFunctional < Test::Unit::TestCase
11
+
12
+ AMP_FILE = (RUBY_VERSION < "1.9") ? "amp" : "amp1.9"
13
+ AMP_BINARY = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', AMP_FILE))
14
+
15
+ def setup
16
+ $current_dir = Dir.pwd
17
+ $current_basedir = File.expand_path(File.dirname(__FILE__))
18
+ FileUtils.safe_unlink(File.join($current_basedir, "test.log"))
19
+ clean_dir "testrepo" #just in case
20
+ clean_dir "newrepo"
21
+ clean_dir "conflictrepo"
22
+ end
23
+
24
+ ##
25
+ # This is the big functional test. Since we will be building this repo up
26
+ # from scratch, every single test must pass in order - we can't hope a certain
27
+ # order is followed. So it all goes in one method. Sorry.
28
+ def test_init
29
+
30
+ # Create the mainline repository! Woo!
31
+ run_amp_command "init", "testrepo".fun_local
32
+
33
+ # Make sure we've correctly initialized the repository
34
+ assert_file 'testrepo'
35
+ assert_file 'testrepo/.hg'
36
+ assert_file 'testrepo/.hg/requires'
37
+ assert_file 'testrepo/.hg/store'
38
+
39
+ # Enter the repository. Time to take care of business
40
+ enter_repo "testrepo"
41
+
42
+ # Adds the first file, make sure it was successfully added to the dirstate
43
+ add_file_ensure_added "STYLE.txt"
44
+
45
+ # Commit the first file!
46
+ commit :message => "First commit."
47
+
48
+ # Make sure the first file made it into the manifest
49
+ assert_files_in_manifest "STYLE.txt"
50
+
51
+ # Run basic tests on the `head`, `log`, and `tip` commands
52
+ confirm_head_is_first_commit
53
+ confirm_head_equals_log_limit_one
54
+ confirm_head_equals_tip
55
+
56
+ # Get ready for revision 2: add a bunch of files!
57
+ # Make sure they were successfully added, too.
58
+ add_file_ensure_added "command.rb"
59
+ add_file_ensure_added "commands/annotate.rb"
60
+ add_file_ensure_added "commands/heads.rb"
61
+ add_file_ensure_added "commands/manifest.rb"
62
+ add_file_ensure_added "commands/status.rb"
63
+
64
+ # Copy a file into the repo, but don't add it. This is so we can check
65
+ # if `status` picks up unknown files.
66
+ copy_resource "commands/experimental/lolcats.rb", "commands/experimental/lolcats.rb"
67
+
68
+ # Make sure the file got copied
69
+ assert_file "testrepo/commands/experimental/lolcats.rb"
70
+
71
+ # Make sure status sees it and recognizes it as an unknown file.
72
+ assert_file_has_status "commands/experimental/lolcats.rb", :unknown
73
+
74
+ # Commit the second round of files
75
+ commit :message => "Second commit, added commands\nInteresting stuff."
76
+
77
+ # Make sure the second set of files are all in the manifest now
78
+ assert_files_in_manifest "command.rb", "commands/annotate.rb", "commands/heads.rb",
79
+ "commands/manifest.rb", "commands/status.rb", "STYLE.txt"
80
+
81
+ # Add our .hgignore file so we can test for ignored status
82
+ add_file_ensure_added ".hgignore"
83
+
84
+ # Make sure it picks up on lolcats.rb being an ignored file
85
+ assert_file_has_status "commands/experimental/lolcats.rb", :ignored
86
+
87
+ # Make sure we can see which files are clean
88
+ assert_file_has_status "STYLE.txt", :clean
89
+
90
+ ## Let's move the repo to version 2. woot! This copies the version2
91
+ ## resources into the working directory
92
+ replace_resources_with_version "version2"
93
+
94
+ # Version 2 modifies STYLE.txt and commands/annotate.rb.
95
+ # So let's run some status checks, making sure that those 2 files are marked
96
+ # as modified, .hgignore is still marked as added (we added it above), and
97
+ # an unmodified file is still marked as clean.
98
+ assert_file_has_status "STYLE.txt", :modified
99
+ assert_file_has_status "commands/annotate.rb", :modified
100
+ assert_file_has_status ".hgignore", :added #it's modified, but still should be added
101
+ assert_file_has_status "commands/manifest.rb", :clean
102
+
103
+ # Commit version 2, and specify a custom user.
104
+ commit :message => "Changed a couple files!", :user => "medgar"
105
+
106
+ # Make sure .hgignore got successfully added to the repo
107
+ assert_file_in_manifest ".hgignore"
108
+
109
+ # Make sure our custom user worked
110
+ assert_command_match(/user\: +medgar/, "log", nil, :limit => 1)
111
+ # Make sure the repo's still spiffy
112
+ assert_verify
113
+
114
+ # We're done with testrepo. Time to try some more advanced stuff. Exit testrepo.
115
+ exit_repo
116
+
117
+ # Clone testrepo to create "newrepo".
118
+ run_amp_command "clone #{"testrepo".fun_local} #{"newrepo".fun_local}"
119
+ # Enter the newrepo repository.
120
+ enter_repo "newrepo"
121
+
122
+ # Update this child repo to version 3
123
+ replace_resources_with_version "version3"
124
+ # Make sure command.rb was successfully modified
125
+ assert_file_has_status "command.rb", :modified
126
+ # Commit the modification
127
+ commit :message => "demonic infestation in command.rb", :user => "seydar"
128
+
129
+ # Add the curently ignored file
130
+ add_file_ensure_added "commands/experimental/lolcats.rb"
131
+ # And make sure it shows up as added, even though it falls under ignore rules
132
+ assert_file_has_status "commands/experimental/lolcats.rb", :added
133
+ # Commit our lolcats command
134
+ commit :message => "experimental branch with the lolcats command", :user => "seydar"
135
+ # Make sure that the custom user is still peachy
136
+ assert_command_match(/user\: +seydar/, "log", nil, :limit => 1)
137
+
138
+ # Push upstream to testrepo
139
+ run_amp_command "push"
140
+
141
+ # Switch to testrepo
142
+ exit_repo
143
+ enter_repo "testrepo"
144
+
145
+ # Make sure we didn't corrupt the upstream repo with our push
146
+ assert_verify
147
+ # Update to the newly pushed changesets
148
+ assert_command_match(/3 files updated/, "update")
149
+ # Verify that the head changeset is the correct one (about the lolcats branch)
150
+ assert_command_match(/experimental branch/, "head")
151
+
152
+ # Remove a file from the repo (using `amp remove`)
153
+ remove_file "commands/annotate.rb"
154
+ # And make sure it's marked as removed in the status
155
+ assert_file_is_removed "commands/annotate.rb"
156
+ # Update to version 4
157
+ replace_resources_with_version "version4"
158
+ # Add a file from version4 that we didn't have before, and make sure it gets
159
+ # added to the dirstate
160
+ add_file_ensure_added "version4/commands/stats.rb", "commands/stats.rb"
161
+ # Commit the file removal and the new addition
162
+ commit :message => "removed stupid annotate command. added stats!", :date => "1/1/2009"
163
+
164
+ # Make sure stats is marked as clean
165
+ assert_file_has_status "commands/stats.rb", :clean
166
+
167
+ # We have to do some juggling here because Ruby 1.9 will produce a different string for
168
+ # the date. So just hand-parse the input string and see if the result is in the changelog.
169
+ require 'time'
170
+ t = Time.parse("1/1/2009")
171
+ assert_command_match(/#{t.to_s}/, "log -l 1")
172
+
173
+ # Over-zealous verification never hurt anyone
174
+ assert_verify
175
+
176
+ # Switch to our child repo, so we can pull that new changeset!
177
+ exit_repo
178
+ enter_repo "newrepo"
179
+
180
+ # Pull! wooooo!
181
+ assert_command_match(/added 1 changesets/, "pull")
182
+ # Update it
183
+ update_result = run_amp_command "update"
184
+ # And check to see if the 2 things we did were both in the update
185
+ assert_match(/1 files updated/, update_result)
186
+ assert_match(/1 files removed/, update_result)
187
+
188
+ # Make sure that commands/annotate.rb was removed by the update
189
+ assert_false File.exist?(File.expand_path(File.join(Dir.pwd,"commands/annotate.rb")))
190
+
191
+ # ok, so right now, newrepo is the same as testrepo.
192
+ # now to generate a conflict, so we can test merging. we'll need a second child repo.
193
+ exit_repo
194
+ run_amp_command "clone #{"testrepo".fun_local} #{"conflictrepo".fun_local}"
195
+
196
+ # create one branch in conflictrepo
197
+ enter_repo "conflictrepo"
198
+ replace_resources_with_version "version5_1"
199
+ run_amp_command "status"
200
+ commit :message => "conflict, part 1"
201
+ exit_repo
202
+
203
+ # and create a conflicting branch in newrepo
204
+ enter_repo "newrepo"
205
+ remove_file_without_amp "commands/heads.rb"
206
+ replace_resources_with_version "version5_2"
207
+
208
+ # test addremove, while we're at it!
209
+ addremove_result = run_amp_command "addremove"
210
+ assert_match(/Adding commands\/newz.rb/, addremove_result)
211
+ assert_match(/Removing commands\/heads.rb/, addremove_result)
212
+ run_amp_command "status"
213
+ commit :message => "conflict, part 2"
214
+
215
+ # push our conflicting commit to testrepo from the "newrepo" child.
216
+ push_results = run_amp_command "push"
217
+ assert_match(/1 changeset/, push_results)
218
+ assert_match(/2 changes/, push_results)
219
+ assert_match(/2 files/, push_results)
220
+
221
+ exit_repo
222
+
223
+ # Ok, so conflictrepo wants to push its local commits, but they cross
224
+ # the branch that testrepo's at. So we'll need to pull newrepo's commit,
225
+ # merge, and then push.
226
+ enter_repo "conflictrepo"
227
+ # push should fail
228
+ assert_command_match(/new remote heads?/, "push")
229
+ # pull in newrepo's conflicting commit (it will yell at us for the extra head)
230
+ assert_command_match(/\+1 heads?/, "pull")
231
+ # Try to merge the 2 changesets
232
+ result = run_amp_command("merge")
233
+
234
+ # Expected results from the merge
235
+ assert_match(/1 files? unresolved/, result)
236
+ assert_match(/1 files? removed/, result)
237
+ assert_match(/1 files? updated/, result)
238
+
239
+ # Ok, so we have one file that conflicts: STYLE.txt. We want to keep conflictrepo's
240
+ # version of the file. So we'll suck out the local portion of the conflicted summary.
241
+ data = File.read("STYLE.txt")
242
+ vers1_groups = data.scan(/<<<<<<<.*?\n(.*?)=======/).first
243
+ File.open("STYLE.txt","w") {|f| f.write vers1_groups.first}
244
+
245
+ # mark STYLE.txt as resolved, and make sure it successfully was marked
246
+ resolve_result = run_amp_command("resolve", ["--mark", "STYLE.txt"])
247
+ assert_match(/STYLE.txt marked/, resolve_result)
248
+ assert_match(/resolved/, resolve_result)
249
+
250
+ # commit the branch merge
251
+ commit :message => "conflict resolved!"
252
+
253
+ # push to testrepo
254
+ run_amp_command "push"
255
+ assert_verify
256
+ # make sure we're still intact in conflictrepo
257
+
258
+ # let's go back to testrepo, and make sure our push was successful!
259
+ exit_repo
260
+ enter_repo "testrepo"
261
+
262
+ # did that push sparkle with testrepo?
263
+ assert_verify
264
+
265
+ # Test the copy command
266
+ run_amp_command("copy", ["-v", "STYLE.txt", "STYLE_copied.txt"])
267
+ assert_file_has_status "STYLE_copied.txt", :added
268
+ assert_equal File.read("STYLE.txt"), File.read("STYLE_copied.txt")
269
+
270
+ # Test the move command
271
+ run_amp_command("move", ["command.rb", "command_moved.rb"])
272
+ assert_false File.exist?("command.rb")
273
+ assert File.exist?("command_moved.rb")
274
+ assert_file_has_status "command.rb", :removed
275
+ assert_file_has_status "command_moved.rb", :added
276
+
277
+ # Test the "root" command
278
+ assert_command_match(/#{Dir.pwd}/, "root")
279
+
280
+ # We should be in the "default" branch right now.
281
+ assert_command_match(/default/, "branches")
282
+ assert_command_match(/default/, "branch")
283
+ # Let's change branches.
284
+ assert_command_match(/branch newbranch/, "branch", ["newbranch"])
285
+ assert_command_match(/newbranch/, "branch")
286
+
287
+ # Only 1 tag, which is the tip
288
+ result = run_amp_command("tags").split("\n")
289
+ result = result.select {|entry| entry =~ /[0-9a-f]{10}/}
290
+ assert_equal 1, result.size
291
+ assert_match(/tip/, result.first)
292
+
293
+ # Tag revision 3 as "noobsauce", by "medgar", with commit message "silly commit!"
294
+ run_amp_command("tag", ["noobsauce"], {:rev => 3, :user => "medgar", :message => "silly commit!"})
295
+
296
+ # Let's make sure our tag went in smoothly.
297
+ result = run_amp_command("tags").split("\n")
298
+ result = result.select {|entry| entry =~ /[0-9a-f]{10}/}
299
+ assert_equal 2, result.size
300
+
301
+ # Can't guarantee order, ruby 1.9 switches them, should investigate.
302
+ noobed = result.first =~ /noobsauce/ ? 0 : 1
303
+ tip = 1 - noobed
304
+
305
+ # First listed tag should be noobsauce:3
306
+ assert_match(/noobsauce/, result[noobed])
307
+ assert_match(/3/, result[noobed])
308
+ # second listed tag should be tip:9
309
+ assert_match(/tip/, result[tip])
310
+ assert_match(/9/, result[tip])
311
+
312
+ # And we should make sure the options were passed into the commit correctly.
313
+ head_result = run_amp_command("head")
314
+ assert_match(/medgar/, head_result)
315
+ assert_match(/silly commit!/, head_result)
316
+
317
+ # Commit that baby and make sure we're still rockin'.
318
+ commit :message => "moves and copies"
319
+ assert_verify
320
+
321
+ exit_repo
322
+ enter_repo 'testrepo'
323
+
324
+ # Create a dummy commit
325
+ File.open('used_in_bundle', 'w') {|f| f.write "monkay" }
326
+ amp "commit", :message => 'monkey'
327
+ assert_verify
328
+
329
+ # Create and compare bundles of ALL revisions
330
+ assert_amp_hg_bundle_same 'amp_bundle_all.bundle', :all => true
331
+
332
+ # Now go only up to the 3rd revision.
333
+ assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :rev => 3, :all => true
334
+
335
+ # We shall now test types 'none', 'bzip2', and 'gzip'
336
+ ['none', 'bzip2', 'gzip'].each do |type|
337
+ assert_amp_hg_bundle_same "bundle_up_to_7_with_type_#{type}.bundle",
338
+ :rev => 7, :type => type, :all => true
339
+ end
340
+
341
+ # Test making bundles with --base
342
+ assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :rev => 3, :base => 2
343
+ assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :base => 3
344
+ ensure
345
+ # cleanup
346
+ exit_repo
347
+ clean_dir "testrepo"
348
+ clean_dir "newrepo"
349
+ clean_dir "conflictrepo"
350
+ end
351
+
352
+ private ##################################
353
+
354
+ def assert_amp_hg_bundle_same(fname, opts={})
355
+ amp "bundle", ["amp_#{fname}"], opts
356
+ hg "bundle", ["hg_#{fname}"], opts
357
+ assert_files_are_same "amp_#{fname}", "hg_#{fname}"
358
+ ["amp_#{fname}", "hg_#{fname}"].each {|f| File.delete f }
359
+ end
360
+
361
+ ##
362
+ # Asserts that the repo is in perfect working order. This requires the
363
+ # hg binary, since we trust them above all when it comes to verifying our
364
+ # stuff. Fails if there are any integrity errors in our files.
365
+ def assert_verify
366
+ assert_command_no_match(/integrity errors/, "verify")
367
+ end
368
+
369
+ ##
370
+ #
371
+ def confirm_head_is_first_commit
372
+ heads_result = run_amp_command("heads")
373
+ assert_match(/changeset\: +0\:/, heads_result)
374
+ assert_match(/First commit\./, heads_result)
375
+ end
376
+
377
+ ##
378
+ # Asserts that a) heads returns the most recent revision, b) log -l 1 returns only
379
+ # one revision.
380
+ def confirm_head_equals_log_limit_one
381
+ assert_equal run_amp_command("heads").strip, run_amp_command("log -l 1").strip
382
+ end
383
+
384
+ ##
385
+ # Asserts that a) heads returns the most recent revision, b) tip returns the correct
386
+ # revision.
387
+ def confirm_head_equals_tip
388
+ assert_equal run_amp_command("heads").strip, run_amp_command("tip").strip
389
+ end
390
+
391
+ ##########################################
392
+ ## MAJOR HELPER METHODS
393
+ ###########################################
394
+
395
+ def add_file_ensure_added(source, dest=source)
396
+ copy_resource(source, dest)
397
+ assert_file "#{@current_repo}/#{dest}"
398
+ run_amp_command "add", dest
399
+
400
+ assert_file_is_added dest
401
+ end
402
+
403
+ def remove_file(source)
404
+ run_amp_command "remove", source
405
+ end
406
+
407
+ def assert_files_in_manifest(*files)
408
+ manifest_result = run_amp_command("manifest")
409
+ [*files].each do |file|
410
+ assert_match(/#{file}/, manifest_result)
411
+ end
412
+ end
413
+ alias_method :assert_file_in_manifest, :assert_files_in_manifest
414
+
415
+ def assert_file_is_added(file)
416
+ assert_file_has_status(file, :added)
417
+ end
418
+
419
+ def assert_file_is_removed(file)
420
+ assert_file_has_status(file, :removed)
421
+ end
422
+
423
+ def assert_files_are_same(file1, file2)
424
+ flunk "Tried to compare #{file1} but it doesn't exist" unless File.exist? file1
425
+ flunk "Tried to compare #{file2} but it doesn't exist" unless File.exist? file2
426
+
427
+ output1 = `md5 #{file1}`.strip.match(/MD5 (?:.+) = (.*)/)
428
+ output2 = `md5 #{file2}`.strip.match(/MD5 (?:.+) = (.*)/)
429
+ assert_equal output1[1], output2[1]
430
+ end
431
+
432
+ def assert_command_match(regex, command, args=[], opts={})
433
+ result = run_amp_command command, args, opts
434
+ assert_match regex, result
435
+ end
436
+
437
+ def assert_command_no_match(regex, command, args=[], opts={})
438
+ result = run_amp_command command, args, opts
439
+ assert_no_match regex, result
440
+ end
441
+
442
+ def assert_hg_command_match(regex, command, args=[], opts={})
443
+ result = run_hg_command command, args, opts
444
+ assert_match regex, result
445
+ end
446
+
447
+ def assert_hg_command_no_match(regex, command, args=[], opts={})
448
+ result = run_hg_command command, args, opts
449
+ assert_no_match regex, result
450
+ end
451
+
452
+ def assert_file_has_status(file, status)
453
+ stat_letter = case status
454
+ when :added
455
+ "A"
456
+ when :removed
457
+ "R"
458
+ when :unknown
459
+ "\\?"
460
+ when :ignored
461
+ "I"
462
+ when :clean
463
+ "C"
464
+ when :modified
465
+ "M"
466
+ end
467
+ status_result = run_amp_command "status", nil, status.to_sym => true, :hg => true, :"no-color" => true
468
+ assert_match(/#{stat_letter} #{file}/, status_result)
469
+ end
470
+
471
+ def commit(options = {})
472
+ run_amp_command "commit", [], options
473
+ end
474
+
475
+ ###########################################
476
+ # OTHER HELPER METHODS
477
+ ##########################################
478
+
479
+ def get_resource(file_name, version="")
480
+ File.read(File.join($current_basedir, "resources", version, file_name))
481
+ end
482
+
483
+ def replace_resources_with_version(version_string)
484
+ resource_folder = File.join($current_basedir, "resources", version_string)
485
+ list = Dir["#{resource_folder}/**/.*","#{resource_folder}/**/*"]
486
+ list.reject! do |a|
487
+ b = File.basename(a)
488
+ b == "." || b == ".."
489
+ end
490
+ list.each do |file|
491
+ unless File.directory?(file)
492
+ new_dest = File.join($current_basedir, @current_repo, file[(resource_folder.size+1)..-1])
493
+ File.copy(file, new_dest)
494
+ end
495
+ end
496
+ end
497
+
498
+ def options_hash_to_string(options = {})
499
+ opt_arr = []
500
+ options.each do |k, v|
501
+ case v
502
+ when Integer
503
+ opt_arr << "--#{k}=#{v}"
504
+ when TrueClass
505
+ opt_arr << "--#{k}"
506
+ else
507
+ opt_arr << "--#{k}=\"#{v}\""
508
+ end
509
+ end
510
+ opt_arr.join(" ")
511
+ end
512
+
513
+ ##
514
+ # Enters the given repository's working directory. Changes the program's working directory
515
+ # to the repo, so relative paths can be used
516
+ #
517
+ # @param [String] which_repo the name of the repository to enter. Must be a directory in the
518
+ # test/functional_tests directory.
519
+ def enter_repo(which_repo)
520
+ @current_repo = which_repo
521
+ Dir.chdir File.join($current_basedir, which_repo)
522
+ end
523
+
524
+ ##
525
+ # Exits the current repository (changes the program's current working directory)
526
+ def exit_repo
527
+ Dir.chdir $current_dir
528
+ end
529
+
530
+ ##
531
+ # Executes the given command using the amp binary. Backbone of the functional tests.
532
+ #
533
+ # @example
534
+ # run_amp_command(:commit, "STYLE.txt", :user => "seydar", :date => "1/1/2001")
535
+ # will run
536
+ # `amp commit --user="seydar" --date="1/1/2001" STYLE.txt`
537
+ #
538
+ # @param [String] command the command to execute
539
+ # @param [Array<String>] args the arguments to supply to the command.
540
+ # @param [Hash<#to_s => #to_s>] opts the options to pass to the command, such as :user => "seydar"
541
+ # for a commit command.
542
+ def run_amp_command(command, args = [], opts = {})
543
+ args = [args] unless args.kind_of?(Array)
544
+ %x(TESTING='true' && #{AMP_BINARY} #{command} #{options_hash_to_string(opts)} #{args.join(" ")})
545
+ end
546
+ alias_method :amp, :run_amp_command
547
+
548
+ ##
549
+ # Executes the given command using the hg binary (mercurial's binary). Used for when
550
+ # we don't trust amp's output (i.e. for "verify" - that'd be like grading your own math exam).
551
+ #
552
+ # @see run_amp_command
553
+ def run_hg_command(command, args = [], opts = {})
554
+ args = [args] unless args.kind_of?(Array)
555
+ %x(hg #{command} #{options_hash_to_string(opts)} #{args.join(" ")})
556
+ end
557
+ alias_method :hg, :run_hg_command
558
+
559
+ ##
560
+ # Copies a file, relative to "functional_tests/resources", to the destination, relative to
561
+ # the current repository's root. Creates any directories necessary to copy into the
562
+ # destination.
563
+ #
564
+ # @param [String] resource the path, relative to the resources root, of the file we wish
565
+ # to copy into the working directory
566
+ # @param [String] destination the destination, relative to the working repo's root, where
567
+ # we wish to move the file
568
+ def copy_resource(resource, destination)
569
+ # make sure the parent directories exist
570
+ FileUtils.makedirs File.dirname(File.join($current_basedir, @current_repo, destination))
571
+ File.copy(File.join($current_basedir, "resources", resource),
572
+ File.join($current_basedir, @current_repo, destination))
573
+ end
574
+
575
+ ##
576
+ # Removes a file, without using amp to mark it as removed from the working directory.
577
+ # This method allows us to use relative path names without keeping track of which
578
+ # repo we're in, as well.
579
+ #
580
+ # @param [String] file a path to a file (relative to the repo's root) we wish to delete.
581
+ def remove_file_without_amp(file)
582
+ File.unlink File.join($current_basedir, @current_repo, file)
583
+ end
584
+
585
+ ##
586
+ # Asserts that a file exists. Expects a path relative to the functional_tests directory.
587
+ #
588
+ # @param [String] file a path to a file relative to the functional_tests directory.
589
+ def assert_file(file)
590
+ assert File.exist?(file.fun_local)
591
+ rescue => e
592
+ puts "#{file.fun_local.inspect} does not exist!"
593
+ raise e # this kills e's backtrace
594
+ end
595
+
596
+ ##
597
+ # Destroys a directory. rm -rf, motherfuckers.
598
+ #
599
+ # @param [String] file the directory to completely erase
600
+ def clean_dir(file)
601
+ FileUtils::rm_rf file.fun_local
602
+ end
603
+
604
+ end