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,121 @@
1
+ require "test/unit"
2
+ require 'fileutils'
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
4
+
5
+ class TestLocalRepo < Test::Unit::TestCase
6
+ REPO_PATH = File.expand_path(File.join(File.dirname(__FILE__)))
7
+ EXISTING_REPO_PATH = File.expand_path(File.join(File.dirname(__FILE__), "testrepo"))
8
+
9
+ def setup
10
+ @config = Amp::AmpConfig.new
11
+ @repo = Amp::Repositories::LocalRepository.new(EXISTING_REPO_PATH, false, @config)
12
+ end
13
+
14
+ def join(*args)
15
+ File.join(REPO_PATH, *args)
16
+ end
17
+
18
+ def hg_join(*args)
19
+ File.join(REPO_PATH, ".hg", *args)
20
+ end
21
+
22
+ def teardown
23
+ FileUtils.rm_rf join(".hg")
24
+ end
25
+
26
+ def test_create_repo
27
+ Amp::Repositories::LocalRepository.new(REPO_PATH, true, @config)
28
+ assert File.directory?(join(".hg"))
29
+ assert File.exists?(hg_join("00changelog.i"))
30
+ assert File.exists?(hg_join("requires"))
31
+ assert File.directory?(hg_join("store"))
32
+ assert_file_contents hg_join("requires"),"revlogv1\nstore\nfncache\n"
33
+ end
34
+
35
+ def test_open_existing_repo
36
+ assert_not_nil @repo
37
+ end
38
+
39
+ def test_get_initial_changeset
40
+ changeset = @repo[0]
41
+ assert_equal Amp::Changeset, changeset.class
42
+ end
43
+
44
+ def test_repo_size
45
+ assert_equal 4, @repo.size
46
+ end
47
+
48
+ def test_initial_changeset_manifest
49
+ changeset = @repo[0]
50
+ # manifest check
51
+ expected_list = ["readme","silly/code"]
52
+ actual = []
53
+ changeset.each do |k,v|
54
+ actual << k
55
+ end
56
+ assert_equal expected_list.sort, actual.sort
57
+ end
58
+
59
+ def test_initial_readme
60
+ changeset = @repo[0]
61
+
62
+ changeset.manifest.inspect # force load of manifest
63
+
64
+ file = changeset["readme"]
65
+ # data check on a file
66
+ expected_readme = "this is the readme. I hope you like it.\nAmp is "+
67
+ "totally sweet. We're gonna do awesome stuff.\nI hope "+
68
+ "you lik it.\n"
69
+
70
+ expected = expected_readme
71
+ actual = file.data
72
+ assert_equal expected, actual
73
+
74
+ expected = Zlib::Deflate.deflate(file.data).size
75
+ actual = file.size # compressed size
76
+ assert_equal expected, actual
77
+
78
+ assert_false file.cmp(expected_readme)
79
+ end
80
+
81
+ def test_second_readme
82
+ expected_readme = "this is the readme. I hope you like it.\nAmp is "+
83
+ "totally sweet. We're gonna do awesome stuff.\nI hope "+
84
+ "you like it.\n" # typo fixed
85
+ changeset = @repo[1]
86
+ changeset.manifest # force load of manifest
87
+ file = changeset["readme"]
88
+
89
+ expected = expected_readme
90
+ actual = file.data
91
+ assert_equal expected, actual
92
+ end
93
+
94
+ def test_status
95
+
96
+ actual = @repo.status(:ignored => true, :clean => true, :unknown => true,
97
+ :node_1 => @repo["."].node, :node_2 => nil)
98
+
99
+
100
+
101
+ modified = ["readme"]
102
+ clean = ["emptyfile", "fileididcopy", "silly/code", "silly/ignoredfile"]
103
+ ignored = ["silly/unknownfile"]
104
+ unknown = [".hgignore"]
105
+ added = []
106
+ deleted = []
107
+ removed = []
108
+ expected = { :modified => modified.sort,
109
+ :added => added.sort,
110
+ :removed => removed.sort,
111
+ :deleted => deleted.sort,
112
+ :unknown => unknown.sort,
113
+ :ignored => ignored.sort,
114
+ :clean => clean.sort ,
115
+ :delta => 19
116
+ }
117
+
118
+ assert_equal expected, actual
119
+
120
+ end
121
+ end
@@ -0,0 +1,72 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
3
+
4
+
5
+
6
+ class TestManifest < Test::Unit::TestCase
7
+
8
+ def setup
9
+ opener = Amp::Opener.new(File.dirname(__FILE__))
10
+ opener.default = :open_file
11
+ @manifest = Amp::Manifest.new(opener)
12
+ end
13
+
14
+ def test_load_manifest
15
+ assert_not_nil @manifest
16
+ end
17
+
18
+ def test_manifest_read_delta
19
+ result = @manifest.read_delta(@manifest.node(8))
20
+ expected = {"test/test_bdiff.rb" => "P\xa1\x85\x8b\xe6\xc6N\xb6\xf3\x92MuIv\xe1|u\x03\xadM",
21
+ "test/test_mpatch.rb"=> "\xd2c\xcf\x03\xea\x86\x9b:\xa7\xba\xd8\x80\xcf\xad\x7f\xed\xfc\x07\xd9\xd6"}
22
+ assert_equal expected, result
23
+ result = @manifest.read_delta(@manifest.node(21))
24
+ expected = {"lib/revlogs/revlog.rb" => ".\x9e~-\xa6y~\xb8\xd9\xb3\xd5\xe8\xd2tB\xb6\x1d\xbc\x9f:",
25
+ "lib/revlogs/index.rb" => "\xaa.4\x97\x874g\xb9\xeb\\\x93\x96\x0c\xf8\x9f<\xea\xe9\xae\x16",
26
+ "lib/commands/command.rb" => "\xf4,\xaa\xf6\xcb\xb1\t\x88\x89\x0f\xd3d\x9d\xb2rQ\x9c!\xf1\x9a",
27
+ "lib/revlogs/node.rb" => "$&gv\x82{g\xe8Q\xcc$\x0f\x0eh\xdd\x1e\xf5\xba\xc66",
28
+ "lib/revlogs/revlog_support.rb" => "\xf2\x8b\xe7\xfa\xd4\x04l\xae\xb6\xdf\x82h\xeaW\xc3XLY\xbc/"}
29
+ assert_equal expected, result
30
+ end
31
+
32
+ def test_manifest_read
33
+ result = @manifest.read(@manifest.node(8))
34
+ expected = {"lib/encoding/bdiff.rb" => "\x8c:\xc9\x1e\xd3\xdaa\xc3'\xbd\xfbF\xd4\xcfs\r\xe4\x936`",
35
+ "test/test_bdiff.rb" => "P\xa1\x85\x8b\xe6\xc6N\xb6\xf3\x92MuIv\xe1|u\x03\xadM",
36
+ "test/test_amp.rb" => "\x02\xf9k_3\xfe\xf7\x8b\x0e\x96\x99\xcd\xc4\xac\xa0\xee\x9e\xd5{\x10",
37
+ "Manifest.txt" => "\xf0H4jr\x1eS\x13u\x89,\xa1d\x92\xee*\x87z\x97\xf8",
38
+ "test/test_difflib.rb" => "\xba\x96\xa4r\x0b\xc0@\x16.\xc9!\xe8\x90s\x9c\x97\\\xd2c\xc7",
39
+ "lib/commands/dispatch.rb" => "~\x04\xe7H\xc4\xfc\x1b@\xee\xde\xe6\xdd\x04\x00\xde\x12\\,$\xfb",
40
+ "lib/encoding/difflib.rb" => "\xf8\x0b\x08\xf2!\x13\x81#\x87\x94\x1e/\x11\xcf\x05\x95K7\xf2\x05",
41
+ "lib/repository/repository.rb" => "\x7f\xac\xdc\x9e$\x8b\x1f\xba\xb9\xc9'\xa2\x0c$h\x8d2\xe6/\xc0",
42
+ "README.txt" => "\n0\xba\xf2\x99\x9c\xe8\n\xa7Wee\xc7\x9c\x8a\x11\x98\xc3\x7f\xa8",
43
+ "lib/commands/command.rb" => "\x84\x92\xae6Dsd\x10\x8b`\x90\x17\xcc\x07\xe0\x06\x0f\xb6L\xe6",
44
+ "History.txt" => "\xe1\x1e\x1f\x90\x96\x10\x0e\x8c\xc0X\x07`\x19\xbcf\x96\x96\x91\x84<",
45
+ "test/test_base85.rb" => "\xf5\x12\xce4C\x08pd;\x13s\xfcub!\xd7\xb0\xff\xc3\xe2",
46
+ "bin/amp" => "\xebG\xef\x04^y\xaa\xd8\xdc\x1ex\xbe\xb2\xc5\x8c\x01\x87\x84(~",
47
+ "lib/encoding/base85.rb" => "\x89\xda\xc14\x9f\x9b\x84\xad\xcf'\xd4\xe0|-\xf3\x04\x97\xebz\xdf",
48
+ "Rakefile" => "h\xf3\xab\x8e\xf2pu\xff\xa9\x9e\x94\x8et\xb7E\x1f\xb8\xee2\xfa",
49
+ "lib/commands/builtin_commands.rb" => "e\xe1\rR@sq\xcd\xf5\xd0\xde'\x99\xd01E\x04V\x9e1",
50
+ "jolts.rb" => "\xce\x96yL\x06J\xd8\xba\x93g=o\xf8P\x88-I\x1d\xb7\xc9",
51
+ "test/test_mpatch.rb" => "\xd2c\xcf\x03\xea\x86\x9b:\xa7\xba\xd8\x80\xcf\xad\x7f\xed\xfc\x07\xd9\xd6",
52
+ "lib/encoding/mpatch.rb" => "~\xadi\x7f\xb7i[\x17s\xa0\xa3\xd7E\x1c\xf0L4]\xb44",
53
+ "lib/amp.rb" => "\xfe\xf3\xcd\x96C\xca\\9\n\xb7\xfcE\xd0\xb8f\x14\rC*\xc6",
54
+ "lib/support/support.rb" => "A\x90\x8a\xe9\xdb3M\xbb\xaa\x15G\xdf \xfe\xee\xc8\xfdw\xdds",
55
+ ".hgignore" => "~^\xb1WH\xf1\x9f\xee\xde\xb0@\xf3\xdc\xf3\xe57\xab\xaa\xc4\x9d"}
56
+ assert_equal expected, result
57
+ end
58
+
59
+ def test_manifest_find
60
+ result = @manifest.find(@manifest.node(8), "lib/encoding/bdiff.rb")
61
+ expected = ["\x8c:\xc9\x1e\xd3\xdaa\xc3'\xbd\xfbF\xd4\xcfs\r\xe4\x936`", '']
62
+ assert_equal expected, result
63
+
64
+ result = @manifest.find(@manifest.node(21), "lib/support/support.rb")
65
+ expected = ["\x14|~9\xad\x1c\x1a5\xbe\xff\xcb\x81\x11J\xd6\x89g\xe2EK", '']
66
+ assert_equal expected, result
67
+
68
+ result = @manifest.find(@manifest.node(44), "lib/support/ruby_19_compatibility.rb")
69
+ expected = ["\xa3d\xd7?g\xb4p\xa6\xe2\xbd\xf9\x97P\x97.\xbb\x8f{\xd4\x05", '']
70
+ assert_equal expected, result
71
+ end
72
+ end
@@ -0,0 +1,10 @@
1
+ First line
2
+ second line
3
+ third line
4
+ fourth line
5
+ fifth line
6
+ sixth line
7
+ seventh line
8
+ eighth line
9
+ ninth line
10
+ tenth line
@@ -0,0 +1,16 @@
1
+ First line
2
+ second line
3
+ third line
4
+ 3 1/2th line
5
+ fourth line
6
+ fifth line
7
+ sixth line
8
+ <<<<<<< local
9
+ seventh line MODIFIED
10
+ =======
11
+ seventh line CHANGED
12
+ >>>>>>> other
13
+ eighth line
14
+ ninth line
15
+ 9 1/2th line
16
+ tenth line
@@ -0,0 +1,11 @@
1
+ First line
2
+ second line
3
+ third line
4
+ 3 1/2th line
5
+ fourth line
6
+ fifth line
7
+ sixth line
8
+ seventh line MODIFIED
9
+ eighth line
10
+ ninth line
11
+ tenth line
@@ -0,0 +1,11 @@
1
+ First line
2
+ second line
3
+ third line
4
+ fourth line
5
+ fifth line
6
+ sixth line
7
+ seventh line CHANGED
8
+ eighth line
9
+ ninth line
10
+ 9 1/2th line
11
+ tenth line
@@ -0,0 +1,26 @@
1
+ require "test/unit"
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
3
+
4
+ class TestMerge < Test::Unit::TestCase
5
+ TEST_BASE = File.expand_path(File.join(File.dirname(__FILE__), 'base.txt'))
6
+ TEST_LOCAL = File.expand_path(File.join(File.dirname(__FILE__), 'local.txt'))
7
+ TEST_REMOTE = File.expand_path(File.join(File.dirname(__FILE__), 'remote.txt'))
8
+ TEST_EXPECTED = File.expand_path(File.join(File.dirname(__FILE__), 'expected.local.txt'))
9
+ TEST_OUT = File.expand_path(File.join(File.dirname(__FILE__), 'local.txt.out'))
10
+ TEST_BACKUP = File.expand_path(File.join(File.dirname(__FILE__), 'local.txt.bak'))
11
+
12
+ def test_full_merge
13
+ File.copy TEST_LOCAL, TEST_BACKUP
14
+
15
+ # kill the error output...
16
+ old, $stderr = $stderr, StringIO.new
17
+ Amp::Merges::ThreeWayMerger.three_way_merge(TEST_LOCAL, TEST_BASE, TEST_REMOTE,
18
+ :labels => ["local","other"])
19
+ $stderr = old # and reassign
20
+
21
+ File.move TEST_LOCAL , TEST_OUT
22
+ File.move TEST_BACKUP, TEST_LOCAL
23
+ assert_equal File.read(TEST_EXPECTED), File.read(TEST_OUT)
24
+ end
25
+
26
+ end
@@ -0,0 +1,333 @@
1
+ # -*- coding: us-ascii -*-
2
+
3
+ require "test/unit"
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
5
+
6
+ class TestRevlog < Test::Unit::TestCase
7
+ TEST_REVLOG_INDEX = "testindex.i"
8
+
9
+ def setup
10
+ opener = Amp::Opener.new(File.expand_path(File.dirname(__FILE__)))
11
+ opener.default = :open_file # for testing purposes!
12
+ @revlog = Amp::Revlog.new(opener, TEST_REVLOG_INDEX)
13
+ end
14
+
15
+ def test_load_revlog
16
+ assert_not_nil @revlog
17
+ assert_equal(TEST_REVLOG_INDEX[0..-3] + ".d", @revlog.data_file)
18
+ end
19
+
20
+ def test_revlog_tip
21
+ result = @revlog.tip
22
+ expected = "|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"
23
+ assert_equal expected, result
24
+ end
25
+
26
+ def test_revlog_size
27
+ result = @revlog.size
28
+ expected = 51
29
+ assert_equal expected, result
30
+ end
31
+
32
+ def test_revlog_node_id_for_index
33
+ result = @revlog.node_id_for_index 10
34
+ expected = "\xf8`\x8b/\x1dR\xa2\xaf\x0c\x10M\x89y\xf7,\xdc\xfd6\xaaI"
35
+ assert_equal expected, result
36
+ result = @revlog.node_id_for_index 40
37
+ expected = "\x03\xb2\xdd\x03\x8b\xc7\x9cDaA\xb8\xbd\xebg\xcc\x18\x06\x91A\xf0"
38
+ assert_equal expected, result
39
+ result = @revlog.node_id_for_index 51
40
+ expected = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
41
+ assert_equal expected, result
42
+ end
43
+
44
+ def test_revlog_revision_index_for_node
45
+ result = @revlog.revision_index_for_node "\xf8`\x8b/\x1dR\xa2\xaf\x0c\x10M\x89y\xf7,\xdc\xfd6\xaaI"
46
+ expected = 10
47
+ assert_equal expected, result
48
+ result = @revlog.revision_index_for_node "\x03\xb2\xdd\x03\x8b\xc7\x9cDaA\xb8\xbd\xebg\xcc\x18\x06\x91A\xf0"
49
+ expected = 40
50
+ assert_equal expected, result
51
+ result = @revlog.revision_index_for_node "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
52
+ expected = -1
53
+ assert_equal expected, result
54
+ end
55
+
56
+ def test_revlog_link_revision_for_index
57
+ result = @revlog.link_revision_for_index 22
58
+ expected = 22
59
+ assert_equal expected,result
60
+ result = @revlog.link_revision_for_index 40
61
+ expected = 40
62
+ assert_equal expected,result
63
+ result = @revlog.link_revision_for_index 1
64
+ expected = 1
65
+ assert_equal expected,result
66
+ end
67
+
68
+ def test_revlog_base_revision_for_index
69
+ result = @revlog.base_revision_for_index 1
70
+ expected = 0
71
+ assert_equal expected,result
72
+ result = @revlog.base_revision_for_index 10
73
+ expected = 7
74
+ assert_equal expected,result
75
+ result = @revlog.base_revision_for_index 50
76
+ expected = 48
77
+ assert_equal expected,result
78
+ end
79
+
80
+ def test_revlog_parents_for_node
81
+ result = @revlog.parents_for_node "\xf8`\x8b/\x1dR\xa2\xaf\x0c\x10M\x89y\xf7,\xdc\xfd6\xaaI"
82
+ expected = ["\xd1\x818?\xc0*\xdf\xe4r\x13\x00\x95T\xf5\xbb\xf9\x84k\xc8\x1c", "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"]
83
+ assert_equal expected,result
84
+ result = @revlog.parents_for_node "\x03\xb2\xdd\x03\x8b\xc7\x9cDaA\xb8\xbd\xebg\xcc\x18\x06\x91A\xf0"
85
+ expected = ["\x8cL\x01\nU#7\x1d\x1c5\xfb\x9b,vM\xbe\x80\x862M", "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"]
86
+ assert_equal expected,result
87
+ result = @revlog.parents_for_node "` \xf6W_\xab\xf9+es-Ee\x14\xff\x1d\xf4\xf5\xd7\xfb"
88
+ expected = ["\x01\x0c\\\xbe\x1ea\xc3\xcfu\xeeM\xfa\xfc#\xd0\x87%\xb2\x9bA", "\xd84l\x9e\x04\xe1s0\x1e2T\x98f\"&\xa2\xd9\xad\xc5\x7f"]
89
+ assert_equal expected,result
90
+ end
91
+
92
+ def test_revlog_parent_indices_for_index
93
+ result = @revlog.parent_indices_for_index 24
94
+ expected = [23, -1]
95
+ assert_equal expected,result
96
+ result = @revlog.parent_indices_for_index 25
97
+ expected = [24, 21]
98
+ assert_equal expected,result
99
+ result = @revlog.parent_indices_for_index 26
100
+ expected = [22, 25]
101
+ assert_equal expected,result
102
+ end
103
+
104
+ def test_revlog_data_start_for_index
105
+ result = @revlog.data_start_for_index 42
106
+ expected = 6995
107
+ assert_equal expected,result
108
+ result = @revlog.data_start_for_index 7
109
+ expected = 1335
110
+ assert_equal expected,result
111
+ result = @revlog.data_start_for_index 35
112
+ expected = 5810
113
+ assert_equal expected,result
114
+ end
115
+
116
+ def test_revlog_data_length_for_index
117
+ result = @revlog.data_size_for_index 42
118
+ expected = 95
119
+ assert_equal expected,result
120
+ result = @revlog.data_size_for_index 7
121
+ expected = 128
122
+ assert_equal expected,result
123
+ result = @revlog.data_size_for_index 35
124
+ expected = 122
125
+ assert_equal expected,result
126
+ end
127
+
128
+ def test_revlog_data_end_for_index
129
+ result = @revlog.data_end_for_index 42
130
+ expected = 7090
131
+ assert_equal expected,result
132
+ result = @revlog.data_end_for_index 7
133
+ expected = 1463
134
+ assert_equal expected,result
135
+ result = @revlog.data_end_for_index 35
136
+ expected = 5932
137
+ assert_equal expected,result
138
+ end
139
+
140
+ def test_revlog_reachable
141
+ result = @revlog.reachable_nodes_for_node "|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"
142
+ expected = {"\x82\x8b\xd3\x98\xea\xcb\rq\xf1\xb1\xdbg\xe8\xbe!(\x19\x1f\x9d\x93" => true,
143
+ "\x87\x16\xac\xec?\xd2{\xc5\xba\xa9\n\x8d\x82\xf5\x9e\xa5\xd2<+Z" => true,
144
+ "\xfb\x7f\xe6*\x92\x0e\xb9!\xd6\x10\x06(\xf98&\xd6\x90\x06\xc23" => true,
145
+ "\x19}\xe0X\xf7\x90\xf6\x88\xcf\x06\x95E\x13ym\xde=msk" => true,
146
+ "\x9c\x91\xd9\xb1\xec\xf4L/\x16\xaf=\xc9&\x14\xad.v\xaf\xce\\" => true,
147
+ "\xce\x10\x8a<\xb8%\x90T\x19+R1\xe4\x7f\xd5J\\\xf9\xe0\x81" => true,
148
+ "I\xde:;7\x16\xfaK\x02\xdb\xbf0\xb5(c\xd8\xf6\xfe\x80\x08" => true,
149
+ "\x99\xc5\xf6\xcb|6f\xca\xc1\xc6\xae\x86\xe9\xda\x1e\xf2\xcf\xee\xf9\xe8" => true,
150
+ "!i2I7$A\xfe\xe9\x80G\xbe\xa7\xb50Mb\\\x89\x0e" => true,
151
+ "\x8cL\x01\nU#7\x1d\x1c5\xfb\x9b,vM\xbe\x80\x862M" => true,
152
+ "\xf9`\xd4\xdcQ\x1c`\x0c\xc0\x10\xa2\xeb\x81\xe4:\xae,\x81\x1f\xa3" => true,
153
+ "co\xac\xbd\x02\xfb\xdc\xd5\x93\x16\x9a\xb5\xa3\x9ep}R\xe9\xa7\x19" => true,
154
+ "g\xf4t-\xcc|w\xc01v\x80JH\x93\x05\xaa\x07\x13F\xe1" => true,
155
+ "\x0b\xf3\x81\\\xe1k\x19\x14Qa\xbah|\xa4?\xfa\xb4\xa4VH" => true,
156
+ "W5\xbe\xb7n\xfdd\xa4nn\x14\x0b\xc6\xf1\xbf\xee\x8e\x92\xeeF" => true,
157
+ "\x14\x07T\xfb\xc4\xdc\x88\xb7\xb3\x13\xb2\x9e-\xd4\xe87\xb8X+B" => true,
158
+ "_\xf7\xf8\xdd\xfd\xfa\xda1\xe0\x97\x96\xa1\\\xe0g\xe1}p\x1bn" => true,
159
+ "\x1fZd\xa4\xc7\xb8V\xcaK@b\xc3\x7f{YD\xd1:{\xb6" => true,
160
+ "\xd0D\x9a\x99h\x06\"\x9e\x16C\x89F\xa4\xff\xf1\xa0N\xcaj\xc6" => true,
161
+ "R\xed\x19\x93\r\xcd\xb2\xc6b|J\x89\xf7\xa7% E\xfa}\xe9" => true,
162
+ "\x03\xb2\xdd\x03\x8b\xc7\x9cDaA\xb8\xbd\xebg\xcc\x18\x06\x91A\xf0" => true,
163
+ "\xc0t\xcf\x9a%p{\xe4X\xbb.+\xa0\xbe\xf5\x99\x1a\xc7{\xde" => true,
164
+ "E \xc3\xc6\xcc\x99\x91\x01H\xfe\x95s\xc4I@\xafrW$\xa1" => true,
165
+ "\x12>\xf0\x91W\x88 \x8d\xf8\xb3\xa2<{\xed \x90\xe1\x9b\x0e\xda" => true,
166
+ "vO\x00\x85\x19\x968\xc0\x9b\x80\x9a\xec*\x9c\x12\xcd\xd9\x15\xf1\xee" => true,
167
+ "#.9\xc3f\xec\x9b\t\x96\xffqKz3<\x16\x9a\x95\x11\x1d" => true,
168
+ "C\xfe\xec\xf2\x8fL\xb3\x95\xb5\x8d\x1f\xb1\xbc\xc7Y\xfe\xae\xf5;=" => true,
169
+ "\xa0\x89\xde\xcd\x9bt\x98\xdc\xf9\x0c#,XZ\xc0\xc8\xeb\xa6/\xd4" => true,
170
+ "\x8fR$g\xcc!l\xfe\xa4\xc7\xe5\x87G\xd3\xe75!g\xa5_" => true,
171
+ "\xef%\xc7Z\x0co\x08B\xed\x80\x98\t\x18)\xecj\x1c\x9b\x9b\x94" => true,
172
+ "\xf7>6\xc4=\xe3\xe8$\x08\x9b\x87\x95P\x1c\xbe\\4\xfa\xed\xce" => true,
173
+ "\x01\x0c\\\xbe\x1ea\xc3\xcfu\xeeM\xfa\xfc#\xd0\x87%\xb2\x9bA" => true,
174
+ ")\xc1\xc5r\xbc\x10\x86\xdc\xf2:\xca\xda\xe5i\x7f\xb6\x1c\x14i1" => true,
175
+ "\xb0\x94\xcc,\\\xacY\x87\xa4\x9a1\xbc\x88jM\xafM\xd3\xd0\xee" => true,
176
+ "s\xc3\x8dK\xcb\xe9\x93\xd1\x8a\xf2\xe4\xc8\xc3f\xd1J\xe8\x8c\xeaZ" => true,
177
+ "\x08\xe9\x07^\x1d\x9a\xed|\xb2QC\xd6\x8a\xd9:@\xf2\xdcT$" => true,
178
+ "|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02" => true,
179
+ "\x18\xac\x85\x85q\x01Z\x85\x0ff\x1b\x9c\xc1hM\x1cX\xcd\x9b\xa7" => true,
180
+ "` \xf6W_\xab\xf9+es-Ee\x14\xff\x1d\xf4\xf5\xd7\xfb" => true,
181
+ "o(\xef\xc0\xe3(\xbdP6=P\xd7!\xa4a$\x10\x1a\xce\xc4" => true,
182
+ "\x02\x8c\xfb\xa9\x16\xb1&\xa7\x04\xa0\xfezr\x8d5\x9b\x1c2\xacv" => true,
183
+ "\x1e\x0eA+q\xa0\x16cm\xe2\xc8\xa1\xbfJ\xfb\r\x15,\xd3*" => true,
184
+ "\xd1\x818?\xc0*\xdf\xe4r\x13\x00\x95T\xf5\xbb\xf9\x84k\xc8\x1c" => true,
185
+ "\n\xb7\xdc\x9b\x80l-lWGK?\x8a\x9dxq\xef\xdf&@" => true,
186
+ "\x07?\xae0\xaa`\xec\x97x=\x7f\x95 \xbc\x1c\x0e\x16\xe4\xe1\xe8" => true,
187
+ "\xe2\xeaP\x89\x1b\xa7\xc9\x03H\x0fh\xc4f\xd8\xd8w\xa8\xf9\xd3\xb6" => true,
188
+ "\xf5\xd0fy\x11\xe1\xf9\xfc\xe1\xb9\x9e\xc4Gp\x00\xcd\xb5\xa4*\xcc" => true,
189
+ "\t\xb2\x0f\xe5\xc2\xba\x1a\xa9>\xb0#\x8c\x85l\x0e\xb6\x18\xc1s\xcb" => true,
190
+ "\xd84l\x9e\x04\xe1s0\x1e2T\x98f\"&\xa2\xd9\xad\xc5\x7f" => true,
191
+ "\x87\xb9\x16\xc6\xb9\xafF\x8b\xa8\x99,g\xca]\x9a\xc9g\xe5^\x94" => true,
192
+ "\xf8`\x8b/\x1dR\xa2\xaf\x0c\x10M\x89y\xf7,\xdc\xfd6\xaaI" => true}
193
+ expected.each do |k, v|
194
+ unless result.keys.include? k
195
+ flunk
196
+ end
197
+ end
198
+ assert true
199
+ end
200
+
201
+ def test_revlog_ancestors
202
+ result = @revlog.ancestors([10]).to_a.sort
203
+ expected = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
204
+ assert_equal expected, result
205
+ end
206
+
207
+ def test_revlog_descendants
208
+ result = @revlog.descendants([30]).to_a.sort
209
+ expected = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
210
+ assert_equal expected, result
211
+ end
212
+
213
+ def test_revlog_heads
214
+ result = @revlog.heads.to_a.sort
215
+ expected = ["|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"]
216
+ assert_equal expected, result
217
+ end
218
+
219
+ def test_revlog_between
220
+ result = @revlog.nodes_between(["\xc0t\xcf\x9a%p{\xe4X\xbb.+\xa0\xbe\xf5\x99\x1a\xc7{\xde"],
221
+ ["|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"])
222
+ expected = {:between => ["\xc0t\xcf\x9a%p{\xe4X\xbb.+\xa0\xbe\xf5\x99\x1a\xc7{\xde", "\xfb\x7f\xe6*\x92\x0e\xb9!\xd6\x10\x06(\xf98&\xd6\x90\x06\xc23", "\x1e\x0eA+q\xa0\x16cm\xe2\xc8\xa1\xbfJ\xfb\r\x15,\xd3*", "|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"],
223
+ :roots => ["\xc0t\xcf\x9a%p{\xe4X\xbb.+\xa0\xbe\xf5\x99\x1a\xc7{\xde"],
224
+ :heads => ["|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"]}
225
+ assert_equal expected, result
226
+ end
227
+
228
+ def test_revlog_children
229
+ result = @revlog.children("` \xf6W_\xab\xf9+es-Ee\x14\xff\x1d\xf4\xf5\xd7\xfb")
230
+ expected = ["\xb0\x94\xcc,\\\xacY\x87\xa4\x9a1\xbc\x88jM\xafM\xd3\xd0\xee"]
231
+ assert_equal expected, result
232
+ end
233
+ def test_revlog_id_match
234
+ result = @revlog.id_match("` \xf6W_\xab\xf9+es-Ee\x14\xff\x1d\xf4\xf5\xd7\xfb")
235
+ expected = "` \xf6W_\xab\xf9+es-Ee\x14\xff\x1d\xf4\xf5\xd7\xfb"
236
+ assert_equal expected, result
237
+ result = @revlog.id_match(5)
238
+ expected = "\xf5\xd0fy\x11\xe1\xf9\xfc\xe1\xb9\x9e\xc4Gp\x00\xcd\xb5\xa4*\xcc"
239
+ assert_equal expected, result
240
+ end
241
+
242
+ def test_revlog_partial_match
243
+ result = @revlog.partial_id_match("7c03fe1439812bcc35a397942a49e2b954a9ac")
244
+ expected = "|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"
245
+ assert_equal expected, result
246
+ end
247
+
248
+ def test_revlog_lookup_id
249
+ result = @revlog.lookup_id("` \xf6W_\xab\xf9+es-Ee\x14\xff\x1d\xf4\xf5\xd7\xfb")
250
+ expected = "` \xf6W_\xab\xf9+es-Ee\x14\xff\x1d\xf4\xf5\xd7\xfb"
251
+ assert_equal expected, result
252
+ result = @revlog.lookup_id(5)
253
+ expected = "\xf5\xd0fy\x11\xe1\xf9\xfc\xe1\xb9\x9e\xc4Gp\x00\xcd\xb5\xa4*\xcc"
254
+ assert_equal expected, result
255
+ result = @revlog.lookup_id("7c03fe1439812bcc35a397942a49e2b954a9ac")
256
+ expected = "|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"
257
+ assert_equal expected, result
258
+ end
259
+
260
+ def test_revlog_cmp
261
+ str = "273f0c435892dea22da8ef93a44ebcacc797b7c3\nmichaeledgar@michael-edgars-macbook-pro.local\n1238527096 " +
262
+ "14400\nlib/revlogs/revlog.rb\nlib/revlogs/revlog_support.rb\nlib/support/support.rb\n\ntweaked to use "+
263
+ ".null? and .not_null?\n\nari... lol... node_ids are strings, so putting .null? on the Numeric class wasn't"+
264
+ " the way to go ;-)"
265
+ node = "|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02"
266
+ assert_equal false, @revlog.cmp(node, str)
267
+ end
268
+
269
+ def test_revlog_get_chunk
270
+ result = @revlog.get_chunk 3
271
+ expected = "\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)2ac51d136ec922ba54cb149dfcdcbd9a17253ab0\n\x00\x00\x00W\x00\x00"+
272
+ "\x00h\x00\x00\x00/1238272471 14400\nManifest.txt\nbin/amp\njolts.rb\n\x00\x00\x00s\x00\x00\x00\xd0\x00\x00"+
273
+ "\x00\\lib/commands/dispatch.rb\nlib/encoding/bdiff.rb\nlib/encoding/difflib.rb\ntest/test_difflib.rb\n\x00"+
274
+ "\x00\x00\xd1\x00\x00\x00\xec\x00\x00\x00yadded difflib port, added binary diff class (which mercurial-diff "+
275
+ "uses)\nadded jolts.rb - which is the Rakefile, basically"
276
+ assert_equal expected, result
277
+ end
278
+
279
+ def test_revlog_revision_diff
280
+ result = @revlog.revision_diff 4,5
281
+ expected = "\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)e7cebf6558e7de50f9afa223ce13262afcc296a1\n\x00\x00\x00W\x00\x00\x00"+
282
+ "h\x00\x00\x00\x1b1238296608 14400\n.hgignore\n\x00\x00\x00q\x00\x00\x00q\x00\x00\x00\x93lib/commands/command.rb"+
283
+ "\nlib/commands/dispatch.rb\nlib/encoding/base85.rb\nlib/encoding/bdiff.rb\nlib/encoding/difflib.rb\nlib/repository"+
284
+ "/repository.rb\n\x00\x00\x00\x89\x00\x00\x00\xd9\x00\x00\x00PButtload of documentation. Added an .hgignore to avoid"+
285
+ " the docs being versioned."
286
+ assert_equal expected, result
287
+ end
288
+ def test_revlog_decompress_revision
289
+ result = @revlog.decompress_revision "\xc0t\xcf\x9a%p{\xe4X\xbb.+\xa0\xbe\xf5\x99\x1a\xc7{\xde"
290
+ expected = "6a3d4041fc19b7d64ce9f2567ea4564cb1106594\nmichaeledgar@michael-edgars-macbook-pro.local\n1238480134 "+
291
+ "14400\nlib/encoding/mdiff.rb\ntest/test_mdiff.rb\n\nmore interesting testing revealed bugs in mercurial"+
292
+ " diff. they're fixed with hacks. test in for a complex unified diff!"
293
+ assert_equal expected, result
294
+ end
295
+ def test_revlog_add_revision
296
+ cmp_file = "./test/revlog_tests/revision_added_changelog.i"
297
+ new_file = "./test/revlog_tests/test_adding_index.i"
298
+ opener = Amp::Opener.new(".")
299
+ opener.default = :open_file
300
+ newrevlog = Amp::Revlog.new(opener, new_file)
301
+ Amp::Journal.start("sillymonkey.tx") do |j|
302
+ newrevlog.add_revision("silly", j, 50, "|\x03\xfe\x149\x81+\xcc5\xa3\x97\x94*I\xe2\xb9T\xa9\xac\x02", "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
303
+ end
304
+ new_str = ""
305
+ cmp_str = ""
306
+ File.open(new_file, "r") do |f|
307
+ new_str = f.read
308
+ end
309
+ File.open(cmp_file, "r") do |f|
310
+ cmp_str = f.read
311
+ end
312
+ i = 0
313
+ new_str.force_encoding("ASCII-8BIT") if RUBY_VERSION >= "1.9"
314
+ cmp_str.force_encoding("ASCII-8BIT") if RUBY_VERSION >= "1.9"
315
+
316
+ new_str = new_str.split("")
317
+ cmp_str = cmp_str.split("")
318
+ while new_str.first == cmp_str.first && new_str.size > 0
319
+ new_str.shift
320
+ cmp_str.shift
321
+ i += 1
322
+ end
323
+ unless new_str.empty? && cmp_str.empty?
324
+ puts "Failed at byte #{ i }"
325
+ flunk
326
+ end
327
+ assert true
328
+ end
329
+
330
+ # def test_revlog_ancestor
331
+ # assert_equal(19, @revlog.rev(@revlog.ancestor(@revlog.node(19), @revlog.node(45))))
332
+ # end
333
+ end