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,11 @@
1
+ command :forget do |c|
2
+ c.workflow :hg
3
+ c.desc "Stop tracking a file"
4
+
5
+ c.on_run do |opts, args|
6
+ repo = opts[:repository]
7
+
8
+ puts "Forgetting #{args.size} file#{args.size == 1 ? '' : 's'}"
9
+ repo.forget args
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ command :heads do |c|
2
+ c.workflow :hg
3
+ c.desc "Prints the heads of the repository."
4
+ c.opt :rev, "show only heads which are descendants of rev", {:short => "-r"}
5
+ c.opt :active, "show only active heads", {:short => "-a"}
6
+ c.opt :template, "Which template to use while printing", {:short => "-t", :type => :string, :default => "default"}
7
+
8
+ c.on_run do |options, args|
9
+ repo = options[:repository]
10
+ start = options[:rev] ? repo.lookup(options[:rev]) : nil
11
+ closed = options[:active]
12
+
13
+ if args.size == 0
14
+ heads = repo.heads start, :closed => closed
15
+ else
16
+ #branch shit
17
+ end
18
+
19
+ options.merge! :template_type => :log
20
+ heads.each do |n|
21
+ Amp::UI::say repo[n].to_templated_s(options)
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ command :identify do |c|
2
+ c.workflow :hg
3
+ c.desc "Identifies the current (or another) revision"
4
+ c.opt :num, "show local revision number", :short => "-n"
5
+ c.opt :id, "show global revision ID", :short => "-i"
6
+ c.opt :branch, "show branch", :short => "-b"
7
+ c.opt :tags, "show tags", :short => "-t"
8
+ c.opt :rev, "specifies which revision to report upon", :type => :string, :short => "-r"
9
+ c.on_run do |opts, args|
10
+ repo = opts[:repository]
11
+ opts[:id] = opts[:num] = true unless opts[:num] || opts[:id] || opts[:branch] || opts[:tags]
12
+ working_changeset = repo[nil]
13
+ parent_changeset = working_changeset.parents.first
14
+
15
+ Amp::UI.tell parent_changeset.node_id.short_hex + " " if opts[:id]
16
+ Amp::UI.tell parent_changeset.revision.to_s + " " if opts[:num]
17
+ Amp::UI.tell parent_changeset.branch + " " if opts[:branch]
18
+ Amp::UI.tell parent_changeset.tags.join(" ") + " " if opts[:tags]
19
+
20
+ Amp::UI.say
21
+
22
+ end
23
+ end
@@ -0,0 +1,135 @@
1
+ command :import do |c|
2
+ c.workflow :hg
3
+ c.desc "Import an ordered set of patches"
4
+ c.help <<-EOS
5
+ amp import [options]+ [FILE]+
6
+
7
+ Import a list of patches and commit them individually.
8
+
9
+ If there are outstanding changes in the working directory, import
10
+ will abort unless given the -f flag.
11
+
12
+ You can import a patch straight from a mail message. Even patches
13
+ as attachments work (body part must be type text/plain or
14
+ text/x-patch to be used). From and Subject headers of email
15
+ message are used as default committer and commit message. All
16
+ text/plain body parts before first diff are added to commit
17
+ message.
18
+
19
+ If the imported patch was generated by amp export, user and description
20
+ from patch override values from message headers and body. Values
21
+ given on command line with -m and -u override these.
22
+
23
+ If --exact is specified, import will set the working directory
24
+ to the parent of each patch before applying it, and will abort
25
+ if the resulting changeset has a different ID than the one
26
+ recorded in the patch. This may happen due to character set
27
+ problems or other deficiencies in the text patch format.
28
+
29
+ With --similarity, amp will attempt to discover renames and copies
30
+ in the patch in the same way as 'addremove'.
31
+
32
+ To read a patch from standard input, use patch name "-".
33
+
34
+ Where options are:
35
+ EOS
36
+
37
+ c.on_run do |opts, args|
38
+ require 'date'
39
+ require 'open-uri'
40
+
41
+ repo = opts[:repository]
42
+ patches = args
43
+
44
+ opts[:date] &&= DateTime.parse(opts[:date])
45
+ opts[:similarity] = Float(opts[:similarity] || 0)
46
+
47
+ if opts[:similarity] < 0 || opts[:similarity] > 100
48
+ raise abort('similarity must be between 0 and 100')
49
+ end
50
+
51
+ if opts[:exact] || !opts[:force]
52
+ raise abort("Outstanding changes or uncommitted merges exist") if repo.changed?
53
+ end
54
+
55
+ d = opts[:base]
56
+ strip = opts[:strip]
57
+ repo.lock_working_and_store do
58
+ patches.each do |patch|
59
+ patch_file = File.join d, patch
60
+
61
+ if patch_file == '-'
62
+ Amp::UI.status 'applying patch from STDIN'
63
+ patch_file = $stdin
64
+ else
65
+ Amp::UI.status "applying #{patch_file}"
66
+ patch_file = Kernel.open patch_file # uses open-uri's version of #open
67
+ end
68
+
69
+ data = Amp::Patch.extract patch_file
70
+ # python uses an array for this:
71
+ # tmpname, message, user, date, branch, nodeid, p1, p2 = *data
72
+ # WRONG BITCH! We're using a hash
73
+ raise abort('no patch found') if data[:tmp_name].nil?
74
+
75
+ begin
76
+ message = if (msg = c.log_message opts[:message], opts[:log_file])
77
+ msg
78
+ elsif !data[:message].empty?
79
+ data[:message].strip
80
+ end # defaults to nil
81
+ Amp::UI.debug "message: #{message}"
82
+
83
+ wp = repo.parents
84
+ if opts[:exact]
85
+ raise abort('not a mercurial patch') unless data[:node_id] && data[:p1]
86
+ p1 = repo.lookup data[:p1]
87
+ p2 = repo.lookup data[:p2] || Amp::RevlogSupport::Node::NULL_ID.hexlify
88
+
89
+ repo.update(p1, false, true, nil).success? if p1 != wp.first.node
90
+ repo.dirstate.parents = [p1, p2]
91
+ elsif p2
92
+ begin
93
+ p1 = repo.lookup p1
94
+ p2 = repo.lookup p2
95
+ repo.dirstate.parents = [p1, p2] if p1 == wp[0].node
96
+ rescue Amp::RepoError
97
+ # Do nothing...
98
+ end
99
+ end
100
+
101
+ if opts[:exact] || opts[:"import-branch"]
102
+ repo.dirstate.branch = data[:branch] || 'default'
103
+ end
104
+
105
+ files = {}
106
+ begin
107
+ fuzz = Amp::Patch.patch data[:tmp_name], :strip => data[:strip],
108
+ :cwd => repo.root ,
109
+ :file => files
110
+ ensure
111
+ files = Amp::Patch.update_dir repo, files, opts.pick(:similarity)
112
+ end
113
+
114
+ unless opts[:"no-commit"]
115
+ n = repo.commit files, :message => message ,
116
+ :user => opts[:user] || data[:user],
117
+ :date => opts[:date] || data[:date]
118
+ if opts[:exact]
119
+ if n.hexlify != data[:node_id]
120
+ repo.rollback!
121
+ raise abort('patch is damaged or loses information')
122
+ end
123
+ end
124
+
125
+ # Force a dirstate write so that the next transaction
126
+ # backups an up-do-date file.
127
+ repo.dirstate.write
128
+ end
129
+ ensure
130
+ File.safe_unlink data[:tmp_name]
131
+ end
132
+ end
133
+ end
134
+ end # end on_run
135
+ end
@@ -0,0 +1,85 @@
1
+ command :incoming do |c|
2
+ c.workflow :hg
3
+ c.desc "Show new changesets found in source"
4
+
5
+ c.help <<-HELP
6
+ amp incoming [options]+ source
7
+
8
+ Show new changesets found in the specified path/URL or the default
9
+ pull location. These are the changesets that would be pulled if a pull
10
+ was requested.
11
+
12
+ For remote repository, using --bundle or -b avoids downloading the changesets
13
+ twice if the incoming is followed by a pull.
14
+
15
+ See pull for valid source format details.
16
+ HELP
17
+
18
+ c.opt :force, "Run even when remote repository is unrelated", :short => '-f'
19
+ c.opt :"newest-first", "Show newest record first", :short => '-n'
20
+ c.opt :bundle, "File to store the bundles into", :short => '-b', :type => :string
21
+ c.opt :rev, "A specific revision up to which you would like to pull", :short => '-r', :type => :string
22
+ c.opt :patch, "Show patch", :short => '-p'
23
+ c.opt :limit, "Limit number of changes displayed", :short => '-l'
24
+ c.opt :"no-merges", "Do not show merges", :short => '-M'
25
+ c.opt :style, "Display using template map file", :short => '-s'
26
+ c.opt :template, "Which template to use while printing", {:short => "-t", :type => :string, :default => "default"}
27
+
28
+ c.opt :ssh, "Specify ssh command to use", :short => '-e'
29
+ c.opt :remotecmd, "Specify hg command to run on the remote side", :short => '-c'
30
+
31
+ c.on_run do |opts, args|
32
+ repo = opts[:repository]
33
+
34
+ url = args.shift || repo.config['paths', 'default-push'] || repo.config['paths', 'default']
35
+ url = Amp::Support::parse_hg_url url, opts[:rev]
36
+ #source, revs, checkout
37
+
38
+ remote = Amp::Repositories.pick opts[:global_config], url[:url]
39
+ Amp::UI::status "comparing with #{url[:url].hide_password}"
40
+
41
+ url[:revs] = url[:revs].map {|r| remote.lookup r } if url[:revs] && url[:revs].any?
42
+ common, incoming, remote_heads = *repo.common_nodes(remote, :heads => url[:revs],
43
+ :force => opts[:force])
44
+
45
+
46
+ if incoming.empty?
47
+ File.safe_unlink opts[:bundle]
48
+ Amp::UI::status 'no changes found'
49
+ break
50
+ end
51
+
52
+ cleanup = nil
53
+ file = opts[:bundle]
54
+
55
+ if file || !remote.local?
56
+ # create a bundle (uncompressed if the other repo is not local)
57
+
58
+ url[:revs] = remote_heads if url[:revs].nil? && remote.capable?('changegroupsubset')
59
+ cg = if url[:revs].nil? || !url[:revs].any?
60
+ remote.changegroup incoming, 'incoming'
61
+ else
62
+ remote.changegroup_subset incoming, url[:revs], 'incoming'
63
+ end
64
+
65
+ bundle_type = (remote.local? && "HG10GZ") || "HG10UN" # ???
66
+ require 'tempfile'
67
+ file = Tempfile.new("hg-incoming-bundle", Dir.pwd)
68
+ Amp::RevlogSupport::ChangeGroup.write_bundle(cg, bundle_type, file)
69
+ cleanup = file.path
70
+ unless remote.local?
71
+ remote = Amp::Repositories::BundleRepository.new(repo.root, opts[:global_config], cleanup)
72
+ end
73
+ end
74
+ opts.merge! :template_type => :log
75
+ remote.changelog.nodes_between(incoming, url[:revs])[:between].each do |n|
76
+ puts remote[n].to_templated_s(opts)
77
+ end
78
+
79
+ if remote.respond_to?(:close)
80
+ remote.close
81
+ end
82
+ #File.safe_unlink cleanup if cleanup
83
+
84
+ end
85
+ end
@@ -0,0 +1,18 @@
1
+ command :info do |c|
2
+ c.workflow :hg
3
+ c.desc "Print information about one or more changesets"
4
+ c.opt :template, "Which template to use while printing", {:short => "-t", :type => :string, :default => "default"}
5
+
6
+ c.on_run do |opts, args|
7
+ #arguments are the revisions
8
+ repo = opts[:repository]
9
+
10
+ args.empty? && args = ['tip']
11
+ opts.merge! :template_type => :log
12
+
13
+ args.each do |arg|
14
+ index = arg
15
+ puts repo[index].to_templated_s(opts)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ command :log do |c|
2
+ c.workflow :hg
3
+ c.desc "Prints the commit history."
4
+ c.add_opt :verbose, "Verbose output", {:short => "-v"}
5
+ c.add_opt :limit, "Limit how many revisions to show", {:short => "-l", :type => :integer, :default => -1}
6
+ c.add_opt :template, "Which template to use while printing", {:short => "-t", :type => :string, :default => "default"}
7
+ c.add_opt :no_output, "Doesn't print output (useful for benchmarking)"
8
+ c.on_run do |options, args|
9
+ repo = options[:repository]
10
+ limit = options[:limit]
11
+ limit = repo.size if limit == -1
12
+
13
+ start = repo.size - 1
14
+ stop = start - limit + 1
15
+
16
+ options.merge! :template_type => :log
17
+ start.downto stop do |x|
18
+ puts repo[x].to_templated_s(options) unless options[:no_output]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ command :manifest do |c|
2
+ c.workflow :hg
3
+ c.desc "Prints the manifest at a given revision (defaults to working directory)"
4
+ c.add_opt :rev, "Specifies the revision to check", {:short => "-r", :type => :integer}
5
+ c.on_run do |options, arguments|
6
+ revision = options[:rev] || "tip"
7
+ repo = options[:repository]
8
+
9
+ repo[revision].each do |k, _|
10
+ puts "#{k}"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,53 @@
1
+ command :merge do |c|
2
+ c.workflow :hg
3
+
4
+ c.desc "merge working directory with another revision"
5
+ c.opt :force, "force a merge with outstanding changes", :short => "-f"
6
+ c.opt :rev, "revision to merge", :type => :integer, :short => "-r"
7
+
8
+ c.before do |opts, args|
9
+ repo = opts[:repository]
10
+ if !opts[:rev]
11
+ branch = repo[nil].branch
12
+ bheads = repo.branch_heads[branch]
13
+ if bheads.size > 2
14
+ raise abort("branch #{branch} has #{bheads.size} - please merge " +
15
+ " with an explicit revision")
16
+ c.break
17
+ end
18
+ parent = repo.dirstate.parents.first
19
+ if bheads.size == 1
20
+ if repo.heads.size > 1
21
+ raise abort("branch #{branch} has one head - please merge with " +
22
+ "an explicit revision")
23
+ c.break
24
+ end
25
+ message = "there is nothing to merge"
26
+ if parent != repo.lookup(repo[nil].branch)
27
+ message = "#{message} - use \"amp update\" instead"
28
+ end
29
+ raise abort(message)
30
+ end
31
+ unless bheads.include? parent
32
+ raise abort("working dir not at a head revision - use \"amp update\" or "+
33
+ "merge with an explicit revision" + bheads.inspect)
34
+ end
35
+ opts[:node] = (parent == bheads.first) ? bheads.last : bheads.first
36
+ end
37
+
38
+ true
39
+ end
40
+
41
+ c.on_run do |opts, args|
42
+ repo = opts[:repository]
43
+ node = opts[:node]
44
+ stats = repo.update(node, true, opts[:force], false)
45
+ c.print_update_stats stats
46
+ if stats[:unresolved]
47
+ Amp::UI.status("use 'amp resolve' to retry unresolved file merges or use "+
48
+ "'amp update --clean' to abandon changes")
49
+ elsif true # check for a reminder setting to disable this remidner
50
+ Amp::UI.status("(branch merge, don't forget to commit)")
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,28 @@
1
+ command :move do |c|
2
+ c.workflow :hg
3
+ c.desc "Moves a file from one place to another"
4
+ c.opt :force, "Forces the move, ignoring overwrites", :short => "-f"
5
+ c.opt :"dry-run", "Doesn't actually move files - only prints what would happen", :short => "-n"
6
+
7
+ c.synonym :mv
8
+ c.synonym :rename
9
+
10
+ c.before do |opts, args|
11
+ if args.size < 2
12
+ Amp::UI.say "Usage: amp move source destination"
13
+ c.break
14
+ elsif args.size > 2 && !File.directory?(args.last)
15
+ Amp::UI.say "If you want to move more than 1 file, your destination must" +
16
+ " be a directory."
17
+ c.break
18
+ end
19
+ true
20
+ end
21
+
22
+ c.on_run do |opts, args|
23
+ opts.merge!(:rename => true)
24
+ Amp::Command["copy"].run(opts, args)
25
+ end
26
+ end
27
+
28
+
@@ -0,0 +1,61 @@
1
+ command :outgoing do |c|
2
+ c.workflow :hg
3
+ c.opt :limit, "How much of the logs to show", :short => '-l', :type => :integer
4
+ c.opt :rev, "Revision to clone up to (implies pull=True)", :short => '-r', :type => :integer
5
+ c.opt :force, "Force getting new heads", :short => '-f'
6
+ c.opt :"newest-first", 'Show the newest heads first'
7
+ c.opt :"no-merges", "Don't show merges"
8
+ c.desc "Prints the list of all changesets that can be pushed"
9
+ c.help <<-HELP
10
+ amp outgoing [options]+ dest
11
+ show changesets not found in destination
12
+
13
+ Show changesets not found in the specified destination repository or
14
+ the default push location. These are the changesets that would be pushed
15
+ if a push was requested.
16
+
17
+ See pull for valid destination format details.
18
+ HELP
19
+
20
+ c.on_run do |opts, args|
21
+ repo = opts[:repository]
22
+
23
+ dest = args.shift
24
+ path = c.expand_path dest || 'default-push', dest || 'default', repo.config
25
+ url = Amp::Support::parse_hg_url path, opts[:rev]
26
+ # dest, revs, checkout
27
+ if url[:revs] && url[:revs].any? # url[:revs] isn't guaranteed to be an array
28
+ url[:revs] = url[:revs].map {|r| repo.lookup rev }
29
+ end
30
+
31
+ remote = Amp::Repositories.pick nil, url[:url]
32
+ Amp::UI::status "comparing with #{url[:url].hide_password}"
33
+
34
+ o = repo.find_outgoing_roots remote, :force => opts[:force]
35
+ (Amp::UI::status "no changes found"; return 1) if o.empty?
36
+
37
+ o = repo.changelog.nodes_between(o, url[:revs])[:between]
38
+
39
+ # reverse the order, because the newest are usually last
40
+ # this is noticed if you get bitbucket email notifications
41
+ o.reverse! if opts[:"newest-first"]
42
+
43
+ # trim the list if it's bigger than our limit
44
+ o = opts[:limit] ? o[0..opts[:limit]-1] : o
45
+
46
+ Amp::UI::say # give us some space
47
+
48
+ # print each changeset using the template in templates/
49
+ o.each do |node_id|
50
+ # get the parents of the node so that we can check if it's a merge
51
+ # (merges have two parents)
52
+ parents = repo.changelog.parents(node_id).select {|p| p.not_null? }
53
+
54
+ # We skip printing this if it's a merge (parents.size == 2)
55
+ # and we're NOT printing merges (opts[:"no-merges"])
56
+ next if opts[:"no-merges"] && parents.size == 2
57
+ opts.merge! :template_type => :log
58
+ Amp::UI::tell repo[node_id].to_templated_s(opts)
59
+ end
60
+ end
61
+ end