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,74 @@
1
+ command :pull do |c|
2
+ c.workflow :hg
3
+ c.desc "Add a file to the repository (it will be tracked from here on)"
4
+ c.opt :update, "update to new tip if changesets were pulled", :short => "-u"
5
+ c.opt :force, "run even when remote repository is unrelated", :short => "-f"
6
+ c.opt :rev, "a specific revision up to which you would like to pull", :short => '-r',
7
+ :type => :string
8
+ c.opt :ssh, "specify ssh command to use", :short => '-e', :type => :string
9
+ c.opt :remotecmd, "specify amp command to run on the remote side", :type => :string
10
+
11
+ c.desc "pull changes from the specified source"
12
+ c.help <<-HELP
13
+ amp pull [options]+ src
14
+
15
+ Pull changes from a remote repository to a local one.
16
+
17
+ This finds all changes from the repository at the specified path
18
+ or URL and adds them to the local repository. By default, this
19
+ does not update the copy of the project in the working directory.
20
+
21
+ Valid URLs are of the form:
22
+
23
+ local/filesystem/path (or file://local/filesystem/path)
24
+ http://[user[:pass]@]host[:port]/[path]
25
+ https://[user[:pass]@]host[:port]/[path]
26
+ ssh://[user[:pass]@]host[:port]/[path]
27
+
28
+ Paths in the local filesystem can either point to Mercurial
29
+ repositories or to bundle files (as created by 'amp bundle' or
30
+ 'amp incoming --bundle').
31
+
32
+ An optional identifier after # indicates a particular branch, tag,
33
+ or changeset to pull.
34
+ HELP
35
+
36
+ c.on_run do |opts, args|
37
+ repo = opts[:repository]
38
+ dest = args.shift || repo.config["paths", "default-push"] || repo.config["paths", "default"]
39
+
40
+ if dest =~ /#/
41
+ dest, branch = dest.split('#')
42
+ else
43
+ branch = nil
44
+ end
45
+
46
+ remote = Amp::Repositories::pick repo.config, dest
47
+ Amp::UI::status "pulling from #{dest.hide_password}"
48
+
49
+ revs = opts[:rev] && [ remote.lookup(opts[:rev]) ]
50
+
51
+ mod_heads = repo.pull remote, :heads => revs, :force => opts[:force]
52
+
53
+ #
54
+ # Everything here is "post-incoming"
55
+ ####################################
56
+
57
+ unless mod_heads.zero?
58
+ if opts[:update]
59
+ if mod_heads <= 1 || repo.branch_heads.size == 1 || opts[:rev]
60
+ Amp::Command['update'].run( { :repository => repo } ,
61
+ { :rev => opts[:rev] } )
62
+ else
63
+ Amp::UI::status "not updating, since new heads were added"
64
+ end
65
+ end
66
+
67
+ if mod_heads > 1
68
+ Amp::UI::status "(run 'amp heads' to see heads, 'amp merge' to merge)"
69
+ else
70
+ Amp::UI::status "(run 'amp update' to get a working copy)"
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,20 @@
1
+ command :push do |c|
2
+ c.workflow :hg
3
+ c.desc "Pushes the latest revisions to the remote repository."
4
+ c.opt :remote, "The remote repository's URL", :short => "-R"
5
+ c.opt :revs, "The revisions to push", :short => "-r", :type => :string
6
+ c.opt :force, "Ignore remote heads", :short => "-f"
7
+
8
+ c.on_run do |opts, args|
9
+ repo = opts[:repository]
10
+ dest = opts[:remote] || repo.config["paths","default-push"] || repo.config["paths","default"]
11
+ opts[:revs] ||= nil
12
+ remote = Amp::Support.parse_hg_url(dest, opts[:revs])
13
+ dest, revs, checkout = remote[:url], remote[:revs], remote[:head]
14
+ remote_repo = Amp::Repositories.pick(repo.config, dest, false)
15
+
16
+ revs = revs.map {|rev| repo.lookup rev } if revs
17
+
18
+ result = repo.push remote_repo, :force => opts[:force], :revs => revs
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ command :remove do |c|
2
+ c.workflow :hg
3
+ c.desc "Removes files from the repository on next commit"
4
+ c.opt :after, "record as delete for missing files (whether or not to actually delete files)", :short => "-A", :default => false
5
+ c.opt :force, "Forces removal of files", :short => "-f", :default => false
6
+ c.opt :include, "include names matching the given patterns", :short => "-I", :type => :string
7
+ c.opt :exclude, "exclude names matching the given patterns", :short => "-X", :type => :string
8
+
9
+ c.synonym :rm, :nuke
10
+ c.on_run do |opts, args|
11
+ repo = opts[:repository]
12
+ list = args
13
+ list = list.map {|p| repo.relative_join(p) }
14
+
15
+ match = Amp::Match.create :files => list, :includer => opts[:include], :excluder => opts[:exclude]
16
+ s = repo.status(:match => match, :clean => true)
17
+ modified, added, deleted, clean = s[:modified], s[:added], s[:deleted], s[:clean]
18
+
19
+ if opts[:force]
20
+ remove, forget = modified + clean, added
21
+ elsif opts[:after]
22
+ remove, forget = deleted, []
23
+ (modified + added + clean).each {|p| Amp::UI.warn "#{p} still exists" }
24
+ else
25
+ remove, forget = deleted + clean, []
26
+ modified.each {|p| Amp::UI.warn "not removing #{p} - file is modified (use -f)" }
27
+ added.each {|p| Amp::UI.warn "not removing #{p} - file is marked for add (use -f)" }
28
+ end
29
+
30
+ if opts[:verbose]
31
+ (remove + forget).sort.each {|f| Amp::UI.status "removing #{f}..." }
32
+ end
33
+
34
+ repo.remove(remove, :unlink => ! opts[:after]) # forgetting occurs here
35
+ repo.forget(forget)
36
+
37
+ remove += forget
38
+
39
+ if remove.size == 1
40
+ Amp::UI.say "File #{remove.first.red} removed at #{Time.now}"
41
+ else
42
+ Amp::UI.say "#{remove.size.to_s.red} files removed at #{Time.now}"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,83 @@
1
+ command :resolve do |c|
2
+ c.workflow :hg
3
+ c.desc "Retry file merges, or mark files as successfully hand-merged"
4
+ c.opt :all, "Attempt to resolve (or mark) all unresolved files", :short => "-a"
5
+ c.opt :list, "List unresolved files", :short => "-l"
6
+ c.opt :mark, "Mark file(s) as resolved", :short => "-m"
7
+ c.opt :unmark, "Mark file(s) as unresolved", :short => "-u"
8
+ c.opt :include, "Specify patterns of files to include in the operation", :short => "-I", :type => :string
9
+ c.opt :exclude, "Specify patterns of files to exclude in the operation", :short => "-E", :type => :string
10
+
11
+ c.before do |opts, args|
12
+ parse_args = lambda {|os| [:all, :mark, :unmark, :list].map {|i| os[i] } }
13
+
14
+ # Checks to make sure user input is valid
15
+ all, mark, unmark, list = *parse_args[ opts ]
16
+
17
+ if (list && (mark || unmark)) || (mark && unmark)
18
+ raise abort("too many options specified")
19
+ end
20
+
21
+ if all && (opts[:include] || opts[:exclude] || args.any?)
22
+ raise abort("can't specify --all and patterns or files")
23
+ end
24
+
25
+ if !(all || args.any? || opts[:include] || opts[:exclude] || mark || unmark || list)
26
+ raise abort("no files or directories specified; use --all to remerge all files")
27
+ end
28
+
29
+ true
30
+ end
31
+
32
+ c.on_run do |opts, args|
33
+ repo = opts[:repository]
34
+ parse_args = lambda {|os| [:all, :mark, :unmark, :list].map {|i| os[i] } }
35
+
36
+ all, mark, unmark, list = *parse_args[opts]
37
+ merge_state = Amp::Merges::MergeState.new(repo)
38
+
39
+ if opts[:all]
40
+ # the block means "default to true" - so basically ignore all other input
41
+ match = Amp::Match.create(:files => []) { true }
42
+ else
43
+ # the block means "default to false" - rely entirely on user input
44
+ match = Amp::Match.create(:includer => opts[:include],
45
+ :excluder => opts[:exclude],
46
+ :files => args) { false }
47
+ end
48
+
49
+ # iterate over each entry in the merge state file
50
+ merge_state.each do |file, status|
51
+ # check to see if our user wants this file
52
+ if match.call(file)
53
+ if list
54
+ Amp::UI.say "#{status.first} #{file}"
55
+ elsif mark
56
+ # the "r" means resolved
57
+ merge_state.mark(file, "r")
58
+ Amp::UI.say "#{file} marked as #{"resolved".blue}"
59
+ elsif unmark
60
+ # the "u" means unresolved
61
+ merge_state.mark(file, "u")
62
+ Amp::UI.say "#{file} marked as #{"unresolved".red}"
63
+ else
64
+ # retry the merge
65
+ working_changeset = repo[nil]
66
+ merge_changeset = working_changeset.parents.last
67
+
68
+ # backup the current file to a .resolve file (but retain the extension
69
+ # so editors that rely on extensions won't bug out)
70
+ path = repo.working_join file
71
+ File.copy(path, path + ".resolve" + File.extname(path))
72
+
73
+ # try to merge the files!
74
+ merge_state.resolve(file, working_changeset, merge_changeset)
75
+
76
+ # restore the backup to .orig (overwriting the old one)
77
+ File.move(path + ".resolve" + File.extname(path), path + ".orig" + File.extname(path))
78
+ end
79
+ end
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,53 @@
1
+ command :revert do |c|
2
+ c.workflow :hg
3
+ c.desc "Restore individual files or dirs to an earlier state"
4
+ c.opt :include, "include names matching the given patterns", :short => "-I", :type => :string
5
+ c.opt :exclude, "exclude names matching the given patterns", :short => "-X", :type => :string
6
+ c.opt :rev, "The revision to revert to", :short => "-r", :type => :integer
7
+ c.opt :all, "Revert entire repository", :short => "-a"
8
+ c.help <<-HELP
9
+ amp revert [options]+ [FILE]+
10
+
11
+ restore individual files or dirs to an earlier state
12
+
13
+ (use update -r to check out earlier revisions, revert does not
14
+ change the working dir parents)
15
+
16
+ With no revision specified, revert the named files or directories
17
+ to the contents they had in the parent of the working directory.
18
+ This restores the contents of the affected files to an unmodified
19
+ state and unschedules adds, removes, copies, and renames. If the
20
+ working directory has two parents, you must explicitly specify the
21
+ revision to revert to.
22
+
23
+ Using the -r option, revert the given files or directories to their
24
+ contents as of a specific revision. This can be helpful to "roll
25
+ back" some or all of an earlier change.
26
+ See 'amp help dates' for a list of formats valid for -d/--date.
27
+
28
+ Revert modifies the working directory. It does not commit any
29
+ changes, or change the parent of the working directory. If you
30
+ revert to a revision other than the parent of the working
31
+ directory, the reverted files will thus appear modified
32
+ afterwards.
33
+
34
+ If a file has been deleted, it is restored. If the executable
35
+ mode of a file was changed, it is reset.
36
+
37
+ If names are given, all files matching the names are reverted.
38
+ If no arguments are given, no files are reverted.
39
+
40
+ Modified files are saved with a .orig suffix before reverting.
41
+ To disable these backups, use --no-backup.
42
+
43
+ Options are:
44
+ HELP
45
+
46
+ c.on_run do |opts, args|
47
+ repo = opts[:repository]
48
+ list = args.map {|p| repo.relative_join(p) } # we assume they're files
49
+
50
+ repo.revert list, opts
51
+
52
+ end
53
+ end
@@ -0,0 +1,13 @@
1
+ command :root do |c|
2
+ c.workflow :hg
3
+ c.desc "Prints the current repository's root path."
4
+ c.help <<-EOF
5
+ amp root
6
+
7
+ Prints the path to the current repository's root.
8
+ EOF
9
+ c.on_run do |opts, args|
10
+ repo = opts[:repository]
11
+ puts repo.root
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+ command :serve do |c|
2
+ c.workflow :hg
3
+
4
+ c.desc "Starts an HTTP server (with an associated website) serving the repository"
5
+ c.opt :path, "The path section of the URL (e.g. /repository/served/)", :short => "-P", :type => :string
6
+ c.opt :port, "Which port to run the server on", :short => "-p", :type => :integer
7
+ c.opt :basic, "HTTP Basic Authentication (vs. Digest)", :short => "-b", :default => false
8
+ c.opt :private, "Should the server not be publicly readable?", :short => "-X", :default => false
9
+ c.opt :storage, "Store the users in [TYPE] manner. Can be 'sequel' or 'memory'", :short => "-s", :type => :string,
10
+ :default => 'memory'
11
+ c.opt :users, "File from which to read the users (YAML format)", :short => '-u', :type => :string
12
+
13
+ c.on_run do |opts, args|
14
+ repo = opts[:repository]
15
+ http_path = opts[:path] || "/"
16
+ auth = opts[:basic] ? :basic : :digest
17
+
18
+ server = Amp::Servers::FancyHTTPServer
19
+ server.set_authentication auth
20
+ server.amp_repository http_path, repo, {:title => repo.root }
21
+ server.set :port, opts[:port] if opts[:port]
22
+
23
+ server.set_storage opts[:storage]
24
+
25
+ file = YAML::load_file(opts[:users] || File.join(repo.hg, 'users')) rescue {:users => []}
26
+
27
+ perms = file[:users].map do |u|
28
+ [ u[:permission] ,
29
+ server << {:username => u[:username], :password => u[:password]} ]
30
+ end
31
+
32
+ perms.map {|(p, u)| server.set_permission p, repo, u }
33
+ server.set_private repo, opts[:private]
34
+
35
+ server.run!
36
+
37
+ end
38
+ end
@@ -0,0 +1,116 @@
1
+ command :status do |c|
2
+ c.workflow :hg
3
+
4
+ c.desc "Prints the status of the working directory (or another revision)"
5
+ c.opt :all, "Show all files", {:short => "-A"}
6
+ c.opt :modified, "Show only modified files", {:short => "-m"}
7
+ c.opt :added, "Show only added files", {:short => "-a"}
8
+ c.opt :deleted, "Show only deleted files", {:short => "-D"}
9
+ c.opt :removed, "Show only removed files", {:short => "-R"}
10
+ c.opt :clean, "Show only files without changes", {:short => "-c"}
11
+ c.opt :unknown, "Show only untracked files", {:short => "-u"}
12
+ c.opt :ignored, "Show only ignored files", {:short => "-i"}
13
+ c.opt :rev, "Selects which revision to use", {:short => "-r", :type => :string, :multi => true}
14
+ c.opt :hg, "Print the information in hg's style"
15
+ c.opt :"no-color","Don't use color to categorize the output"
16
+ c.opt :yaml, "Print the information in YAML format (for use with computers)", {:short => '-y'}
17
+ c.synonym :st
18
+
19
+ c.on_run do |options, args|
20
+ repo = options[:repository]
21
+ node1, node2 = *c.revision_pair(repo, options[:rev])
22
+ cwd = "" # use patterns later
23
+ stop = "\n"
24
+ copy = {}
25
+ colors = {'modified' => :cyan,
26
+ 'added' => :blue,
27
+ 'removed' => :red,
28
+ 'deleted' => :magenta,
29
+ 'unknown' => :green,
30
+ 'ignored' => :yellow,
31
+ 'clean' => :white
32
+ }
33
+ states = ['modified',
34
+ 'added' ,
35
+ 'removed' ,
36
+ 'deleted' ,
37
+ 'unknown' ,
38
+ 'ignored' ,
39
+ 'clean' ]
40
+ show = states.select {|k| options[k.to_sym] } # filter the list down
41
+
42
+ show = states if options[:all]
43
+ show = states[0..4] if show.empty?
44
+
45
+ statopts = {:node_1 => node1, :node_2 => node2 }
46
+
47
+ show.each {|switch| statopts[switch.to_sym] = true }
48
+
49
+ status = repo.status statopts
50
+
51
+ # this is the proc that does the printing. I have the code in a proc
52
+ # so that the logic is in a short screenful and isn't convoluted.
53
+ stdout_print = proc do
54
+ # PRINTING TIME!!!!!!!!
55
+ if options[:hg]
56
+ status_as_array = [status[:modified],
57
+ status[:added] ,
58
+ status[:removed] ,
59
+ status[:deleted] ,
60
+ status[:unknown] ,
61
+ status[:ignored] ,
62
+ status[:clean]
63
+ ]
64
+ changestates = states.zip("MAR!?IC".split(""), status_as_array)
65
+ changestates.each do |state, char, files|
66
+ if show.include? state
67
+ files.each do |f|
68
+ #Amp::Logger.info("#{char} #{f}")
69
+ if options[:"no-color"]
70
+ Amp::UI.tell "#{char} #{File.join(cwd, f.to_s)[1..-1]}#{stop}" unless f.nil?
71
+ else
72
+ Amp::UI.tell "#{char.send colors[state]} #{File.join(cwd, f.to_s)[1..-1]}#{stop}" unless f.nil?
73
+ end
74
+ end
75
+ end
76
+ end
77
+ else
78
+ # print it our way
79
+ show.each do |state|
80
+ next if status[state.to_sym].empty?
81
+ num_of_files = status[state.to_sym].size
82
+
83
+ if options[:"no-color"]
84
+ Amp::UI.say("#{state.upcase}" +
85
+ " => #{num_of_files} file#{num_of_files == 1 ? 's' : ''}")
86
+ else
87
+ Amp::UI.say("#{state.upcase.send colors[state]}" +
88
+ " => #{num_of_files} file#{num_of_files == 1 ? 's' : ''}")
89
+ end
90
+
91
+ status[state.to_sym].each do |file|
92
+ #Amp::Logger.info("#{state[0,1].upcase} #{file}")
93
+ Amp::UI.say "\t#{File.join(cwd, file)[1..-1]}"
94
+ end
95
+
96
+ end
97
+
98
+ Amp::UI.say
99
+ Amp::UI.say "#{status[:delta]} bytes were changed" if status[:delta]
100
+ end
101
+ end
102
+
103
+ yaml_printer = proc do
104
+ require 'yaml'
105
+ puts YAML::dump(status)
106
+ end
107
+
108
+ # printing logic
109
+ if options[:yaml]
110
+ yaml_printer[]
111
+ else
112
+ stdout_print[]
113
+ end
114
+
115
+ end
116
+ end