amp 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.hgignore +26 -0
- data/AUTHORS +2 -0
- data/History.txt +6 -0
- data/LICENSE +37 -0
- data/MANIFESTO +7 -0
- data/Manifest.txt +294 -0
- data/README.md +129 -0
- data/Rakefile +102 -0
- data/SCHEDULE.markdown +12 -0
- data/STYLE +27 -0
- data/TODO.markdown +149 -0
- data/ampfile.rb +47 -0
- data/bin/amp +30 -0
- data/bin/amp1.9 +30 -0
- data/ext/amp/bz2/README.txt +39 -0
- data/ext/amp/bz2/bz2.c +1582 -0
- data/ext/amp/bz2/extconf.rb +77 -0
- data/ext/amp/bz2/mkmf.log +29 -0
- data/ext/amp/mercurial_patch/extconf.rb +5 -0
- data/ext/amp/mercurial_patch/mpatch.c +405 -0
- data/ext/amp/priority_queue/extconf.rb +5 -0
- data/ext/amp/priority_queue/priority_queue.c +947 -0
- data/ext/amp/support/extconf.rb +5 -0
- data/ext/amp/support/support.c +250 -0
- data/lib/amp.rb +200 -0
- data/lib/amp/commands/command.rb +507 -0
- data/lib/amp/commands/command_support.rb +137 -0
- data/lib/amp/commands/commands/config.rb +143 -0
- data/lib/amp/commands/commands/help.rb +29 -0
- data/lib/amp/commands/commands/init.rb +10 -0
- data/lib/amp/commands/commands/templates.rb +137 -0
- data/lib/amp/commands/commands/version.rb +7 -0
- data/lib/amp/commands/commands/workflow.rb +28 -0
- data/lib/amp/commands/commands/workflows/git/add.rb +65 -0
- data/lib/amp/commands/commands/workflows/git/copy.rb +27 -0
- data/lib/amp/commands/commands/workflows/git/mv.rb +23 -0
- data/lib/amp/commands/commands/workflows/git/rm.rb +60 -0
- data/lib/amp/commands/commands/workflows/hg/add.rb +53 -0
- data/lib/amp/commands/commands/workflows/hg/addremove.rb +86 -0
- data/lib/amp/commands/commands/workflows/hg/annotate.rb +46 -0
- data/lib/amp/commands/commands/workflows/hg/archive.rb +126 -0
- data/lib/amp/commands/commands/workflows/hg/branch.rb +28 -0
- data/lib/amp/commands/commands/workflows/hg/branches.rb +30 -0
- data/lib/amp/commands/commands/workflows/hg/bundle.rb +115 -0
- data/lib/amp/commands/commands/workflows/hg/clone.rb +95 -0
- data/lib/amp/commands/commands/workflows/hg/commit.rb +42 -0
- data/lib/amp/commands/commands/workflows/hg/copy.rb +31 -0
- data/lib/amp/commands/commands/workflows/hg/debug/dirstate.rb +32 -0
- data/lib/amp/commands/commands/workflows/hg/debug/index.rb +36 -0
- data/lib/amp/commands/commands/workflows/hg/default.rb +9 -0
- data/lib/amp/commands/commands/workflows/hg/diff.rb +30 -0
- data/lib/amp/commands/commands/workflows/hg/forget.rb +11 -0
- data/lib/amp/commands/commands/workflows/hg/heads.rb +25 -0
- data/lib/amp/commands/commands/workflows/hg/identify.rb +23 -0
- data/lib/amp/commands/commands/workflows/hg/import.rb +135 -0
- data/lib/amp/commands/commands/workflows/hg/incoming.rb +85 -0
- data/lib/amp/commands/commands/workflows/hg/info.rb +18 -0
- data/lib/amp/commands/commands/workflows/hg/log.rb +21 -0
- data/lib/amp/commands/commands/workflows/hg/manifest.rb +13 -0
- data/lib/amp/commands/commands/workflows/hg/merge.rb +53 -0
- data/lib/amp/commands/commands/workflows/hg/move.rb +28 -0
- data/lib/amp/commands/commands/workflows/hg/outgoing.rb +61 -0
- data/lib/amp/commands/commands/workflows/hg/pull.rb +74 -0
- data/lib/amp/commands/commands/workflows/hg/push.rb +20 -0
- data/lib/amp/commands/commands/workflows/hg/remove.rb +45 -0
- data/lib/amp/commands/commands/workflows/hg/resolve.rb +83 -0
- data/lib/amp/commands/commands/workflows/hg/revert.rb +53 -0
- data/lib/amp/commands/commands/workflows/hg/root.rb +13 -0
- data/lib/amp/commands/commands/workflows/hg/serve.rb +38 -0
- data/lib/amp/commands/commands/workflows/hg/status.rb +116 -0
- data/lib/amp/commands/commands/workflows/hg/tag.rb +69 -0
- data/lib/amp/commands/commands/workflows/hg/tags.rb +27 -0
- data/lib/amp/commands/commands/workflows/hg/tip.rb +13 -0
- data/lib/amp/commands/commands/workflows/hg/update.rb +27 -0
- data/lib/amp/commands/commands/workflows/hg/verify.rb +9 -0
- data/lib/amp/commands/commands/workflows/hg/view.rb +36 -0
- data/lib/amp/commands/dispatch.rb +181 -0
- data/lib/amp/commands/hooks.rb +81 -0
- data/lib/amp/dependencies/amp_support.rb +1 -0
- data/lib/amp/dependencies/amp_support/ruby_amp_support.rb +103 -0
- data/lib/amp/dependencies/minitar.rb +979 -0
- data/lib/amp/dependencies/priority_queue.rb +18 -0
- data/lib/amp/dependencies/priority_queue/c_priority_queue.rb +1 -0
- data/lib/amp/dependencies/priority_queue/poor_priority_queue.rb +46 -0
- data/lib/amp/dependencies/priority_queue/ruby_priority_queue.rb +525 -0
- data/lib/amp/dependencies/python_config.rb +211 -0
- data/lib/amp/dependencies/trollop.rb +713 -0
- data/lib/amp/dependencies/zip/ioextras.rb +155 -0
- data/lib/amp/dependencies/zip/stdrubyext.rb +111 -0
- data/lib/amp/dependencies/zip/tempfile_bugfixed.rb +186 -0
- data/lib/amp/dependencies/zip/zip.rb +1850 -0
- data/lib/amp/dependencies/zip/zipfilesystem.rb +609 -0
- data/lib/amp/dependencies/zip/ziprequire.rb +90 -0
- data/lib/amp/encoding/base85.rb +97 -0
- data/lib/amp/encoding/binary_diff.rb +82 -0
- data/lib/amp/encoding/difflib.rb +166 -0
- data/lib/amp/encoding/mercurial_diff.rb +378 -0
- data/lib/amp/encoding/mercurial_patch.rb +1 -0
- data/lib/amp/encoding/patch.rb +292 -0
- data/lib/amp/encoding/pure_ruby/ruby_mercurial_patch.rb +123 -0
- data/lib/amp/extensions/ditz.rb +41 -0
- data/lib/amp/extensions/lighthouse.rb +167 -0
- data/lib/amp/graphs/ancestor.rb +147 -0
- data/lib/amp/graphs/copies.rb +261 -0
- data/lib/amp/merges/merge_state.rb +164 -0
- data/lib/amp/merges/merge_ui.rb +322 -0
- data/lib/amp/merges/simple_merge.rb +450 -0
- data/lib/amp/profiling_hacks.rb +36 -0
- data/lib/amp/repository/branch_manager.rb +234 -0
- data/lib/amp/repository/dir_state.rb +950 -0
- data/lib/amp/repository/journal.rb +203 -0
- data/lib/amp/repository/lock.rb +207 -0
- data/lib/amp/repository/repositories/bundle_repository.rb +214 -0
- data/lib/amp/repository/repositories/http_repository.rb +377 -0
- data/lib/amp/repository/repositories/local_repository.rb +2661 -0
- data/lib/amp/repository/repository.rb +94 -0
- data/lib/amp/repository/store.rb +485 -0
- data/lib/amp/repository/tag_manager.rb +319 -0
- data/lib/amp/repository/updatable.rb +532 -0
- data/lib/amp/repository/verification.rb +431 -0
- data/lib/amp/repository/versioned_file.rb +475 -0
- data/lib/amp/revlogs/bundle_revlogs.rb +246 -0
- data/lib/amp/revlogs/changegroup.rb +217 -0
- data/lib/amp/revlogs/changelog.rb +338 -0
- data/lib/amp/revlogs/changeset.rb +521 -0
- data/lib/amp/revlogs/file_log.rb +165 -0
- data/lib/amp/revlogs/index.rb +493 -0
- data/lib/amp/revlogs/manifest.rb +195 -0
- data/lib/amp/revlogs/node.rb +18 -0
- data/lib/amp/revlogs/revlog.rb +1032 -0
- data/lib/amp/revlogs/revlog_support.rb +126 -0
- data/lib/amp/server/amp_user.rb +44 -0
- data/lib/amp/server/extension/amp_extension.rb +396 -0
- data/lib/amp/server/extension/authorization.rb +201 -0
- data/lib/amp/server/fancy_http_server.rb +252 -0
- data/lib/amp/server/fancy_views/_browser.haml +28 -0
- data/lib/amp/server/fancy_views/_diff_file.haml +13 -0
- data/lib/amp/server/fancy_views/_navbar.haml +17 -0
- data/lib/amp/server/fancy_views/changeset.haml +31 -0
- data/lib/amp/server/fancy_views/commits.haml +32 -0
- data/lib/amp/server/fancy_views/file.haml +35 -0
- data/lib/amp/server/fancy_views/file_diff.haml +23 -0
- data/lib/amp/server/fancy_views/harshcss/all_hallows_eve.css +72 -0
- data/lib/amp/server/fancy_views/harshcss/amy.css +147 -0
- data/lib/amp/server/fancy_views/harshcss/twilight.css +138 -0
- data/lib/amp/server/fancy_views/stylesheet.sass +175 -0
- data/lib/amp/server/http_server.rb +140 -0
- data/lib/amp/server/repo_user_management.rb +287 -0
- data/lib/amp/support/amp_config.rb +164 -0
- data/lib/amp/support/amp_ui.rb +287 -0
- data/lib/amp/support/docs.rb +54 -0
- data/lib/amp/support/generator.rb +78 -0
- data/lib/amp/support/ignore.rb +144 -0
- data/lib/amp/support/loaders.rb +93 -0
- data/lib/amp/support/logger.rb +103 -0
- data/lib/amp/support/match.rb +151 -0
- data/lib/amp/support/multi_io.rb +87 -0
- data/lib/amp/support/openers.rb +121 -0
- data/lib/amp/support/ruby_19_compatibility.rb +66 -0
- data/lib/amp/support/support.rb +1095 -0
- data/lib/amp/templates/blank.commit.erb +23 -0
- data/lib/amp/templates/blank.log.erb +18 -0
- data/lib/amp/templates/default.commit.erb +23 -0
- data/lib/amp/templates/default.log.erb +26 -0
- data/lib/amp/templates/template.rb +165 -0
- data/site/Rakefile +24 -0
- data/site/src/about/ampfile.haml +57 -0
- data/site/src/about/commands.haml +106 -0
- data/site/src/about/index.haml +33 -0
- data/site/src/about/performance.haml +31 -0
- data/site/src/about/workflows.haml +34 -0
- data/site/src/contribute/index.haml +65 -0
- data/site/src/contribute/style.haml +297 -0
- data/site/src/css/active4d.css +114 -0
- data/site/src/css/all_hallows_eve.css +72 -0
- data/site/src/css/all_themes.css +3299 -0
- data/site/src/css/amp.css +260 -0
- data/site/src/css/amy.css +147 -0
- data/site/src/css/blackboard.css +88 -0
- data/site/src/css/brilliance_black.css +605 -0
- data/site/src/css/brilliance_dull.css +599 -0
- data/site/src/css/cobalt.css +149 -0
- data/site/src/css/cur_amp.css +185 -0
- data/site/src/css/dawn.css +121 -0
- data/site/src/css/eiffel.css +121 -0
- data/site/src/css/espresso_libre.css +109 -0
- data/site/src/css/idle.css +62 -0
- data/site/src/css/iplastic.css +80 -0
- data/site/src/css/lazy.css +73 -0
- data/site/src/css/mac_classic.css +123 -0
- data/site/src/css/magicwb_amiga.css +104 -0
- data/site/src/css/pastels_on_dark.css +188 -0
- data/site/src/css/reset.css +55 -0
- data/site/src/css/slush_poppies.css +85 -0
- data/site/src/css/spacecadet.css +51 -0
- data/site/src/css/sunburst.css +180 -0
- data/site/src/css/twilight.css +137 -0
- data/site/src/css/zenburnesque.css +91 -0
- data/site/src/get/index.haml +32 -0
- data/site/src/helpers.rb +121 -0
- data/site/src/images/amp_logo.png +0 -0
- data/site/src/images/carbonica.png +0 -0
- data/site/src/images/revolution.png +0 -0
- data/site/src/images/tab-bg.png +0 -0
- data/site/src/images/tab-sliding-left.png +0 -0
- data/site/src/images/tab-sliding-right.png +0 -0
- data/site/src/include/_footer.haml +22 -0
- data/site/src/include/_header.haml +17 -0
- data/site/src/index.haml +104 -0
- data/site/src/learn/index.haml +46 -0
- data/site/src/scripts/jquery-1.3.2.min.js +19 -0
- data/site/src/scripts/jquery.cookie.js +96 -0
- data/tasks/stats.rake +155 -0
- data/tasks/yard.rake +171 -0
- data/test/dirstate_tests/dirstate +0 -0
- data/test/dirstate_tests/hgrc +5 -0
- data/test/dirstate_tests/test_dir_state.rb +192 -0
- data/test/functional_tests/resources/.hgignore +2 -0
- data/test/functional_tests/resources/STYLE.txt +25 -0
- data/test/functional_tests/resources/command.rb +372 -0
- data/test/functional_tests/resources/commands/annotate.rb +57 -0
- data/test/functional_tests/resources/commands/experimental/lolcats.rb +17 -0
- data/test/functional_tests/resources/commands/heads.rb +22 -0
- data/test/functional_tests/resources/commands/manifest.rb +12 -0
- data/test/functional_tests/resources/commands/status.rb +90 -0
- data/test/functional_tests/resources/version2/.hgignore +5 -0
- data/test/functional_tests/resources/version2/STYLE.txt +25 -0
- data/test/functional_tests/resources/version2/command.rb +372 -0
- data/test/functional_tests/resources/version2/commands/annotate.rb +45 -0
- data/test/functional_tests/resources/version2/commands/experimental/lolcats.rb +17 -0
- data/test/functional_tests/resources/version2/commands/heads.rb +22 -0
- data/test/functional_tests/resources/version2/commands/manifest.rb +12 -0
- data/test/functional_tests/resources/version2/commands/status.rb +90 -0
- data/test/functional_tests/resources/version3/.hgignore +5 -0
- data/test/functional_tests/resources/version3/STYLE.txt +31 -0
- data/test/functional_tests/resources/version3/command.rb +376 -0
- data/test/functional_tests/resources/version3/commands/annotate.rb +45 -0
- data/test/functional_tests/resources/version3/commands/experimental/lolcats.rb +17 -0
- data/test/functional_tests/resources/version3/commands/heads.rb +22 -0
- data/test/functional_tests/resources/version3/commands/manifest.rb +12 -0
- data/test/functional_tests/resources/version3/commands/status.rb +90 -0
- data/test/functional_tests/resources/version4/.hgignore +5 -0
- data/test/functional_tests/resources/version4/STYLE.txt +31 -0
- data/test/functional_tests/resources/version4/command.rb +376 -0
- data/test/functional_tests/resources/version4/commands/experimental/lolcats.rb +17 -0
- data/test/functional_tests/resources/version4/commands/heads.rb +22 -0
- data/test/functional_tests/resources/version4/commands/manifest.rb +12 -0
- data/test/functional_tests/resources/version4/commands/stats.rb +25 -0
- data/test/functional_tests/resources/version4/commands/status.rb +90 -0
- data/test/functional_tests/resources/version5_1/.hgignore +5 -0
- data/test/functional_tests/resources/version5_1/STYLE.txt +2 -0
- data/test/functional_tests/resources/version5_1/command.rb +374 -0
- data/test/functional_tests/resources/version5_1/commands/experimental/lolcats.rb +17 -0
- data/test/functional_tests/resources/version5_1/commands/heads.rb +22 -0
- data/test/functional_tests/resources/version5_1/commands/manifest.rb +12 -0
- data/test/functional_tests/resources/version5_1/commands/stats.rb +25 -0
- data/test/functional_tests/resources/version5_1/commands/status.rb +90 -0
- data/test/functional_tests/resources/version5_2/.hgignore +5 -0
- data/test/functional_tests/resources/version5_2/STYLE.txt +14 -0
- data/test/functional_tests/resources/version5_2/command.rb +376 -0
- data/test/functional_tests/resources/version5_2/commands/experimental/lolcats.rb +17 -0
- data/test/functional_tests/resources/version5_2/commands/manifest.rb +12 -0
- data/test/functional_tests/resources/version5_2/commands/newz.rb +12 -0
- data/test/functional_tests/resources/version5_2/commands/stats.rb +25 -0
- data/test/functional_tests/resources/version5_2/commands/status.rb +90 -0
- data/test/functional_tests/test_functional.rb +604 -0
- data/test/localrepo_tests/test_local_repo.rb +121 -0
- data/test/localrepo_tests/testrepo.tar.gz +0 -0
- data/test/manifest_tests/00manifest.i +0 -0
- data/test/manifest_tests/test_manifest.rb +72 -0
- data/test/merge_tests/base.txt +10 -0
- data/test/merge_tests/expected.local.txt +16 -0
- data/test/merge_tests/local.txt +11 -0
- data/test/merge_tests/remote.txt +11 -0
- data/test/merge_tests/test_merge.rb +26 -0
- data/test/revlog_tests/00changelog.i +0 -0
- data/test/revlog_tests/revision_added_changelog.i +0 -0
- data/test/revlog_tests/test_adding_index.i +0 -0
- data/test/revlog_tests/test_revlog.rb +333 -0
- data/test/revlog_tests/testindex.i +0 -0
- data/test/store_tests/store.tar.gz +0 -0
- data/test/store_tests/test_fncache_store.rb +122 -0
- data/test/test_amp.rb +9 -0
- data/test/test_base85.rb +14 -0
- data/test/test_bdiff.rb +42 -0
- data/test/test_commands.rb +122 -0
- data/test/test_difflib.rb +50 -0
- data/test/test_helper.rb +15 -0
- data/test/test_journal.rb +29 -0
- data/test/test_match.rb +134 -0
- data/test/test_mdiff.rb +74 -0
- data/test/test_mpatch.rb +14 -0
- data/test/test_support.rb +24 -0
- metadata +385 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
AMP: Enter commit message. Lines beginning with 'AMP:' are removed.
|
|
4
|
+
AMP: --
|
|
5
|
+
AMP: <%= user %>
|
|
6
|
+
<%- if p2 != NULL_REV -%>
|
|
7
|
+
AMP: branch merge
|
|
8
|
+
<%- end -%>
|
|
9
|
+
<%- if branch -%>
|
|
10
|
+
AMP: branch '<%= branch %>'
|
|
11
|
+
<%- end -%>
|
|
12
|
+
<%- added.each do |file| -%>
|
|
13
|
+
AMP: added <%= file %>
|
|
14
|
+
<%- end -%>
|
|
15
|
+
<%- updated.each do |file| -%>
|
|
16
|
+
AMP: changed <%= file %>
|
|
17
|
+
<%- end -%>
|
|
18
|
+
<%- removed.each do |file| -%>
|
|
19
|
+
AMP: removed <%= file %>
|
|
20
|
+
<%- end -%>
|
|
21
|
+
<%- if added.size + updated.size + removed.size == 0 -%>
|
|
22
|
+
AMP: no files changed
|
|
23
|
+
<%- end -%>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%# This is the blank template file. Here's some information about the
|
|
2
|
+
variables you have access to in your ERb file!
|
|
3
|
+
|
|
4
|
+
Note: This template is for when you want to print changesets.
|
|
5
|
+
|
|
6
|
+
revision: the revision number of the changeset you're printing
|
|
7
|
+
change_node: the node ID of the changeset. This will be in binary,
|
|
8
|
+
so you'll probably want to use hexlify to make it hexy.
|
|
9
|
+
branch: the name of the branch this changeset belongs to
|
|
10
|
+
parents: parents of the revision, as [index, node (as hex)]
|
|
11
|
+
username: the user who committed this changeset
|
|
12
|
+
date: the date this was committed
|
|
13
|
+
description: the message connected to the changeset
|
|
14
|
+
config: the entire configuration of the entire program! This includes
|
|
15
|
+
switches such as :verbose.
|
|
16
|
+
|
|
17
|
+
Be sure to take a look at the default template, to get some ideas!
|
|
18
|
+
%>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
AMP: Enter commit message. Lines beginning with 'AMP:' are removed.
|
|
4
|
+
AMP: --
|
|
5
|
+
AMP: <%= user %>
|
|
6
|
+
<%- if p2 != nil -%>
|
|
7
|
+
AMP: branch merge
|
|
8
|
+
<%- end -%>
|
|
9
|
+
<%- if branch -%>
|
|
10
|
+
AMP: branch '<%= branch %>'
|
|
11
|
+
<%- end -%>
|
|
12
|
+
<%- added.each do |file| -%>
|
|
13
|
+
AMP: added <%= file %>
|
|
14
|
+
<%- end -%>
|
|
15
|
+
<%- updated.each do |file| -%>
|
|
16
|
+
AMP: changed <%= file %>
|
|
17
|
+
<%- end -%>
|
|
18
|
+
<%- removed.each do |file| -%>
|
|
19
|
+
AMP: removed <%= file %>
|
|
20
|
+
<%- end -%>
|
|
21
|
+
<%- if added.size + updated.size + removed.size == 0 -%>
|
|
22
|
+
AMP: no files changed
|
|
23
|
+
<%- end -%>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<%- if config[:verbose] -%>
|
|
2
|
+
changeset: <%= revision %>:<%= change_node.hexlify %>
|
|
3
|
+
<%- else -%>
|
|
4
|
+
changeset: <%= revision %>:<%= change_node[0..5].hexlify %>
|
|
5
|
+
<%- end -%>
|
|
6
|
+
branch: <%= branch %>
|
|
7
|
+
<%- parents.each do |index, node| -%>
|
|
8
|
+
parent: <%= "#{index}:#{node}" %>
|
|
9
|
+
<%- end -%>
|
|
10
|
+
<%- if cs_tags.any? -%>
|
|
11
|
+
tags: <%= cs_tags %>
|
|
12
|
+
<%- end -%>
|
|
13
|
+
user: <%= username %>
|
|
14
|
+
date: <%= date %>
|
|
15
|
+
<%- if config[:verbose] -%>
|
|
16
|
+
files: <%= files.join(" ") %>
|
|
17
|
+
<%- end -%>
|
|
18
|
+
<%- if description && description.any?
|
|
19
|
+
if config[:verbose] -%>
|
|
20
|
+
description:
|
|
21
|
+
<%= description %>
|
|
22
|
+
<%- else -%>
|
|
23
|
+
summary: <%= description.split_lines_better.first.strip %>
|
|
24
|
+
<%- end -%>
|
|
25
|
+
<%- end -%>
|
|
26
|
+
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
module Amp
|
|
2
|
+
module Support
|
|
3
|
+
##
|
|
4
|
+
# = Template
|
|
5
|
+
# @author Michael Edgar
|
|
6
|
+
#
|
|
7
|
+
# Class representing a template in the amp system
|
|
8
|
+
class Template
|
|
9
|
+
|
|
10
|
+
@all_templates = {}
|
|
11
|
+
class << self
|
|
12
|
+
attr_accessor :all_templates
|
|
13
|
+
|
|
14
|
+
##
|
|
15
|
+
# Returns the template with the given name.
|
|
16
|
+
#
|
|
17
|
+
# @param [String, Symbol, #to_sym] template the name of the template to retrieve
|
|
18
|
+
# @return [Template] the template with the given name
|
|
19
|
+
def [](template)
|
|
20
|
+
ensure_templates_loaded
|
|
21
|
+
return all_templates[template.to_sym]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Registers a template with the Amp system. Should have a unique name.
|
|
26
|
+
#
|
|
27
|
+
# @param [String, Symbol, #to_sym] name the name of the template. Should be unique.
|
|
28
|
+
# @param [Template] template the template to register.
|
|
29
|
+
def register(name, template)
|
|
30
|
+
all_templates[name.to_sym] = template
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
##
|
|
34
|
+
# Unregisters a template with the Amp system. If the name is not found, an exception
|
|
35
|
+
# is thrown.
|
|
36
|
+
#
|
|
37
|
+
# @param [String, Symbol, #to_sym] name the name of the template to remove from
|
|
38
|
+
# the system.
|
|
39
|
+
def unregister(name)
|
|
40
|
+
raise ArgumentError.new("Unknown template: #{name}") unless all_templates[name.to_sym]
|
|
41
|
+
all_templates.delete name.to_sym
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# Returns whether any templates have been loaded. Used for lazy loading of templates.
|
|
46
|
+
#
|
|
47
|
+
# @return [Boolean] have the default templates, or any templates, been loaded?
|
|
48
|
+
def templates_loaded?
|
|
49
|
+
all_templates.any?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
# Registers the default templates. Separated into a method (instead of automatically
|
|
54
|
+
# run) because templates aren't used enough to justify the IO hit from loading them in.
|
|
55
|
+
def load_default_templates
|
|
56
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__), "*.erb"))].each do |f|
|
|
57
|
+
name = f.split('/').last.chomp('.erb').sub('.','-')
|
|
58
|
+
FileTemplate.new(name, f)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
##
|
|
63
|
+
# Makes sure the default templates have been loaded.
|
|
64
|
+
#
|
|
65
|
+
# About the use of instance_eval - this method could potentially be run more than once. There
|
|
66
|
+
# is no reason for it to ever run more than once. So we'll redefine it to do nothing.
|
|
67
|
+
def ensure_templates_loaded
|
|
68
|
+
load_default_templates
|
|
69
|
+
instance_eval do
|
|
70
|
+
def ensure_templates_loaded; end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
attr_accessor :name, :renderer, :text
|
|
76
|
+
|
|
77
|
+
##
|
|
78
|
+
# Creates a new template with the given values. The name is how you will reference the
|
|
79
|
+
# template using the --template option from the command line, so choose it wisely!
|
|
80
|
+
#
|
|
81
|
+
# @param [String, Symbol, #to_s] name the name of the template, which is invoked
|
|
82
|
+
# using --template
|
|
83
|
+
# @param [Symbol] type the type of the template. Indicates the renderer used.
|
|
84
|
+
# @param [String] text the text of the template, which presumably has some templating
|
|
85
|
+
# code to substitute in local variables and make a nice output system.
|
|
86
|
+
def initialize(name, renderer = :erb, text = "")
|
|
87
|
+
@name, @renderer, @text = name, renderer, text
|
|
88
|
+
Template.register(name, self)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
##
|
|
92
|
+
# Renders the template with the given local variables. Uses whichever templating engine
|
|
93
|
+
# you set. Note: if you use HAML, you'll need to have HAML installed. This is why none
|
|
94
|
+
# of the default templates use HAML.
|
|
95
|
+
#
|
|
96
|
+
# @param [Hash] locals the local variables passed to the template. Works for HAML so far,
|
|
97
|
+
# not for erb.
|
|
98
|
+
# @return [String] the parsed template
|
|
99
|
+
# @todo make locals work for ERb without bootleg hax
|
|
100
|
+
def render(locals = {}, render_binding = binding)
|
|
101
|
+
# expose this local to make it easier, even if it's nil
|
|
102
|
+
|
|
103
|
+
case renderer.to_sym
|
|
104
|
+
when :erb
|
|
105
|
+
require 'erb'
|
|
106
|
+
locals_assigns = locals.to_a.collect { |k,v| "#{k} = locals[:#{k}]" }
|
|
107
|
+
eval locals_assigns.join("\n"), render_binding
|
|
108
|
+
|
|
109
|
+
erb = ERB.new(text, 0, "-")
|
|
110
|
+
erb.result render_binding
|
|
111
|
+
when :haml
|
|
112
|
+
require 'rubygems'
|
|
113
|
+
require 'haml'
|
|
114
|
+
haml = Haml::Engine.new(text)
|
|
115
|
+
haml.render render_binding, locals
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
private
|
|
120
|
+
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
##
|
|
124
|
+
# = FileTemplate
|
|
125
|
+
# Class for loading a template from a file and registering it in the system.
|
|
126
|
+
# Is smart enough that if the filename ends in a known extension, the appropriate
|
|
127
|
+
# renderer will be used. Otherwise, you will have to specify the renderer.
|
|
128
|
+
class FileTemplate < Template
|
|
129
|
+
KNOWN_EXTENSIONS = ["erb", "haml"]
|
|
130
|
+
|
|
131
|
+
attr_accessor :file
|
|
132
|
+
|
|
133
|
+
##
|
|
134
|
+
# Initializes a new FileTemplate with different
|
|
135
|
+
def initialize(name, file, renderer = nil)
|
|
136
|
+
if renderer.nil?
|
|
137
|
+
renderer = KNOWN_EXTENSIONS.select {|ext| file.end_with? ext}.first
|
|
138
|
+
end
|
|
139
|
+
raise ArgumentError.new("No renderer specified for #{file.inspect}") if renderer.nil?
|
|
140
|
+
@file = file
|
|
141
|
+
super(name, renderer, File.read(file))
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def save!
|
|
145
|
+
File.open(file, "w") { |out| out.write text }
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
module Amp
|
|
155
|
+
module KernelMethods
|
|
156
|
+
def template(name, *args)
|
|
157
|
+
if args.size > 2 || args.empty?
|
|
158
|
+
raise ArgumentError.new('Usage of template: template(name, text)'+
|
|
159
|
+
'or template(name, renderer, text)')
|
|
160
|
+
end
|
|
161
|
+
template = (args.size > 1) ? args[0] : :erb
|
|
162
|
+
Support::Template.new(name, template, args.last)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
data/site/Rakefile
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'rake'
|
|
5
|
+
require 'rake/tasklib'
|
|
6
|
+
require 'haml'
|
|
7
|
+
require 'src/helpers.rb'
|
|
8
|
+
require 'ftools'
|
|
9
|
+
|
|
10
|
+
desc "Compile Site"
|
|
11
|
+
task :"build-website" do
|
|
12
|
+
Dir["src/**/*.haml"].reject {|item| item.split("/").last =~ /^_/}.each do |haml|
|
|
13
|
+
FileUtils.makedirs(File.dirname("build" + haml[3..-6] + ".html"))
|
|
14
|
+
File.open("build" + haml[3..-6] + ".html","w") do |out|
|
|
15
|
+
puts "Building #{haml[3..-6]}"
|
|
16
|
+
out.write render(haml)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
%w(css images scripts docs).each do |dir|
|
|
20
|
+
if File.exist? "src/#{dir}/"
|
|
21
|
+
sh "cp -r src/#{dir}/ build/#{dir}/"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
!!! 1.1
|
|
2
|
+
%html{ :xmlns => "http://www.w3.org/1999/xhtml" }
|
|
3
|
+
%head
|
|
4
|
+
%meta{ :content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type" }
|
|
5
|
+
%title
|
|
6
|
+
Amp | Version Control Revolution | Ampfiles
|
|
7
|
+
= stylesheets :reset, :amp, :all_themes
|
|
8
|
+
= javascripts "jquery-1.3.2.min.js", "jquery.cookie.js"
|
|
9
|
+
%body.oneColFixCtr
|
|
10
|
+
= render("include/_header.haml", :selected => "about")
|
|
11
|
+
.infopage#container
|
|
12
|
+
.body-width
|
|
13
|
+
.floatleft{ :style => "width:90%; padding:8px 0em 6px; margin-left:5%;"}
|
|
14
|
+
%h2 What's an Ampfile?
|
|
15
|
+
%p
|
|
16
|
+
#{blue_amp "Ampfiles"} are how you load your customizations into #{blue_amp}. INI files are handy, and we use them maintain compatibility with the #{hg_link} distribution. However, you can't put code in an INI file. And the files, quite frankly, aren't very pretty. That's why we have ampfiles.
|
|
17
|
+
%p
|
|
18
|
+
For those familiar with #{ruby_link}, ampfiles are sort of similar to #{link_to "http://rake.rubyforge.org/", "Rake"}'s Rakefiles. When you run #{blue_amp}, amp will look in the current directory for a file called "Ampfile" (or "ampfile", "ampfile.rb", etc.). If it doesn't find one it looks in the folder containing the current one - and up and up until it gives up. If it doesn't find one, that's ok - you don't need an ampfile to use #{blue_amp}!
|
|
19
|
+
%h2 So how does Amp use Ampfiles?
|
|
20
|
+
%p
|
|
21
|
+
The cool thing about ampfiles is that they're just Ruby code. So #{blue_amp} just runs your ampfile as Ruby. "But wait," you say, "what use is running a script every time I use amp?" Well, silly, we give you a bunch of Ruby methods you can use to modify #{blue_amp}, and when your ampfile is run, those changes happen!
|
|
22
|
+
%h2 ~/.amprc
|
|
23
|
+
%p
|
|
24
|
+
A quick note: #{blue_amp} will also run the file located at #{shellscript "~/.amprc"} (~ means "your user directory"), right before running any ampfiles. That way, the ampfile in your repository can override any global settings in #{shellscript ".amprc"}.
|
|
25
|
+
%h2 Example! Now!
|
|
26
|
+
%p
|
|
27
|
+
Ok, ok. For starters, you can modify existing commands very simply. In Ruby, you can open a class up, add a method, and close it again. In Amp, you do that like this:
|
|
28
|
+
.rounded.dark.codeholder.floatleft
|
|
29
|
+
:syntaxhighlighter
|
|
30
|
+
command "status" do |c|
|
|
31
|
+
c.default :"no-color", true
|
|
32
|
+
end
|
|
33
|
+
%p
|
|
34
|
+
If you put that in your Ampfile, the #{shellscript "amp status"} command will no longer use color. Why don't we create a new command entirely?
|
|
35
|
+
.rounded.dark.codeholder.floatleft
|
|
36
|
+
:syntaxhighlighter
|
|
37
|
+
command "stats" do |c|
|
|
38
|
+
c.workflow :hg
|
|
39
|
+
c.desc "Prints how many commits each user has contributed"
|
|
40
|
+
c.on_run do |opts, args|
|
|
41
|
+
repo = opts[:repository]
|
|
42
|
+
users = Hash.new {|h, k| h[k] = 0}
|
|
43
|
+
repo.each do |changeset|
|
|
44
|
+
users[changeset.user] += 1
|
|
45
|
+
end
|
|
46
|
+
users.to_a.sort {|a,b| b[1] <=> a[1]}.each do |u,c|
|
|
47
|
+
puts "\#{u}: \#{c}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
%p
|
|
52
|
+
You can put that in your ampfile and get commit statistics right away. In fact, it's in #{blue_amp}'s ampfile. If you run #{shellscript "amp help"}, your new command will be in the list! Why does this work? Well, it's not much of a secret: <b>You're actually writing the exact same code used to create the built-in amp commands.</b> If you look at our code, each of the commands you know and love, such as #{shellscript "amp commit"}, #{shellscript "amp move"} are written using this exact same code style.
|
|
53
|
+
%h2 Cool! What now?
|
|
54
|
+
%p
|
|
55
|
+
Well, start hacking away! You might find the #{commands_link} section interesting, as well as our #{link_to "/learn/", "Learn Amp"} pages, where you can find the #{blue_amp} API. We'll be setting up a place for useful snippets to be posted soon.
|
|
56
|
+
|
|
57
|
+
= render("include/_footer.haml")
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
!!! 1.1
|
|
2
|
+
%html{ :xmlns => "http://www.w3.org/1999/xhtml" }
|
|
3
|
+
%head
|
|
4
|
+
%meta{ :content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type" }
|
|
5
|
+
%title
|
|
6
|
+
Amp | Version Control Revolution | Amp Commands
|
|
7
|
+
= stylesheets :reset, :amp, :all_themes
|
|
8
|
+
= javascripts "jquery-1.3.2.min.js", "jquery.cookie.js"
|
|
9
|
+
%body.oneColFixCtr
|
|
10
|
+
= render("include/_header.haml", :selected => "about")
|
|
11
|
+
.infopage#container
|
|
12
|
+
.body-width
|
|
13
|
+
.floatleft{ :style => "width:90%; padding:8px 0em 6px; margin-left:5%;"}
|
|
14
|
+
%h2 #{blue_amp "Amp"} Commands
|
|
15
|
+
%p
|
|
16
|
+
Amp's commands are the driving force behind what makes #{blue_amp} unique. Most VCS users are programmers, and yet programming existing VCS systems isn't a simple, well-documented task. In #{git_link} you might write a shell script, yet with #{hg_link} you'll find yourself writing a python module and adding it through arcane INI file wizardry. With #{blue_amp} you just add Ruby code directly to your #{ampfile_link}, which is <em>not</em> a hidden file in some strange directory.
|
|
17
|
+
%p
|
|
18
|
+
All of #{blue_amp}'s commands have access to a first-class options parser and command line arguments. You don't have to parse options yourself, of course - you just declare them. Now, we've got some really simple commands littered throughout the site to illustrate how simple commands are. But if you're at this page, you probably want a little bit more. So here's the #{shellscript "amp log"} command in #{blue_amp} - unmodified:
|
|
19
|
+
.floatleft.dark.rounded{:style => "width:100%;padding-top:4px; padding-bottom:4px;"}
|
|
20
|
+
.floatleft{:style => "width:95%; margin-left:5%;"}
|
|
21
|
+
:syntaxhighlighter
|
|
22
|
+
command :log do |c|
|
|
23
|
+
c.workflow :hg
|
|
24
|
+
c.desc "Prints the commit history."
|
|
25
|
+
c.opt :verbose, "Verbose output", {:short => "-v"}
|
|
26
|
+
c.opt :limit, "Limit how many revisions to show",
|
|
27
|
+
{:short => "-l", :type => :integer, :default => -1}
|
|
28
|
+
c.opt :template, "Which template to use while printing",
|
|
29
|
+
{:short => "-t", :type => :string, :default => "default"}
|
|
30
|
+
c.opt :no_output, "Doesn't print output (useful for benchmarking)"
|
|
31
|
+
c.on_run do |options, args|
|
|
32
|
+
repo = options[:repository]
|
|
33
|
+
limit = options[:limit]
|
|
34
|
+
limit = repo.size if limit == -1
|
|
35
|
+
|
|
36
|
+
start = repo.size - 1
|
|
37
|
+
stop = start - limit + 1
|
|
38
|
+
|
|
39
|
+
options.merge! :template_type => :log
|
|
40
|
+
start.downto stop do |x|
|
|
41
|
+
puts repo[x].to_templated_s(options) unless options[:no_output]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
%p
|
|
46
|
+
There's a lot going on here. Let's break it down:
|
|
47
|
+
.floatleft.dark.rounded.codeholder
|
|
48
|
+
:syntaxhighlighter
|
|
49
|
+
command :log do |c|
|
|
50
|
+
%p
|
|
51
|
+
This line creates a command called #{symbol :log}, and passes it to the block as <b>c</b>. <b>If the command #{symbol :log} exists already, then the existing command is passed to the block as <i>c</i></b>. The inside of the block is where we declare our command. This is where things get interesting!
|
|
52
|
+
.floatleft.dark.rounded.codeholder
|
|
53
|
+
:syntaxhighlighter
|
|
54
|
+
c.workflow :hg
|
|
55
|
+
%p
|
|
56
|
+
The <tt>workflow</tt> method specifies which #{workflows_link "workflow"} the command belongs to. We use it here to specify that the #{symbol :log} command we're defining belongs to the #{symbol :hg} workflow, and shouldn't appear if the user is using the git workflow (or any other). If you specify #{symbol :all} as the workflow (or don't specify one), the command will be available to all workflows.
|
|
57
|
+
.floatleft.dark.rounded.codeholder
|
|
58
|
+
:syntaxhighlighter
|
|
59
|
+
c.desc "Prints the commit history."
|
|
60
|
+
%p
|
|
61
|
+
The <tt>desc</tt> method declares a small description of the command, which shows up when the user runs #{shellscript "amp help"} to get a list of all available commands. It should fit on one line and be succinct. You may also use <tt>desc=</tt> if you prefer that style.
|
|
62
|
+
.floatleft.dark.rounded.codeholder
|
|
63
|
+
:syntaxhighlighter
|
|
64
|
+
c.opt :verbose, "Verbose output", {:short => "-v"}
|
|
65
|
+
c.opt :limit, "Limit how many revisions to show",
|
|
66
|
+
{:short => "-l", :type => :integer, :default => -1}
|
|
67
|
+
c.opt :template, "Which template to use while printing",
|
|
68
|
+
{:short => "-t", :type => :string, :default => "default"}
|
|
69
|
+
%p
|
|
70
|
+
Now that's what we're talking about! We're declaring some options here, and can see a small portion of #{blue_amp}'s option parser at work. Take a look at the #{symbol :verbose} line.
|
|
71
|
+
%p
|
|
72
|
+
By declaring #{shellscript "c.opt #{symbol :verbose}"}, we create a #{shellscript "--verbose"} option for our #{shellscript "amp log"} command. The first argument is the name of the option - it can be a string, or a symbol. The second argument is a short description - these first two arguments are required. After that come the nifty options! (Note - #{blue_amp} uses #{link_to "http://trollop.rubyforge.org/", "trollop"} under-the-hood, so its options are identical to trollop's.)
|
|
73
|
+
%ul.bullets{:style => "margin-left:2em;"}
|
|
74
|
+
%li #{symbol :short} - By setting #{symbol :short} to "-v", we can now use #{shellscript "amp log -v"} as well as #{shellscript "amp log --verbose"}
|
|
75
|
+
%li
|
|
76
|
+
#{symbol :type} - The type of the option. This defaults to #{symbol :flag}, which is a normal on-or-off switch, like #{shellscript "--verbose"}.
|
|
77
|
+
%br/
|
|
78
|
+
%br/
|
|
79
|
+
You'll notice the #{symbol :limit} option has #{symbol :type} => #{symbol :integer}. This makes the #{symbol :limit} option require an argument, and forces it into an integer during parsing. Easy, eh?
|
|
80
|
+
%li #{symbol :default} - The default value of the option. If the user doesn't specify the option, it will normally be parsed as #{shellscript "nil"} - you can set a default value here.
|
|
81
|
+
%p
|
|
82
|
+
For more ways to configure your options, see the documentation for the #{shellscript "opt"} method #{link_to "http://amp.carboni.ca/docs/Amp/Command.html#opt-instance_method", "here"}.
|
|
83
|
+
.floatleft.dark.rounded.codeholder
|
|
84
|
+
:syntaxhighlighter
|
|
85
|
+
c.on_run do |options, args|
|
|
86
|
+
repo = options[:repository]
|
|
87
|
+
limit = options[:limit]
|
|
88
|
+
limit = repo.size if limit == -1
|
|
89
|
+
|
|
90
|
+
start = repo.size - 1
|
|
91
|
+
stop = start - limit + 1
|
|
92
|
+
|
|
93
|
+
options.merge! :template_type => :log
|
|
94
|
+
start.downto stop do |x|
|
|
95
|
+
puts repo[x].to_templated_s(options) unless options[:no_output]
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
%p
|
|
99
|
+
Last, but not least, we have the #{shellscript "on_run"} method. This is how we declare what <em>happens</em> when our command is run - which is what we really care about! You specify what the command does in #{shellscript "on_run"}'s block, which takes two arguments: #{shellscript "options"} and #{shellscript "args"}. These are, respectively, the command-line options passed in plus amp's additions, and the arguments provided by the user. For example: #{shellscript "amp log --verbose --limit=3 arg1 arg2"} would provide #{shellscript "{:verbose => true, :limit => 3, :repository => #<LocalRepository repo>}"} as #{shellscript "options"} and #{shellscript "[arg1, arg2]"} as #{shellscript "args"}.
|
|
100
|
+
%p
|
|
101
|
+
Our command is getting changeset information, so it needs a repository to interact with. Unless told to do otherwise, #{blue_amp} will look for a repository and store it in #{shellscript "options[#{symbol :repository}]"}. This will always be an object of the class #{link_to "http://amp.carboni.ca/docs/Amp/Repositories/LocalRepository.html", "LocalRepository"}.
|
|
102
|
+
%p
|
|
103
|
+
Once we extract our repository, we decide which changesets to print based on the options. To get a given changeset, we simply use #{shellscript "repo[x]"}, where #{shellscript "x"} can be a revision number, a partial node ID, "tip", and so on. See the documentation for #{link_to "http://amp.carboni.ca/docs/Amp/Repositories/LocalRepository.html#%5B%5D-instance_method", "LocalRepository#[]"} for more details.
|
|
104
|
+
%p
|
|
105
|
+
This is just a quick once-over of some of the more obvious features of #{blue_amp "Amp's"} command system - there are far more features to discuss. Until those pages are written, take a look at the #{link_to "http://amp.carboni.ca/docs/Amp/Command.html", "Documentation for the Command class"}.
|
|
106
|
+
= render("include/_footer.haml")
|