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,28 @@
1
+ command :branch do |c|
2
+ c.workflow :hg
3
+
4
+ c.desc "Set/Show the current branch name"
5
+ c.opt :force, "Forces the branch-name change", :short => "-f"
6
+ c.opt :clean, "Resets the branch setting for this repository", :short => "-c"
7
+
8
+ c.on_run do |opts, args|
9
+ repo = opts[:repository]
10
+ if opts[:clean]
11
+ _label = repo[nil].parents[0].branch
12
+ repo.dirstate.branch = _label
13
+ Amp::UI.status("Reset working directory to branch #{_label}")
14
+ elsif args.size > 0
15
+ _label = args.first
16
+ if !opts[:force] && repo.branch_tags.include?(_label)
17
+ if !repo.parents.map {|p| p.branch}.include?(_label)
18
+ raise abort("a branch of the same name already exists!"+
19
+ " (use --force to override)")
20
+ end
21
+ end
22
+ repo.dirstate.branch = _label
23
+ Amp::UI.status("marked working directory as branch #{_label}")
24
+ else
25
+ Amp::UI.say("#{repo.dirstate.branch}")
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ command :branches do |c|
2
+ c.workflow :hg
3
+ c.desc "Prints the current branches (active and closed)"
4
+
5
+ c.on_run do |opts, args|
6
+ repo = opts[:repository]
7
+
8
+ active_branches = repo.heads(nil, :closed => false).map {|n| repo[n].branch}
9
+ branches = repo.branch_tags.map do |tag, node|
10
+ [ active_branches.include?(tag), repo.changelog.rev(node), tag ]
11
+ end
12
+ branches.reverse!
13
+ branches.each do |is_active, node, tag|
14
+ if !opts[:active] || is_active
15
+ hexable = repo.lookup(node)
16
+ if is_active
17
+ branch_status = ""
18
+ elsif !(repo.branch_heads(tag, :closed => false).include?(hexable))
19
+ notice = " (closed)"
20
+ else
21
+ notice = " (inactive)"
22
+ end
23
+ revision = node.to_s.rjust(31 - tag.size)
24
+ data = [tag, revision, hexable.short_hex, notice]
25
+ Amp::UI.say "#{tag} #{revision}:#{hexable.short_hex}#{notice}"
26
+ end
27
+ end #end each
28
+
29
+ end # end on_run
30
+ end
@@ -0,0 +1,115 @@
1
+ command :bundle do |c|
2
+ c.workflow :hg
3
+
4
+ c.desc "Create a changegroup file"
5
+ c.help <<-EOS
6
+ amp bundle [options]+ file dest
7
+
8
+ Generate a compressed changegroup file collecting changesets not
9
+ known to be in another repository.
10
+
11
+ If no destination repository is specified the destination is
12
+ assumed to have all the nodes specified by one or more --base
13
+ parameters. To create a bundle containing all changesets, use
14
+ --all (or --base null). To change the compression method applied,
15
+ use the -t option (by default, bundles are compressed using bz2).
16
+
17
+ The bundle file can then be transferred using conventional means and
18
+ applied to another repository with the unbundle or pull command.
19
+ This is useful when direct push and pull are not available or when
20
+ exporting an entire repository is undesirable.
21
+
22
+ Applying bundles preserves all changeset contents including
23
+ permissions, copy/rename information, and revision history.
24
+
25
+ Options are:
26
+ EOS
27
+
28
+ c.opt :force, "Run even when remote repository is unrelated", :short => '-f'
29
+ c.opt :rev, "A changeset up to which you would like to bundle", :short => '-r', :type => :string
30
+ c.opt :base, "A base changeset to specify instead of a destination", :type => :string
31
+ c.opt :all, "Bundle all changesets in the repository", :short => '-a'
32
+ c.opt :type, "Bundle compression type to use (default: bzip2)", :short => '-t', :default => 'bzip2'
33
+ c.opt :ssh, "Specify ssh command to use", :short => '-e', :type => :string
34
+ c.opt :"remote-cmd", "Specify hg command to run on the remote side", :type => :string
35
+
36
+ c.on_run do |opts, args|
37
+ repo = opts[:repository]
38
+ rev = opts[:rev]
39
+ fname = args.shift
40
+ dest = args.shift
41
+
42
+ # Type notation!
43
+ # rev :: Amp::Changeset
44
+ rev = repo.lookup rev
45
+ base = repo.lookup(opts[:all] ? nil : opts[:base]) # --all overrides --base
46
+
47
+ if base
48
+ if dest
49
+ raise abort("--base is incompatible with specifiying a destination")
50
+ end
51
+
52
+ o = []
53
+ has = {Amp::RevlogSupport::Node::NULL_ID => nil}
54
+
55
+ # iterates over each file node id
56
+ base.each do |filename, node_id|
57
+ has.update repo.changelog.reachable_nodes_for_node(node_id)
58
+ end
59
+
60
+ visit = [rev]
61
+ seen = {} # {node => Boolean} where node is a string
62
+ add = proc do |node|
63
+ seen[node] = true
64
+ visit << node
65
+ end
66
+
67
+ until visit.empty?
68
+ n = visit.pop
69
+
70
+ # for those who are lame:
71
+ # rents = 'rents = parents
72
+ rents = repo.changelog.parents(n).select do |parental_unit|
73
+ !has.include?(parental_unit)
74
+ end
75
+
76
+ if rents.empty?
77
+ o.unshift n
78
+ else
79
+ rents.each {|rent| add[ rent ] unless seen.include? rent }
80
+ end # end if
81
+ end # end until
82
+ else
83
+ path = c.expand_path dest || 'default-push', dest || 'default', repo.config
84
+ dest, revs, checkout = *c.parse_url(path, [rev])
85
+ # alio is Esperanto for "other"; it's conveniently the same length as repo
86
+ alio = Amp::Repositories.pick nil, dest
87
+ o = repo.find_outgoing_roots alio, :force => opts[:force]
88
+ end # end if
89
+
90
+ # Oh no, bitches! If you thought we were done, you'd be wrong.
91
+ # Nevermind, false alarm. Turns out there's not that much left to do.
92
+
93
+ cg = if revs
94
+ p [o, rev]
95
+ repo.changegroup_subset o, [rev], 'bundle'
96
+ else
97
+ repo.changegroup o, 'bundle'
98
+ end
99
+
100
+ # these few lines convert nice human speak to icky computer speak
101
+ bundle_type = opts[:type].downcase
102
+ btypes = {'none' => 'HG10UN', 'bzip2' => 'HG10BZ', 'gzip' => 'HG10GZ'}
103
+ bundle_type = btypes[bundle_type]
104
+
105
+ # some error checking
106
+ # yes, this calls Array#include, but the array is only 3 elements
107
+ unless Amp::RevlogSupport::ChangeGroup::BUNDLE_TYPES.include? bundle_type
108
+ raise abort('unknown bundle type specified with --type')
109
+ end
110
+
111
+ File.open fname, 'w' do |file|
112
+ Amp::RevlogSupport::ChangeGroup.write_bundle cg, bundle_type, file
113
+ end
114
+ end # end on_run
115
+ end
@@ -0,0 +1,95 @@
1
+ command :clone do |c|
2
+ c.workflow :hg
3
+ c.desc "Clone a repository"
4
+ c.opt :pull, "Whether to do a pull from the destination (the alternative is to stream)", :short => '-p'
5
+ c.opt :stream, "stream raw data uncompressed from repository", :short => '-u'
6
+ c.opt :rev, "revision to clone up to (implies pull=True)", :short => '-r'
7
+ c.opt :"no-update", "Don't do an update after cloning, leaving the directory, if local, empty"
8
+
9
+ c.help <<-HELP
10
+ amp clone [options]+ src dest
11
+
12
+ Make a copy of an existing repository.
13
+
14
+ Create a copy of an existing repository in a new directory. The
15
+ source and destination are URLs, as passed to the repository
16
+ function. Returns a pair of repository objects, the source and
17
+ newly created destination.
18
+
19
+ The location of the source is added to the new repository's
20
+ .hg/hgrc file, as the default to be used for future pulls and
21
+ pushes.
22
+
23
+ If an exception is raised, the partly cloned/updated destination
24
+ repository will be deleted.
25
+
26
+ Where options are:
27
+ HELP
28
+
29
+ c.on_run do |opts, args|
30
+ require 'uri'
31
+
32
+ src, rev, checkout = *c.parse_url(args.shift) # get the source url, revisions we want, and the checkout
33
+ # puts [src, rev, checkout].inspect
34
+ source = Amp::Repositories.pick opts[:global_config], src # make it an actual repository
35
+ dest = (dest = args.shift) || File.basename(src) # get the destination URL
36
+
37
+ Amp::UI::status "destination directory: #{dest}"
38
+
39
+ # at this point, source is an {Amp::Repository} and dest is a {String}
40
+ begin
41
+ src = c.local_path src
42
+ dest = c.local_path dest
43
+ copy = false
44
+
45
+ raise Amp::Repositories::RepoError.new("destination #{dest} already exists") if File.exist? dest
46
+
47
+ if source.can_copy? and ['file', nil].include? URI.parse(dest).scheme
48
+ copy = !opts[:pull] && rev.empty?
49
+ end
50
+
51
+ if ['file', nil].include? URI.parse(dest).scheme # then it's local
52
+
53
+ if source.local? && copy # then we're copying
54
+ FileUtils.copy_entry src, dest # copy everything, pray it's pristine
55
+ dest_repo = Amp::Repositories::LocalRepository.new dest, false, opts[:global_config]
56
+ else # we have to pull
57
+ # make the directory, cd into it, pull, and maaaaaaybe update
58
+ dest_repo = Amp::Repositories::LocalRepository.new dest, true, opts[:global_config]
59
+ dest_repo.clone source, :revs => (rev ? rev.map {|r| source.lookup r } : []),
60
+ :stream => opts[:stream] # the actual cloning which pulls
61
+ end
62
+
63
+ else
64
+
65
+ # we're cloning ourselves to a faraway land
66
+ # which DOESN'T HAPPEN unless source is local
67
+ # remote - remote cloning just isn't supported in mercurial
68
+ if source.local?
69
+ dest_repo = Amp::Repositories.pick opts[:global_config], dest
70
+ source.push dest_repo, :revs => rev.map {|r| source.lookup r }
71
+ else
72
+ raise Amp::RepoError.new("Remote -> Remote cloning is not yet supported")
73
+ end
74
+
75
+ end
76
+
77
+ # NOW we write the hgrc file if the dest is local
78
+ if dest_repo.local?
79
+ dest_repo.hg_opener.open('hgrc', 'w') do |f|
80
+ f.puts '[paths]'
81
+ f.puts "default = #{File.expand_path(src).gsub('%', '%%')}"
82
+ end
83
+
84
+ if opts[:update]
85
+ Amp::UI::status "updating working directory"
86
+ dest_repo.update if opts[:update] # and here we add the files if we want to
87
+ end
88
+ end
89
+
90
+ [source, dest_repo]
91
+ rescue
92
+ FileUtils.remove_entry dest # kill the dir if we've had any problems
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,42 @@
1
+ command :commit do |c|
2
+ c.workflow :hg
3
+
4
+ c.desc "Commit yo shit"
5
+ c.opt :force, "Forces files to be committed", :short => "-f"
6
+ c.opt :include, "Includes the given patterns", :short => "-I", :type => :string
7
+ c.opt :exclude, "Ignores the given patterns", :short => "-E", :type => :string
8
+ c.opt :message, "The commit message", :short => "-m", :type => :string
9
+ c.opt :user, "The user committing the revision", :short => "-u", :type => :string
10
+ c.opt :date, "The date of the commit", :short => "-d", :type => :string
11
+ c.synonym :ci
12
+ c.help <<-EOS
13
+ amp commit [options]+ [FILE]+
14
+
15
+ Commit changes to the given files into the repository.
16
+
17
+ If a list of files is omitted, all changes reported by "amp status"
18
+ will be committed.
19
+
20
+ If you are committing the result of a merge, do not provide any
21
+ file names or -I/-X filters.
22
+
23
+ If no commit message is specified, the configured editor is started to
24
+ prompt you for a message.
25
+
26
+ amp commit [FILE]+ [options]
27
+
28
+ Where options are:
29
+ EOS
30
+
31
+ c.on_run do |opts, args|
32
+ repo = opts[:repository]
33
+
34
+ files = args
35
+ included = opts[:include]
36
+ excluded = opts[:exclude]
37
+ extra = {}
38
+ match = Amp::Match.create(:files => files, :includer => included, :excluder => excluded) { !files.any? }
39
+ opts.merge! :match => match, :extra => extra
40
+ repo.commit opts
41
+ end
42
+ end
@@ -0,0 +1,31 @@
1
+ command :copy do |c|
2
+ c.workflow :hg
3
+ c.desc "Copies a file from one location to another, while maintaining history"
4
+ c.opt :force, "Forces the copy, ignoring overwrites", :short => "-f"
5
+ c.opt :"dry-run", "Doesn't actually move files - only prints what would happen", :short => "-n"
6
+ c.opt :verbose, "Prints more output than normal", :short => "-v"
7
+ c.synonym :cp
8
+ c.before do |opts, args|
9
+ if args.size < 2
10
+ Amp::UI.say "Usage: amp copy source [other-sources...] destination"
11
+ c.break
12
+ elsif args.size > 2 && !File.directory?(args.last)
13
+ Amp::UI.say "If you want to copy more than 1 file, your destination must" +
14
+ " be a directory."
15
+ c.break
16
+ end
17
+ true
18
+ end
19
+
20
+ c.on_run do |opts, args|
21
+ repo = opts[:repository]
22
+
23
+ sources = args[0..-2]
24
+ destination = args.last
25
+ sources.each do |source|
26
+ repo.copy source, destination, opts
27
+ end
28
+ end
29
+ end
30
+
31
+
@@ -0,0 +1,32 @@
1
+ namespace :debug do
2
+ command :dirstate do |c|
3
+ c.workflow :hg
4
+
5
+ c.desc "Shows the current state of the working directory, as amp sees it."
6
+ c.opt :"no-dates", "Do not show modification dates", :short => "-D"
7
+
8
+ c.on_run do |opts, args|
9
+ repo = opts[:repository]
10
+ showdates = !opts[:"no-dates"]
11
+ time = ""
12
+
13
+ repo.dirstate.files.sort.each do |file, ent|
14
+ if showdates
15
+ # fuck locales for now....
16
+ timetouse = ent.mtime == -1 ? 0 : ent.mtime
17
+ time = Time.at(timetouse).strftime("%Y-%m-%d %H:%M:%S")
18
+ end
19
+ if ent.mode & 020000 != 0
20
+ mode = 'lnk'
21
+ else
22
+ mode = (ent.mode & 0777).to_s(8)
23
+ end
24
+ Amp::UI.say "#{ent.status}\t#{mode.to_s.rjust(3)} #{ent.size.to_s.rjust(10)} #{time} #{file}"
25
+ end
26
+
27
+ repo.dirstate.copy_map.each do |key, value|
28
+ Amp::UI.say "copy: #{value} -> #{key}"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,36 @@
1
+ namespace :debug do
2
+
3
+ command :index do |c|
4
+ c.workflow :hg
5
+
6
+ c.desc "Dumps the index of an index file"
7
+
8
+ c.on_run do |opts, args|
9
+ opener = Amp::Opener.new(Dir.pwd)
10
+ opener.default = :open_file
11
+ args.each do |index_file|
12
+ Amp::UI.say "Index: #{index_file}"
13
+ Amp::UI.say "|---------|------------|------------|----------|-----------|--------------|--------------|--------------|"
14
+ Amp::UI.say "| rev | offset | length | base | linkrev | nodeid | parent1 | parent2 |"
15
+ Amp::UI.say "|---------|------------|------------|----------|-----------|--------------|--------------|--------------|"
16
+ revlog = Amp::Revlog.new(opener, index_file)
17
+ idx = 0
18
+ revlog.each do |entry|
19
+ node = entry.node_id
20
+ parents = revlog.parents_for_node(node) || (["\0" * 20] * 2)
21
+ Amp::UI.say "|#{idx.to_s.ljust(9)}|"+
22
+ "#{revlog.data_start_for_index(idx).to_s.ljust(12)}|"+
23
+ "#{revlog[idx].compressed_len.to_s.ljust(12)}|" +
24
+ "#{revlog[idx].base_rev.to_s.ljust(10)}|"+
25
+ "#{revlog[idx].link_rev.to_s.ljust(11)}|"+
26
+ " #{node.hexlify[0..11]} |"+
27
+ " #{parents[0].hexlify[0..11]} |"+
28
+ " #{parents[1].hexlify[0..11]} |"
29
+ idx += 1
30
+ end
31
+ Amp::UI.say "|---------|------------|------------|----------|-----------|--------------|--------------|--------------|"
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ command :default do |c|
2
+ c.workflow :hg
3
+ c.desc "run the `info` and `status` commands"
4
+
5
+ c.on_run do |options, args|
6
+ Amp::Command['info'].run options, args
7
+ Amp::Command['status'].run options, args
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ command :diff do |c|
2
+ c.desc "Shows the differences between changesets"
3
+ c.opt :"no-color", "Turns off colored formatting", :short => "-c"
4
+ c.opt :rev, "Specifies a revision for diffing.", :short => "-r", :multi => true, :type => :integer
5
+ c.on_run do |opts, args|
6
+ repo = opts[:repository]
7
+ revs = opts[:rev] || []
8
+
9
+ revs << "tip" if revs.size == 0
10
+ revs << nil if revs.size == 1
11
+
12
+ revs.map! {|key| repo[key]}
13
+
14
+ differences = repo.status(:node_1 => revs[0], :node_2 => revs[1])
15
+ files = differences[:added] + differences[:removed] + differences[:deleted] + differences[:modified]
16
+
17
+ files.each do |filename|
18
+ vf_old, vf_new = revs.map {|rev| rev.get_file filename}
19
+ date_old, date_new = revs.map {|rev| rev.easy_date }
20
+ path_old, path_new = vf_old.path, vf_new.path || "/dev/null"
21
+ rev_old, rev_new = vf_old.file_rev, vf_new.file_rev
22
+
23
+ diff = vf_new.file_log.unified_revision_diff rev_old, date_old, rev_new,
24
+ date_new, path_old, path_new,
25
+ :pretty => !opts[:"no-color"]
26
+ Amp::UI::say diff
27
+ end
28
+
29
+ end
30
+ end