amp 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. data/.gitignore +12 -0
  2. data/.hgignore +3 -0
  3. data/AUTHORS +1 -1
  4. data/Manifest.txt +99 -38
  5. data/README.md +3 -3
  6. data/Rakefile +53 -18
  7. data/SCHEDULE.markdown +5 -1
  8. data/TODO.markdown +120 -149
  9. data/ampfile.rb +3 -1
  10. data/bin/amp +4 -1
  11. data/ext/amp/bz2/extconf.rb +1 -1
  12. data/ext/amp/mercurial_patch/extconf.rb +1 -1
  13. data/ext/amp/mercurial_patch/mpatch.c +4 -3
  14. data/ext/amp/priority_queue/extconf.rb +1 -1
  15. data/ext/amp/support/extconf.rb +1 -1
  16. data/ext/amp/support/support.c +1 -1
  17. data/lib/amp.rb +125 -67
  18. data/lib/amp/commands/command.rb +12 -10
  19. data/lib/amp/commands/command_support.rb +8 -1
  20. data/lib/amp/commands/commands/help.rb +2 -20
  21. data/lib/amp/commands/commands/init.rb +14 -2
  22. data/lib/amp/commands/commands/templates.rb +6 -4
  23. data/lib/amp/commands/commands/version.rb +15 -1
  24. data/lib/amp/commands/commands/workflow.rb +3 -3
  25. data/lib/amp/commands/commands/workflows/git/add.rb +3 -3
  26. data/lib/amp/commands/commands/workflows/git/copy.rb +1 -1
  27. data/lib/amp/commands/commands/workflows/git/rm.rb +4 -2
  28. data/lib/amp/commands/commands/workflows/hg/add.rb +1 -1
  29. data/lib/amp/commands/commands/workflows/hg/addremove.rb +2 -2
  30. data/lib/amp/commands/commands/workflows/hg/annotate.rb +8 -2
  31. data/lib/amp/commands/commands/workflows/hg/bisect.rb +253 -0
  32. data/lib/amp/commands/commands/workflows/hg/branch.rb +1 -1
  33. data/lib/amp/commands/commands/workflows/hg/branches.rb +3 -3
  34. data/lib/amp/commands/commands/workflows/hg/bundle.rb +3 -3
  35. data/lib/amp/commands/commands/workflows/hg/clone.rb +4 -5
  36. data/lib/amp/commands/commands/workflows/hg/commit.rb +37 -1
  37. data/lib/amp/commands/commands/workflows/hg/copy.rb +2 -1
  38. data/lib/amp/commands/commands/workflows/hg/debug/index.rb +1 -1
  39. data/lib/amp/commands/commands/workflows/hg/diff.rb +3 -8
  40. data/lib/amp/commands/commands/workflows/hg/forget.rb +5 -4
  41. data/lib/amp/commands/commands/workflows/hg/identify.rb +6 -6
  42. data/lib/amp/commands/commands/workflows/hg/import.rb +1 -1
  43. data/lib/amp/commands/commands/workflows/hg/incoming.rb +2 -2
  44. data/lib/amp/commands/commands/workflows/hg/log.rb +5 -4
  45. data/lib/amp/commands/commands/workflows/hg/merge.rb +1 -1
  46. data/lib/amp/commands/commands/workflows/hg/move.rb +5 -3
  47. data/lib/amp/commands/commands/workflows/hg/outgoing.rb +1 -1
  48. data/lib/amp/commands/commands/workflows/hg/push.rb +6 -7
  49. data/lib/amp/commands/commands/workflows/hg/remove.rb +2 -2
  50. data/lib/amp/commands/commands/workflows/hg/resolve.rb +6 -23
  51. data/lib/amp/commands/commands/workflows/hg/root.rb +1 -2
  52. data/lib/amp/commands/commands/workflows/hg/status.rb +21 -12
  53. data/lib/amp/commands/commands/workflows/hg/tag.rb +2 -2
  54. data/lib/amp/commands/commands/workflows/hg/untrack.rb +12 -0
  55. data/lib/amp/commands/commands/workflows/hg/verify.rb +13 -3
  56. data/lib/amp/commands/commands/workflows/hg/what_changed.rb +18 -0
  57. data/lib/amp/commands/dispatch.rb +12 -13
  58. data/lib/amp/dependencies/amp_support.rb +1 -1
  59. data/lib/amp/dependencies/amp_support/ruby_amp_support.rb +1 -0
  60. data/lib/amp/dependencies/maruku.rb +136 -0
  61. data/lib/amp/dependencies/maruku/attributes.rb +227 -0
  62. data/lib/amp/dependencies/maruku/defaults.rb +71 -0
  63. data/lib/amp/dependencies/maruku/errors_management.rb +92 -0
  64. data/lib/amp/dependencies/maruku/helpers.rb +260 -0
  65. data/lib/amp/dependencies/maruku/input/charsource.rb +326 -0
  66. data/lib/amp/dependencies/maruku/input/extensions.rb +69 -0
  67. data/lib/amp/dependencies/maruku/input/html_helper.rb +189 -0
  68. data/lib/amp/dependencies/maruku/input/linesource.rb +111 -0
  69. data/lib/amp/dependencies/maruku/input/parse_block.rb +615 -0
  70. data/lib/amp/dependencies/maruku/input/parse_doc.rb +234 -0
  71. data/lib/amp/dependencies/maruku/input/parse_span_better.rb +746 -0
  72. data/lib/amp/dependencies/maruku/input/rubypants.rb +225 -0
  73. data/lib/amp/dependencies/maruku/input/type_detection.rb +147 -0
  74. data/lib/amp/dependencies/maruku/input_textile2/t2_parser.rb +163 -0
  75. data/lib/amp/dependencies/maruku/maruku.rb +33 -0
  76. data/lib/amp/dependencies/maruku/output/to_ansi.rb +223 -0
  77. data/lib/amp/dependencies/maruku/output/to_html.rb +991 -0
  78. data/lib/amp/dependencies/maruku/output/to_markdown.rb +164 -0
  79. data/lib/amp/dependencies/maruku/output/to_s.rb +56 -0
  80. data/lib/amp/dependencies/maruku/string_utils.rb +191 -0
  81. data/lib/amp/dependencies/maruku/structures.rb +167 -0
  82. data/lib/amp/dependencies/maruku/structures_inspect.rb +87 -0
  83. data/lib/amp/dependencies/maruku/structures_iterators.rb +61 -0
  84. data/lib/amp/dependencies/maruku/textile2.rb +1 -0
  85. data/lib/amp/dependencies/maruku/toc.rb +199 -0
  86. data/lib/amp/dependencies/maruku/usage/example1.rb +33 -0
  87. data/lib/amp/dependencies/maruku/version.rb +40 -0
  88. data/lib/amp/dependencies/priority_queue.rb +2 -1
  89. data/lib/amp/dependencies/python_config.rb +2 -1
  90. data/lib/amp/graphs/ancestor.rb +2 -1
  91. data/lib/amp/graphs/copies.rb +236 -233
  92. data/lib/amp/help/entries/__default__.erb +31 -0
  93. data/lib/amp/help/entries/commands.erb +6 -0
  94. data/lib/amp/help/entries/mdtest.md +35 -0
  95. data/lib/amp/help/entries/silly +3 -0
  96. data/lib/amp/help/help.rb +288 -0
  97. data/lib/amp/profiling_hacks.rb +5 -3
  98. data/lib/amp/repository/abstract/abstract_changeset.rb +97 -0
  99. data/lib/amp/repository/abstract/abstract_local_repo.rb +181 -0
  100. data/lib/amp/repository/abstract/abstract_staging_area.rb +180 -0
  101. data/lib/amp/repository/abstract/abstract_versioned_file.rb +100 -0
  102. data/lib/amp/repository/abstract/common_methods/changeset.rb +75 -0
  103. data/lib/amp/repository/abstract/common_methods/local_repo.rb +277 -0
  104. data/lib/amp/repository/abstract/common_methods/staging_area.rb +233 -0
  105. data/lib/amp/repository/abstract/common_methods/versioned_file.rb +71 -0
  106. data/lib/amp/repository/generic_repo_picker.rb +78 -0
  107. data/lib/amp/repository/git/repo_format/changeset.rb +336 -0
  108. data/lib/amp/repository/git/repo_format/staging_area.rb +192 -0
  109. data/lib/amp/repository/git/repo_format/versioned_file.rb +119 -0
  110. data/lib/amp/repository/git/repositories/local_repository.rb +164 -0
  111. data/lib/amp/repository/git/repository.rb +41 -0
  112. data/lib/amp/repository/mercurial/encoding/mercurial_diff.rb +382 -0
  113. data/lib/amp/repository/mercurial/encoding/mercurial_patch.rb +1 -0
  114. data/lib/amp/repository/mercurial/encoding/patch.rb +294 -0
  115. data/lib/amp/repository/mercurial/encoding/pure_ruby/ruby_mercurial_patch.rb +124 -0
  116. data/lib/amp/repository/mercurial/merging/merge_ui.rb +327 -0
  117. data/lib/amp/repository/mercurial/merging/simple_merge.rb +452 -0
  118. data/lib/amp/repository/mercurial/repo_format/branch_manager.rb +266 -0
  119. data/lib/amp/repository/mercurial/repo_format/changeset.rb +768 -0
  120. data/lib/amp/repository/mercurial/repo_format/dir_state.rb +716 -0
  121. data/lib/amp/repository/mercurial/repo_format/journal.rb +218 -0
  122. data/lib/amp/repository/mercurial/repo_format/lock.rb +210 -0
  123. data/lib/amp/repository/mercurial/repo_format/merge_state.rb +228 -0
  124. data/lib/amp/repository/mercurial/repo_format/staging_area.rb +367 -0
  125. data/lib/amp/repository/mercurial/repo_format/store.rb +487 -0
  126. data/lib/amp/repository/mercurial/repo_format/tag_manager.rb +322 -0
  127. data/lib/amp/repository/mercurial/repo_format/updatable.rb +543 -0
  128. data/lib/amp/repository/mercurial/repo_format/updater.rb +848 -0
  129. data/lib/amp/repository/mercurial/repo_format/verification.rb +433 -0
  130. data/lib/amp/repository/mercurial/repositories/bundle_repository.rb +216 -0
  131. data/lib/amp/repository/mercurial/repositories/http_repository.rb +386 -0
  132. data/lib/amp/repository/mercurial/repositories/local_repository.rb +2034 -0
  133. data/lib/amp/repository/mercurial/repository.rb +119 -0
  134. data/lib/amp/repository/mercurial/revlogs/bundle_revlogs.rb +249 -0
  135. data/lib/amp/repository/mercurial/revlogs/changegroup.rb +217 -0
  136. data/lib/amp/repository/mercurial/revlogs/changelog.rb +339 -0
  137. data/lib/amp/repository/mercurial/revlogs/file_log.rb +152 -0
  138. data/lib/amp/repository/mercurial/revlogs/index.rb +500 -0
  139. data/lib/amp/repository/mercurial/revlogs/manifest.rb +201 -0
  140. data/lib/amp/repository/mercurial/revlogs/node.rb +20 -0
  141. data/lib/amp/repository/mercurial/revlogs/revlog.rb +1026 -0
  142. data/lib/amp/repository/mercurial/revlogs/revlog_support.rb +129 -0
  143. data/lib/amp/repository/mercurial/revlogs/versioned_file.rb +597 -0
  144. data/lib/amp/repository/repository.rb +11 -88
  145. data/lib/amp/server/extension/amp_extension.rb +3 -3
  146. data/lib/amp/server/fancy_http_server.rb +1 -1
  147. data/lib/amp/server/fancy_views/_browser.haml +1 -1
  148. data/lib/amp/server/fancy_views/_diff_file.haml +1 -8
  149. data/lib/amp/server/fancy_views/changeset.haml +2 -2
  150. data/lib/amp/server/fancy_views/file.haml +1 -1
  151. data/lib/amp/server/fancy_views/file_diff.haml +1 -1
  152. data/lib/amp/support/amp_ui.rb +13 -29
  153. data/lib/amp/support/generator.rb +1 -1
  154. data/lib/amp/support/loaders.rb +1 -2
  155. data/lib/amp/support/logger.rb +10 -16
  156. data/lib/amp/support/match.rb +18 -4
  157. data/lib/amp/support/mercurial/ignore.rb +151 -0
  158. data/lib/amp/support/openers.rb +8 -3
  159. data/lib/amp/support/support.rb +91 -46
  160. data/lib/amp/templates/{blank.commit.erb → mercurial/blank.commit.erb} +0 -0
  161. data/lib/amp/templates/{blank.log.erb → mercurial/blank.log.erb} +0 -0
  162. data/lib/amp/templates/{default.commit.erb → mercurial/default.commit.erb} +0 -0
  163. data/lib/amp/templates/{default.log.erb → mercurial/default.log.erb} +0 -0
  164. data/lib/amp/templates/template.rb +18 -18
  165. data/man/amp.1 +51 -0
  166. data/site/src/about/commands.haml +1 -1
  167. data/site/src/css/amp.css +1 -1
  168. data/site/src/index.haml +3 -3
  169. data/tasks/man.rake +39 -0
  170. data/tasks/stats.rake +1 -10
  171. data/tasks/yard.rake +1 -50
  172. data/test/dirstate_tests/test_dir_state.rb +10 -8
  173. data/test/functional_tests/annotate.out +31 -0
  174. data/test/functional_tests/test_functional.rb +155 -63
  175. data/test/localrepo_tests/ampfile.rb +12 -0
  176. data/test/localrepo_tests/test_local_repo.rb +56 -57
  177. data/test/manifest_tests/test_manifest.rb +3 -5
  178. data/test/merge_tests/test_merge.rb +3 -3
  179. data/test/revlog_tests/test_revlog.rb +14 -6
  180. data/test/store_tests/test_fncache_store.rb +19 -19
  181. data/test/test_19_compatibility.rb +46 -0
  182. data/test/test_base85.rb +2 -2
  183. data/test/test_bdiff.rb +2 -2
  184. data/test/test_changegroup.rb +59 -0
  185. data/test/test_commands.rb +2 -2
  186. data/test/test_difflib.rb +2 -2
  187. data/test/test_generator.rb +34 -0
  188. data/test/test_ignore.rb +203 -0
  189. data/test/test_journal.rb +18 -13
  190. data/test/test_match.rb +2 -2
  191. data/test/test_mdiff.rb +3 -3
  192. data/test/test_mpatch.rb +3 -3
  193. data/test/test_multi_io.rb +40 -0
  194. data/test/test_support.rb +18 -2
  195. data/test/test_templates.rb +38 -0
  196. data/test/test_ui.rb +79 -0
  197. data/test/testutilities.rb +56 -0
  198. metadata +168 -49
  199. data/ext/amp/bz2/mkmf.log +0 -38
  200. data/lib/amp/encoding/mercurial_diff.rb +0 -378
  201. data/lib/amp/encoding/mercurial_patch.rb +0 -1
  202. data/lib/amp/encoding/patch.rb +0 -292
  203. data/lib/amp/encoding/pure_ruby/ruby_mercurial_patch.rb +0 -123
  204. data/lib/amp/merges/merge_state.rb +0 -164
  205. data/lib/amp/merges/merge_ui.rb +0 -322
  206. data/lib/amp/merges/simple_merge.rb +0 -450
  207. data/lib/amp/repository/branch_manager.rb +0 -234
  208. data/lib/amp/repository/dir_state.rb +0 -950
  209. data/lib/amp/repository/journal.rb +0 -203
  210. data/lib/amp/repository/lock.rb +0 -207
  211. data/lib/amp/repository/repositories/bundle_repository.rb +0 -214
  212. data/lib/amp/repository/repositories/http_repository.rb +0 -377
  213. data/lib/amp/repository/repositories/local_repository.rb +0 -2661
  214. data/lib/amp/repository/store.rb +0 -485
  215. data/lib/amp/repository/tag_manager.rb +0 -319
  216. data/lib/amp/repository/updatable.rb +0 -532
  217. data/lib/amp/repository/verification.rb +0 -431
  218. data/lib/amp/repository/versioned_file.rb +0 -475
  219. data/lib/amp/revlogs/bundle_revlogs.rb +0 -246
  220. data/lib/amp/revlogs/changegroup.rb +0 -217
  221. data/lib/amp/revlogs/changelog.rb +0 -338
  222. data/lib/amp/revlogs/changeset.rb +0 -521
  223. data/lib/amp/revlogs/file_log.rb +0 -165
  224. data/lib/amp/revlogs/index.rb +0 -493
  225. data/lib/amp/revlogs/manifest.rb +0 -195
  226. data/lib/amp/revlogs/node.rb +0 -18
  227. data/lib/amp/revlogs/revlog.rb +0 -1045
  228. data/lib/amp/revlogs/revlog_support.rb +0 -126
  229. data/lib/amp/support/ignore.rb +0 -144
  230. data/site/Rakefile +0 -38
  231. data/test/test_amp.rb +0 -9
  232. data/test/test_helper.rb +0 -15
@@ -0,0 +1,12 @@
1
+ # Any ruby code here will be executed before Amp loads a repository and
2
+ # dispatches a command.
3
+ #
4
+ # Example command:
5
+ #
6
+ # command "echo" do |c|
7
+ # c.opt :"no-newline", "Don't print a trailing newline character", :short => "-n"
8
+ # c.on_run do |opts, args|
9
+ # print args.join(" ")
10
+ # print "\n" unless opts[:"no-newline"]
11
+ # end
12
+ # end
@@ -1,14 +1,14 @@
1
- require "test/unit"
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../testutilities')
2
2
  require 'fileutils'
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
4
4
 
5
- class TestLocalRepo < Test::Unit::TestCase
5
+ class TestLocalRepo < AmpTestCase
6
6
  REPO_PATH = File.expand_path(File.join(File.dirname(__FILE__)))
7
7
  EXISTING_REPO_PATH = File.expand_path(File.join(File.dirname(__FILE__), "testrepo"))
8
8
 
9
9
  def setup
10
10
  @config = Amp::AmpConfig.new
11
- @repo = Amp::Repositories::LocalRepository.new(EXISTING_REPO_PATH, false, @config)
11
+ @repo = Amp::Repositories::Mercurial::LocalRepository.new(EXISTING_REPO_PATH, false, @config)
12
12
  end
13
13
 
14
14
  def join(*args)
@@ -23,27 +23,22 @@ class TestLocalRepo < Test::Unit::TestCase
23
23
  FileUtils.rm_rf join(".hg")
24
24
  end
25
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
26
+ def test_create_repo
27
+ Amp::Repositories::Mercurial::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
+ refute_nil @repo
37
+ end
38
+
39
+ def test_repo_size
40
+ assert_equal 4, @repo.size
41
+ end
47
42
 
48
43
  def test_initial_changeset_manifest
49
44
  changeset = @repo[0]
@@ -56,40 +51,40 @@ class TestLocalRepo < Test::Unit::TestCase
56
51
  assert_equal expected_list.sort, actual.sort
57
52
  end
58
53
 
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
54
+ def test_initial_readme
55
+ changeset = @repo[0]
80
56
 
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
57
+ changeset.manifest_entry.inspect # force load of manifest
58
+
59
+ file = changeset["readme"]
60
+ # data check on a file
61
+ expected_readme = "this is the readme. I hope you like it.\nAmp is "+
62
+ "totally sweet. We're gonna do awesome stuff.\nI hope "+
63
+ "you lik it.\n"
64
+
65
+ expected = expected_readme
66
+ actual = file.data
67
+ assert_equal expected, actual
68
+
69
+ expected = Zlib::Deflate.deflate(file.data).size
70
+ actual = file.size # compressed size
71
+ assert_equal expected, actual
72
+
73
+ assert_false file.cmp(expected_readme)
74
+ end
75
+
76
+ def test_second_readme
77
+ expected_readme = "this is the readme. I hope you like it.\nAmp is "+
78
+ "totally sweet. We're gonna do awesome stuff.\nI hope "+
79
+ "you like it.\n" # typo fixed
80
+ changeset = @repo[1]
81
+ changeset.manifest_entry # force load of manifest
82
+ file = changeset["readme"]
83
+
84
+ expected = expected_readme
85
+ actual = file.data
86
+ assert_equal expected, actual
87
+ end
93
88
 
94
89
  def test_status
95
90
 
@@ -105,6 +100,8 @@ class TestLocalRepo < Test::Unit::TestCase
105
100
  added = []
106
101
  deleted = []
107
102
  removed = []
103
+ #copied = []
104
+ #moved = []
108
105
  expected = { :modified => modified.sort,
109
106
  :added => added.sort,
110
107
  :removed => removed.sort,
@@ -112,6 +109,8 @@ class TestLocalRepo < Test::Unit::TestCase
112
109
  :unknown => unknown.sort,
113
110
  :ignored => ignored.sort,
114
111
  :clean => clean.sort ,
112
+ #:copied => copied,
113
+ #:moved => moved,
115
114
  :delta => 19
116
115
  }
117
116
 
@@ -1,14 +1,12 @@
1
- require "test/unit"
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../testutilities')
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
3
3
 
4
-
5
-
6
- class TestManifest < Test::Unit::TestCase
4
+ class TestManifest < AmpTestCase
7
5
 
8
6
  def setup
9
7
  opener = Amp::Opener.new(File.dirname(__FILE__))
10
8
  opener.default = :open_file
11
- @manifest = Amp::Manifest.new(opener)
9
+ @manifest = Amp::Mercurial::Manifest.new(opener)
12
10
  end
13
11
 
14
12
  def test_load_manifest
@@ -1,7 +1,7 @@
1
- require "test/unit"
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../testutilities')
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
3
3
 
4
- class TestMerge < Test::Unit::TestCase
4
+ class TestMerge < AmpTestCase
5
5
  TEST_BASE = File.expand_path(File.join(File.dirname(__FILE__), 'base.txt'))
6
6
  TEST_LOCAL = File.expand_path(File.join(File.dirname(__FILE__), 'local.txt'))
7
7
  TEST_REMOTE = File.expand_path(File.join(File.dirname(__FILE__), 'remote.txt'))
@@ -14,7 +14,7 @@ class TestMerge < Test::Unit::TestCase
14
14
 
15
15
  # kill the error output...
16
16
  old, $stderr = $stderr, StringIO.new
17
- Amp::Merges::ThreeWayMerger.three_way_merge(TEST_LOCAL, TEST_BASE, TEST_REMOTE,
17
+ Amp::Merges::Mercurial::ThreeWayMerger.three_way_merge(TEST_LOCAL, TEST_BASE, TEST_REMOTE,
18
18
  :labels => ["local","other"])
19
19
  $stderr = old # and reassign
20
20
 
@@ -1,15 +1,14 @@
1
1
  # -*- coding: us-ascii -*-
2
-
3
- require "test/unit"
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../testutilities')
4
3
  require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
5
4
 
6
- class TestRevlog < Test::Unit::TestCase
5
+ class TestRevlog < AmpTestCase
7
6
  TEST_REVLOG_INDEX = "testindex.i"
8
7
 
9
8
  def setup
10
9
  opener = Amp::Opener.new(File.expand_path(File.dirname(__FILE__)))
11
10
  opener.default = :open_file # for testing purposes!
12
- @revlog = Amp::Revlog.new(opener, TEST_REVLOG_INDEX)
11
+ @revlog = Amp::Mercurial::Revlog.new(opener, TEST_REVLOG_INDEX)
13
12
  end
14
13
 
15
14
  def test_load_revlog
@@ -23,6 +22,15 @@ class TestRevlog < Test::Unit::TestCase
23
22
  assert_equal expected, result
24
23
  end
25
24
 
25
+
26
+ def test_node_raises
27
+ assert_raises(Amp::Mercurial::RevlogSupport::LookupError) { @revlog.node_id_for_index(12345) }
28
+ end
29
+
30
+ def test_rev_raises
31
+ assert_raises(Amp::Mercurial::RevlogSupport::LookupError) { @revlog.revision_index_for_node("abcdefghijkl") }
32
+ end
33
+
26
34
  def test_revlog_size
27
35
  result = @revlog.size
28
36
  expected = 51
@@ -297,8 +305,8 @@ class TestRevlog < Test::Unit::TestCase
297
305
  new_file = "./test/revlog_tests/test_adding_index.i"
298
306
  opener = Amp::Opener.new(".")
299
307
  opener.default = :open_file
300
- newrevlog = Amp::Revlog.new(opener, new_file)
301
- Amp::Journal.start("sillymonkey.tx") do |j|
308
+ newrevlog = Amp::Mercurial::Revlog.new(opener, new_file)
309
+ Amp::Mercurial::Journal.start("sillymonkey.tx") do |j|
302
310
  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
311
  end
304
312
  new_str = ""
@@ -1,38 +1,38 @@
1
- require "test/unit"
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../testutilities')
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
3
3
 
4
- class TestFilenameCacheStore < Test::Unit::TestCase
4
+ class TestFilenameCacheStore < AmpTestCase
5
5
  STORE_PATH = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  def setup
7
- @store = Amp::Repositories::Stores.pick(['store','fncache'], STORE_PATH, Amp::Opener)
7
+ @store = Amp::Repositories::Mercurial::Stores.pick(['store','fncache'], STORE_PATH, Amp::Opener)
8
8
  end
9
9
 
10
10
  def test_load_manifest
11
11
  assert_not_nil @store
12
- assert_instance_of Amp::Repositories::Stores::FilenameCacheStore, @store
12
+ assert_instance_of Amp::Repositories::Mercurial::Stores::FilenameCacheStore, @store
13
13
  end
14
14
 
15
15
  def test_hybrid_encode
16
- result = Amp::Repositories::Stores.hybrid_encode("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
16
+ result = Amp::Repositories::Mercurial::Stores.hybrid_encode("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
17
17
  "A????WHHHHHHHHHHHAAAAAAAAATTTTTTTTTT/"+
18
18
  "lolzorZ?.rb")
19
19
  expected = "dh/abcdefgh/hahaha~3/lolzorz~3f.rb0d132fe8aa79af42d3d3c11038"+
20
20
  "3007e9f5bd43d4.rb"
21
21
  assert_equal expected, result
22
22
 
23
- result = Amp::Repositories::Stores.hybrid_encode("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
23
+ result = Amp::Repositories::Mercurial::Stores.hybrid_encode("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
24
24
  "A????WHHHHTT/lolzorZ?.rb")
25
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
26
  "_a_h_a_h_a~3f~3f~3f~3f_w_h_h_h_h_t_t/lolzor_z~3f.rb"
27
27
  assert_equal expected, result
28
28
 
29
- result = Amp::Repositories::Stores.hybrid_encode("data///../.././//lolzorZ?.rb")
29
+ result = Amp::Repositories::Mercurial::Stores.hybrid_encode("data///../.././//lolzorZ?.rb")
30
30
  expected = "data///.~2e/.~2e/~2e///lolzor_z~3f.rb"
31
31
  assert_equal expected, result
32
32
  end
33
33
 
34
34
  def test_normal_encode
35
- result = Amp::Repositories::Stores.encode_filename("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
35
+ result = Amp::Repositories::Mercurial::Stores.encode_filename("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
36
36
  "A????WHHHHHHHHHHHAAAAAAAAATTTTTTTTTT/"+
37
37
  "lolzorZ?.rb")
38
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_"+
@@ -40,19 +40,19 @@ class TestFilenameCacheStore < Test::Unit::TestCase
40
40
  "_a_t_t_t_t_t_t_t_t_t_t/lolzor_z~3f.rb"
41
41
  assert_equal expected, result
42
42
 
43
- result = Amp::Repositories::Stores.encode_filename("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
43
+ result = Amp::Repositories::Mercurial::Stores.encode_filename("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAH"+
44
44
  "A????WHHHHTT/lolzorZ?.rb")
45
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
46
  "a_h_a_h_a~3f~3f~3f~3f_w_h_h_h_h_t_t/lolzor_z~3f.rb"
47
47
  assert_equal expected, result
48
48
 
49
- result = Amp::Repositories::Stores.encode_filename("data///../.././//lolzorZ?.rb")
49
+ result = Amp::Repositories::Mercurial::Stores.encode_filename("data///../.././//lolzorZ?.rb")
50
50
  expected = "data///../.././//lolzor_z~3f.rb"
51
51
  assert_equal expected, result
52
52
  end
53
53
 
54
54
  def test_normal_decode
55
- result = Amp::Repositories::Stores.decode_filename(
55
+ result = Amp::Repositories::Mercurial::Stores.decode_filename(
56
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
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
58
  "_a_t_t_t_t_t_t_t_t_t_t/lolzor_z~3f.rb")
@@ -62,13 +62,13 @@ class TestFilenameCacheStore < Test::Unit::TestCase
62
62
  "lolzorZ?.rb"
63
63
  assert_equal expected, result
64
64
 
65
- result = Amp::Repositories::Stores.decode_filename(
65
+ result = Amp::Repositories::Mercurial::Stores.decode_filename(
66
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
67
  "a_h_a_h_a~3f~3f~3f~3f_w_h_h_h_h_t_t/lolzor_z~3f.rb")
68
68
  expected = "data/ABCDEFGHIJKLMNOPQRSTUVWXYZ/HAHAHA????WHHHHTT/lolzorZ?.rb"
69
69
  assert_equal expected, result
70
70
 
71
- result = Amp::Repositories::Stores.decode_filename("data///../.././//lolzor_z~3f.rb")
71
+ result = Amp::Repositories::Mercurial::Stores.decode_filename("data///../.././//lolzor_z~3f.rb")
72
72
  expected = "data///../.././//lolzorZ?.rb"
73
73
  assert_equal expected, result
74
74
  end
@@ -107,16 +107,16 @@ class TestFilenameCacheStore < Test::Unit::TestCase
107
107
 
108
108
  def test_picker_works
109
109
  requirements = []
110
- store = Amp::Repositories::Stores.pick(requirements, STORE_PATH, Amp::Opener)
111
- assert_instance_of Amp::Repositories::Stores::BasicStore, store
110
+ store = Amp::Repositories::Mercurial::Stores.pick(requirements, STORE_PATH, Amp::Opener)
111
+ assert_instance_of Amp::Repositories::Mercurial::Stores::BasicStore, store
112
112
 
113
113
  requirements = ['store']
114
- store = Amp::Repositories::Stores.pick(requirements, STORE_PATH, Amp::Opener)
115
- assert_instance_of Amp::Repositories::Stores::EncodedStore, store
114
+ store = Amp::Repositories::Mercurial::Stores.pick(requirements, STORE_PATH, Amp::Opener)
115
+ assert_instance_of Amp::Repositories::Mercurial::Stores::EncodedStore, store
116
116
 
117
117
  requirements = ['store', 'fncache']
118
- store = Amp::Repositories::Stores.pick(requirements, STORE_PATH, Amp::Opener)
119
- assert_instance_of Amp::Repositories::Stores::FilenameCacheStore, store
118
+ store = Amp::Repositories::Mercurial::Stores.pick(requirements, STORE_PATH, Amp::Opener)
119
+ assert_instance_of Amp::Repositories::Mercurial::Stores::FilenameCacheStore, store
120
120
 
121
121
  end
122
122
  end
@@ -0,0 +1,46 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'testutilities')
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
+
4
+ class Test19Compatibility < AmpTestCase
5
+
6
+ def test_string_any?
7
+ assert "hello".any?
8
+ end
9
+
10
+ def test_string_any_false
11
+ assert_false "".any?
12
+ end
13
+
14
+ def test_lines
15
+ input = "hello\nthere\n\n mike"
16
+ expected = ["hello\n","there\n","\n"," mike"]
17
+ result = []
18
+ input.lines {|str| result << str}
19
+ assert_equal expected, result
20
+ end
21
+
22
+ def test_lines_to_enum
23
+ input = "hello\nthere\n\n mike"
24
+ # can't do a kind_of? because ruby1.9 has ::Enumerator and
25
+ # 1.8 uses Enumerable::Enumerator
26
+ classname = input.lines.class.to_s.split("::").last
27
+ assert_equal "Enumerator", classname
28
+ end
29
+
30
+ def test_ord
31
+ assert_equal "h".ord, 104
32
+ end
33
+
34
+ def test_ord_long_string
35
+ assert_equal "hello".ord, 104
36
+ end
37
+
38
+ def test_tap
39
+ value = "hi there"
40
+ in_block = nil
41
+ value.tap {|val| in_block = val}
42
+ assert_equal value, in_block
43
+ end
44
+
45
+
46
+ end
@@ -1,7 +1,7 @@
1
- require "test/unit"
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'testutilities')
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
3
 
4
- class TestBase85 < Test::Unit::TestCase
4
+ class TestBase85 < AmpTestCase
5
5
  def test_encode
6
6
  assert_equal("Xk~0{Zy<DNWpZUKAZ>XdZeeX@AZc?TZE0g@VP$L~AZTxQAYpQ4AbD?fAarkJVR=6",
7
7
  Amp::Encoding::Base85.encode("hello there, my name is michael! how are you today?"))
@@ -1,7 +1,7 @@
1
- require "test/unit"
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'testutilities')
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
3
 
4
- class TestBdiff < Test::Unit::TestCase
4
+ class TestBdiff < AmpTestCase
5
5
  include Amp::Diffs
6
6
 
7
7
  def test_create_bdiff
@@ -0,0 +1,59 @@
1
+ require 'stringio'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'testutilities')
3
+ require 'zlib'
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
5
+
6
+ class TestChangegroup < AmpTestCase
7
+ include Amp::Mercurial::RevlogSupport
8
+
9
+ def test_compressor_uncompressed
10
+ compressor = ChangeGroup.compressor_by_type("HG10UN")
11
+ assert_kind_of StringIO, compressor
12
+ assert_respond_to compressor, :flush
13
+ compressor << "input string"
14
+ assert_equal "input string", compressor.flush
15
+ end
16
+
17
+ def test_compressor_no_header
18
+ assert_kind_of StringIO, ChangeGroup.compressor_by_type("")
19
+ end
20
+
21
+ def test_compressor_zlib
22
+ compressor = ChangeGroup.compressor_by_type("HG10GZ")
23
+ assert_kind_of Zlib::Deflate, compressor
24
+ end
25
+
26
+ def test_compressor_bz
27
+ # this fails. bz2 is borked atm.
28
+ # compressor = ChangeGroup.compressor_by_type("HG10BZ")
29
+ # assert_kind_of BZ2::Writer, compressor
30
+ end
31
+
32
+ def test_unbundle_uncompressed
33
+ input_io = StringIO.new("input data")
34
+ decompressing_io = ChangeGroup.unbundle("HG10UN", input_io)
35
+ assert_equal("input data", decompressing_io.read)
36
+ end
37
+
38
+ def test_unbundle_funny_header
39
+ input_io = StringIO.new("input data")
40
+ funny_header = "BUNDLE"
41
+ decompressing_io = ChangeGroup.unbundle(funny_header, input_io)
42
+ assert_equal("BUNDLEinput data", decompressing_io.read)
43
+ end
44
+
45
+ def test_unbundle_gzip
46
+ input_io = StringIO.new("", "r+")
47
+ gzip_maker = Zlib::GzipWriter.new(input_io)
48
+ gzip_maker << "input string"
49
+ gzip_maker.flush
50
+ gzip_maker.close
51
+ input_io.reopen(input_io.string,"r")
52
+ input_io.rewind
53
+ decompressing_io = ChangeGroup.unbundle("HG10GZ", input_io)
54
+ assert_kind_of Zlib::GzipReader, decompressing_io
55
+ assert_equal "input string", decompressing_io.read
56
+ end
57
+
58
+
59
+ end