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,17 @@
|
|
|
1
|
+
command :lolcats do |c|
|
|
2
|
+
c.opt :cheezburger, "Add cheezburger to lolcat"
|
|
3
|
+
c.on_run do |opts, args|
|
|
4
|
+
puts "lolcats!"
|
|
5
|
+
puts "lolcats!"
|
|
6
|
+
puts "lolcats!"
|
|
7
|
+
puts "lolcats!"
|
|
8
|
+
puts "lolcats!"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
c.before do |opts, args|
|
|
12
|
+
puts "Before lolcats...."
|
|
13
|
+
end
|
|
14
|
+
c.after do |opts, args|
|
|
15
|
+
puts "After lolcats!"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
command :heads do |c|
|
|
2
|
+
c.desc "Prints the heads of the repository."
|
|
3
|
+
c.add_opt :rev, "show only heads which are descendants of rev", {:short => "-r"}
|
|
4
|
+
c.add_opt :active, "show only active heads", {:short => "-a"}
|
|
5
|
+
c.add_opt :template, "Which template to use while printing", {:short => "-t", :type => :string, :default => "default"}
|
|
6
|
+
c.on_run do |options, args|
|
|
7
|
+
repo = options[:repository]
|
|
8
|
+
start = options[:rev] ? repo.lookup(options[:rev]) : nil
|
|
9
|
+
closed = options[:active]
|
|
10
|
+
if args.size == 0
|
|
11
|
+
heads = repo.heads(start, :closed => closed)
|
|
12
|
+
else
|
|
13
|
+
#branch shit
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
options.merge!({:template_type => :log})
|
|
17
|
+
heads.each do |n|
|
|
18
|
+
puts repo[n].to_templated_s(options)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
command :manifest do |c|
|
|
2
|
+
c.desc "Prints the manifest at a given revision (defaults to working directory)"
|
|
3
|
+
c.add_opt :rev, "Specifies the revision to check", {:short => "-r", :type => :integer}
|
|
4
|
+
c.on_run do |options, arguments|
|
|
5
|
+
revision = options[:rev]
|
|
6
|
+
repo = options[:repository]
|
|
7
|
+
|
|
8
|
+
repo[revision].each do |k, v|
|
|
9
|
+
puts "#{k}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
command :stats do |c|
|
|
2
|
+
c.desc "Prints the stats at a given revision (defaults to working directory)"
|
|
3
|
+
c.add_opt :rev, "Specifies the revision to check", {:short => "-r", :type => :integer}
|
|
4
|
+
c.on_run do |options, arguments|
|
|
5
|
+
revision = options[:rev]
|
|
6
|
+
repo = options[:repository]
|
|
7
|
+
|
|
8
|
+
repo[revision].each do |k, v|
|
|
9
|
+
puts "#{k}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
command :stats do |c|
|
|
15
|
+
c.desc "Prints the stats at a given revision (defaults to working directory)"
|
|
16
|
+
c.add_opt :rev, "Specifies the revision to check", {:short => "-r", :type => :integer}
|
|
17
|
+
c.on_run do |options, arguments|
|
|
18
|
+
revision = options[:rev]
|
|
19
|
+
repo = options[:repository]
|
|
20
|
+
|
|
21
|
+
repo[revision].each do |k, v|
|
|
22
|
+
puts "#{k}"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
command :status do |c|
|
|
2
|
+
c.desc "Prints the status of the working directory (or another revision)"
|
|
3
|
+
c.add_opt :all, "Show all files", {:short => "-A"}
|
|
4
|
+
c.add_opt :modified, "Show only modified files", {:short => "-m"}
|
|
5
|
+
c.add_opt :added, "Show only added files", {:short => "-a"}
|
|
6
|
+
c.add_opt :deleted, "Show only deleted files", {:short => "-D"}
|
|
7
|
+
c.add_opt :removed, "Show only removed files", {:short => "-R"}
|
|
8
|
+
c.add_opt :clean, "Show only files without changes", {:short => "-c"}
|
|
9
|
+
c.add_opt :unknown, "Show only untracked files", {:short => "-u"}
|
|
10
|
+
c.add_opt :ignored, "Show only ignored files", {:short => "-i"}
|
|
11
|
+
c.add_opt :rev, "Selects which revision to use", {:short => "-r", :type => :string, :multi => true}
|
|
12
|
+
c.add_opt :hg, "Print the information in hg's style"
|
|
13
|
+
c.add_opt :"no-color","Don't use color to categorize the output"
|
|
14
|
+
c.synonym :st
|
|
15
|
+
|
|
16
|
+
c.on_run do |options, args|
|
|
17
|
+
repo = options[:repository]
|
|
18
|
+
node1, node2 = c.revision_pair(repo, options[:rev])
|
|
19
|
+
cwd = "" # use patterns later
|
|
20
|
+
stop = "\n"
|
|
21
|
+
copy = {}
|
|
22
|
+
colors = {'modified' => :cyan,
|
|
23
|
+
'added' => :blue,
|
|
24
|
+
'removed' => :red,
|
|
25
|
+
'deleted' => :magenta,
|
|
26
|
+
'unknown' => :green,
|
|
27
|
+
'ignored' => :yellow,
|
|
28
|
+
'clean' => :white
|
|
29
|
+
}
|
|
30
|
+
states = ['modified',
|
|
31
|
+
'added' ,
|
|
32
|
+
'removed' ,
|
|
33
|
+
'deleted' ,
|
|
34
|
+
'unknown' ,
|
|
35
|
+
'ignored' ,
|
|
36
|
+
'clean' ]
|
|
37
|
+
show = states.select {|k| options[k.to_sym]} # filter the list down
|
|
38
|
+
|
|
39
|
+
show = states if options[:all]
|
|
40
|
+
show = states[0..4] if show.empty?
|
|
41
|
+
|
|
42
|
+
statopts = {:node_1 => node1, :node_2 => node2 }
|
|
43
|
+
|
|
44
|
+
show.each {|switch| statopts[switch.to_sym] = true }
|
|
45
|
+
|
|
46
|
+
status = repo.status statopts
|
|
47
|
+
|
|
48
|
+
# PRINTING TIME!!!!!!!!
|
|
49
|
+
|
|
50
|
+
if options[:hg]
|
|
51
|
+
status_as_array = [status[:modified],
|
|
52
|
+
status[:added],
|
|
53
|
+
status[:removed],
|
|
54
|
+
status[:deleted],
|
|
55
|
+
status[:unknown],
|
|
56
|
+
status[:ignored],
|
|
57
|
+
status[:clean]
|
|
58
|
+
]
|
|
59
|
+
changestates = states.zip("MAR!?IC".split(""), status_as_array)
|
|
60
|
+
changestates.each do |state, char, files|
|
|
61
|
+
if show.include? state
|
|
62
|
+
files.each do |f|
|
|
63
|
+
if options[:"no-color"]
|
|
64
|
+
Amp::UI.say "#{char} #{File.join(cwd, f.to_s)[1..-1]}#{stop}" unless f.nil?
|
|
65
|
+
else
|
|
66
|
+
Amp::UI.say "#{char.send colors[state]} #{File.join(cwd, f.to_s)[1..-1]}#{stop}" unless f.nil?
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
else
|
|
72
|
+
# print it our way
|
|
73
|
+
|
|
74
|
+
show.each do |state|
|
|
75
|
+
next if status[state.to_sym].empty?
|
|
76
|
+
num_of_files = status[state.to_sym].size
|
|
77
|
+
|
|
78
|
+
Amp::UI.say("#{state.upcase.send colors[state]}" +
|
|
79
|
+
" => #{num_of_files} file#{num_of_files > 1 ? 's' : ''}")
|
|
80
|
+
|
|
81
|
+
status[state.to_sym].each do |file|
|
|
82
|
+
Amp::UI.say "\t#{File.join(cwd, file)[1..-1]}"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
puts
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
The Amp Commandments Redux:
|
|
2
|
+
1. Thou shalt not useth the "for...in" syntax.
|
|
3
|
+
2. Thou shalt useth only but 80 columns, for those who useth the lord's
|
|
4
|
+
editors, vim and emacs. (emacs sucks - oh no he didn't)
|
|
5
|
+
3. Thou shalt preface thine variables with _ only when thou needest,
|
|
6
|
+
lest ye face judgement for this most grave sin. (this isn't python.
|
|
7
|
+
no __method__ is necessary!)
|
|
8
|
+
4. Thine variables should have descriptive names, for thine ruby might
|
|
9
|
+
read like the psalms.
|
|
10
|
+
5. Thine variables, longer than 6 letters and composed of two or more
|
|
11
|
+
words, shall separate those words with the lord's underscore, so thine
|
|
12
|
+
code shall flow like the Nile herself.
|
|
13
|
+
6. Thou shalt rake thine yard frequently, to be sure thine code is
|
|
14
|
+
well-documented for thine neighbors.
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
need { 'command_support.rb' }
|
|
2
|
+
module Amp
|
|
3
|
+
##
|
|
4
|
+
# Represents a command within the Amp system. Simply instantiating a new
|
|
5
|
+
# command will make it available to the Amp executable. You configure the
|
|
6
|
+
# command by filling out a block in the command's initializer.
|
|
7
|
+
# @example
|
|
8
|
+
# Command.new("add") do |c|
|
|
9
|
+
# c.opt :include, "Paths to include",
|
|
10
|
+
# :options => {:short => "-I", :multi => true}
|
|
11
|
+
# c.opt :print_names, :desc => "Print the filenames",
|
|
12
|
+
# :options => {:short => "-p",
|
|
13
|
+
# :default => false,
|
|
14
|
+
# :type => :boolean}
|
|
15
|
+
# c.on_run do |options, arguments|
|
|
16
|
+
# if options[:print_names]
|
|
17
|
+
# arguments.each do |filename|
|
|
18
|
+
# puts filename
|
|
19
|
+
# end
|
|
20
|
+
# end
|
|
21
|
+
# end
|
|
22
|
+
# c.help "This is the help text when the user runs `amp help add`"
|
|
23
|
+
# end
|
|
24
|
+
#
|
|
25
|
+
class Command
|
|
26
|
+
include CommandSupport
|
|
27
|
+
# All the commands registered in the system
|
|
28
|
+
@@all_commands = {}
|
|
29
|
+
|
|
30
|
+
# Synonyms for commands. Used as a backup.
|
|
31
|
+
@@all_synonyms = {}
|
|
32
|
+
|
|
33
|
+
# These are options that all commands support. Allows the user to put
|
|
34
|
+
# them after the subcommand.
|
|
35
|
+
GLOBAL_OPTIONS = []
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# Returns all of the commands registered in the system.
|
|
39
|
+
#
|
|
40
|
+
# @return [Hash] the commands, keyed by command name as a string
|
|
41
|
+
def self.all_commands
|
|
42
|
+
@@all_commands
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Returns all the synonyms registered in the system.
|
|
47
|
+
#
|
|
48
|
+
# @return [Hash] the synonyms, keyed by the synonym as a string
|
|
49
|
+
def self.all_synonyms
|
|
50
|
+
@@all_synonyms
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
##
|
|
54
|
+
# Returns all of the commands registered in the system.
|
|
55
|
+
#
|
|
56
|
+
# @return [Hash] the commands, keyed by command name as a string
|
|
57
|
+
def self.[](arg)
|
|
58
|
+
return all_commands[arg] if all_commands[arg]
|
|
59
|
+
return all_synonyms[arg] if all_synonyms[arg]
|
|
60
|
+
nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Command-specific command-line options
|
|
64
|
+
attr_accessor :options
|
|
65
|
+
# The name of the command (eg add, init)
|
|
66
|
+
attr_accessor :name
|
|
67
|
+
# Short, 1-line description of the command
|
|
68
|
+
attr_accessor :description
|
|
69
|
+
# The options submitted
|
|
70
|
+
attr_accessor :options
|
|
71
|
+
|
|
72
|
+
##
|
|
73
|
+
# Creates a command in the Amp system. Simply instantiating a new
|
|
74
|
+
# command will make it available to the Amp executable. You configure the
|
|
75
|
+
# command by filling out a block in the command's initializer.
|
|
76
|
+
#
|
|
77
|
+
# @example
|
|
78
|
+
# Command.new("add") do |c|
|
|
79
|
+
# c.opt :include, "Paths to include",
|
|
80
|
+
# :options => {:short => "-I", :multi => true}
|
|
81
|
+
# c.opt :print_names, :desc => "Print the filenames",
|
|
82
|
+
# :options => {:short => "-p", :default => false,
|
|
83
|
+
# :type => :boolean}
|
|
84
|
+
# c.on_run do |options, arguments|
|
|
85
|
+
# puts "silly!"
|
|
86
|
+
# end
|
|
87
|
+
# end
|
|
88
|
+
# @param name the name of the command that the user will use to call
|
|
89
|
+
# the command
|
|
90
|
+
# @param &block a block of code where you can configure the command
|
|
91
|
+
# @yield This block configures the command. Set up options, add an on_run
|
|
92
|
+
# handler, and so on.
|
|
93
|
+
# @yieldparam The command itself - it is yielded so you can modify it.
|
|
94
|
+
def initialize(name)
|
|
95
|
+
# so that you can do additions to commands, just like ammending rake takss
|
|
96
|
+
name = name.to_s
|
|
97
|
+
if @@all_commands[name]
|
|
98
|
+
yield @@all_commands[name]
|
|
99
|
+
return
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
@name = name
|
|
103
|
+
@help = ""
|
|
104
|
+
@description = ""
|
|
105
|
+
@options = []
|
|
106
|
+
@@all_commands[name] = self
|
|
107
|
+
@before = []
|
|
108
|
+
@after = []
|
|
109
|
+
@break = false
|
|
110
|
+
yield(self) if block_given?
|
|
111
|
+
@options += GLOBAL_OPTIONS
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
##
|
|
115
|
+
# Adds an command-line option to the command.
|
|
116
|
+
#
|
|
117
|
+
# @param name the name of the command the user will type to run it
|
|
118
|
+
# @param desc the short, one-line description of the command
|
|
119
|
+
# @param options the options that configure the command-line option
|
|
120
|
+
# (too meta? sorry!)
|
|
121
|
+
# @option [String] options :short (nil) the short version of the option
|
|
122
|
+
# (e.g. "-I")
|
|
123
|
+
# @option [String] options :default (nil) the default value of the option.
|
|
124
|
+
# @option [Symbol] options :type (:string) the type of the option. Allows
|
|
125
|
+
# you to force Integer or URL matches.
|
|
126
|
+
# @option [Boolean] options :multi (false) can this option take multiple
|
|
127
|
+
# values?
|
|
128
|
+
def opt(name, desc='', options={})
|
|
129
|
+
@options << {:name => name, :desc => desc, :options => options}
|
|
130
|
+
end
|
|
131
|
+
alias_method :add_opt, :opt
|
|
132
|
+
|
|
133
|
+
##
|
|
134
|
+
# This method is how you set what the command does when it is run.
|
|
135
|
+
#
|
|
136
|
+
# @param &block the code to run when the command runs
|
|
137
|
+
# @yield The code to run when the command is executed, after options
|
|
138
|
+
# are prepared.
|
|
139
|
+
# @yieldparam options The options that the dispatcher has prepared for
|
|
140
|
+
# the command. Includes global and local.
|
|
141
|
+
# @yieldparam arguments All arguments passed to the command, after
|
|
142
|
+
# the options.
|
|
143
|
+
# @example
|
|
144
|
+
# Command.new("email_news") do |c|
|
|
145
|
+
# c.on_run do |options, arguments|
|
|
146
|
+
# arguments.each do |email_address|
|
|
147
|
+
# send_some_email(options[:email_subject],email_address)
|
|
148
|
+
# end
|
|
149
|
+
# end
|
|
150
|
+
# end
|
|
151
|
+
def on_run(&block)
|
|
152
|
+
@code = block
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
##
|
|
156
|
+
# This method lets you set a synonym (or synonyms) for this command.
|
|
157
|
+
# For example, the "remove" command has the synonym "rm". Example:
|
|
158
|
+
# command :remove do |c|
|
|
159
|
+
# c.synonym :rm, :destroy, :nuke
|
|
160
|
+
# end
|
|
161
|
+
# then you can do
|
|
162
|
+
# amp nuke badfile.rb
|
|
163
|
+
#
|
|
164
|
+
def synonym(*args)
|
|
165
|
+
args.each do |arg|
|
|
166
|
+
@@all_synonyms[arg.to_s] = self
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
##
|
|
171
|
+
# This returns the list of actions to run before the command, in order (first
|
|
172
|
+
# ones are run first). You can modify this array in any way you choose, and
|
|
173
|
+
# it is run _before_ the command is run.
|
|
174
|
+
#
|
|
175
|
+
# @yield Extra code to run before the command is executed, after options are prepared.
|
|
176
|
+
# @yieldparam options The options that the dispatcher has prepared for the command. Includes global and local.
|
|
177
|
+
# @yieldparam arguments All arguments passed to the command, after the options.
|
|
178
|
+
# @return [Hash] an array of strings and blocks. Strings are assumed to be command
|
|
179
|
+
# names and blocks are pieces of code to be run.
|
|
180
|
+
def before(*args, &block)
|
|
181
|
+
args.each do |arg|
|
|
182
|
+
@before << proc {|opts, args| Volt::Command[arg.to_sym].run(opts, args) }
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
@before << block if block
|
|
186
|
+
@before
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
##
|
|
190
|
+
# This returns the list of actions to run after the command, in order (first
|
|
191
|
+
# ones are run first). You can modify this array in any way you choose, and
|
|
192
|
+
# it is run _after_ the command is run.
|
|
193
|
+
#
|
|
194
|
+
# @yield Extra code to run after the command is executed, after options are prepared.
|
|
195
|
+
# @yieldparam options The options that the dispatcher has prepared for the command. Includes global and local.
|
|
196
|
+
# @yieldparam arguments All arguments passed to the command, after the options.
|
|
197
|
+
# @return [Hash] an array of strings and blocks. Strings are assumed to be command
|
|
198
|
+
# names and blocks are pieces of code to be run.
|
|
199
|
+
def after(*args, &block)
|
|
200
|
+
args.each do |arg|
|
|
201
|
+
@after << proc {|opts, args| Volt::Command[arg.to_sym].run(opts, args) }
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
@after << block if block
|
|
205
|
+
@after
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
##
|
|
209
|
+
# Sets the short description for the command. This shouuld be only 1 line,
|
|
210
|
+
# as it's what the user sees when they run `amp --help` and get the
|
|
211
|
+
# full list of commands. `str` defaults to nil so that if no argument is
|
|
212
|
+
# passed, by default #desc will just return `@description`. If `str` is
|
|
213
|
+
# passed a string, then it will set `@description` to `str`.
|
|
214
|
+
#
|
|
215
|
+
# @example cmd.desc "This command is useless."
|
|
216
|
+
# @example cmd.desc # => "This command is useless."
|
|
217
|
+
# @param [String, nil] str the help text to set
|
|
218
|
+
def desc(str=nil)
|
|
219
|
+
str ? @description = str : @description
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
##
|
|
223
|
+
# Sets the short description for the command. This shouuld be only 1 line,
|
|
224
|
+
# as it's what the user sees when they run `amp --help` and get the
|
|
225
|
+
# full list of commands.
|
|
226
|
+
#
|
|
227
|
+
# @param str the help text to set
|
|
228
|
+
alias :desc= :desc
|
|
229
|
+
|
|
230
|
+
##
|
|
231
|
+
# Trollop's help info for the command
|
|
232
|
+
def educate
|
|
233
|
+
# comments are the devil's work.
|
|
234
|
+
# comments are the devil's work.
|
|
235
|
+
@parser ? @parser.educate : ''
|
|
236
|
+
end
|
|
237
|
+
alias_method :education, :educate
|
|
238
|
+
|
|
239
|
+
##
|
|
240
|
+
# Sets the command to not laod a repository when run. Useful for purely
|
|
241
|
+
# informational commands (such as version) or initializing a new
|
|
242
|
+
# repository.
|
|
243
|
+
def no_repo
|
|
244
|
+
NO_REPO_ALLOWED[@name] = true
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# @see no_repo
|
|
248
|
+
def no_repo=(value)
|
|
249
|
+
NO_REPO_ALLOWED[@name] = value
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
##
|
|
253
|
+
# Sets the command to not require a repository to run, but try to load one.
|
|
254
|
+
# Used, for example, for the templates command, which sometimes stores
|
|
255
|
+
# comments are the devil's work.
|
|
256
|
+
# comments are the devil's work.
|
|
257
|
+
# comments are the devil's work.
|
|
258
|
+
# comments are the devil's work.
|
|
259
|
+
# information in the local repository.
|
|
260
|
+
def maybe_repo
|
|
261
|
+
MAYBE_REPO_ALLOWED[@name] = true
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# @see no_repo
|
|
265
|
+
def maybe_repo=(value)
|
|
266
|
+
MAYBE_REPO_ALLOWED[@name] = value
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
##
|
|
270
|
+
# Sets the help text for the command. This can be a very long string,
|
|
271
|
+
# as it is what the user sees when they type `amp help +name+`
|
|
272
|
+
#
|
|
273
|
+
# @param str the help text to set
|
|
274
|
+
# comments are the devil's work.
|
|
275
|
+
# comments are the devil's work.
|
|
276
|
+
# @example cmd.help %Q{
|
|
277
|
+
# Big help text!
|
|
278
|
+
# }
|
|
279
|
+
def help(str=nil)
|
|
280
|
+
str ? @help << str : @help
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
##
|
|
284
|
+
# Sets the help text for the command. This can be a very long string,
|
|
285
|
+
# as it is what the user sees when they type `amp help +name+`
|
|
286
|
+
# comments are the devil's work.
|
|
287
|
+
# comments are the devil's work.
|
|
288
|
+
#
|
|
289
|
+
# @param str the help text to set
|
|
290
|
+
alias :help= :help
|
|
291
|
+
|
|
292
|
+
##
|
|
293
|
+
# Parses the commands from the command line using Trollop. You probably
|
|
294
|
+
# shouldn't override this method, but if you have good reason, go for it.
|
|
295
|
+
#
|
|
296
|
+
# @return [Hash] The parsed command-line options
|
|
297
|
+
def collect_options
|
|
298
|
+
options = @options # hack to get around the fact that
|
|
299
|
+
help = @help # Trollop uses instance eval
|
|
300
|
+
|
|
301
|
+
Trollop::options do
|
|
302
|
+
# we can't use @options here because Trollop::options uses instance_eval
|
|
303
|
+
options.each do |option|
|
|
304
|
+
opt option[:name], option[:desc], option[:options]
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
banner help
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def inspect
|
|
313
|
+
"#<Amp::Command #{name} >"
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
##
|
|
317
|
+
# Stops this command from running any further - uses the global options.
|
|
318
|
+
# comments are the devil's work.
|
|
319
|
+
# comments are the devil's work.
|
|
320
|
+
def break
|
|
321
|
+
@break = true
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
##
|
|
325
|
+
# comments are the devil's work.
|
|
326
|
+
def run(options={}, args=[])
|
|
327
|
+
# run the before commands
|
|
328
|
+
@before.each {|cmd| cmd.run options, args; return if @break }
|
|
329
|
+
|
|
330
|
+
@code[options, args] # and of course the actual command...
|
|
331
|
+
|
|
332
|
+
# top it off with the after commands
|
|
333
|
+
@after.each {|cmd| cmd.run options, args; return if @break }
|
|
334
|
+
|
|
335
|
+
self
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
NO_REPO_ALLOWED = {}
|
|
339
|
+
%w(clone init help version debugcomplete debugdata debugindex
|
|
340
|
+
debugindexdot debugdate debuginstall debugfsinfo).each do |k|
|
|
341
|
+
NO_REPO_ALLOWED[k] = true
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
MAYBE_REPO_ALLOWED = {}
|
|
345
|
+
%w().each do |k|
|
|
346
|
+
MAYBE_REPO_ALLOWED[k] = true
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
module Kernel
|
|
353
|
+
# shortcut
|
|
354
|
+
def command(name, &block)
|
|
355
|
+
Amp::Command.new name, &block
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# Rake style namespacing
|
|
359
|
+
# After new commands are made, alter their names
|
|
360
|
+
# so that they're "#{namespace}:#{command}"
|
|
361
|
+
def silly_namespace(name)
|
|
362
|
+
# current commands
|
|
363
|
+
commands = Amp::Command.all_commands.keys
|
|
364
|
+
|
|
365
|
+
yield
|
|
366
|
+
|
|
367
|
+
more_commands = Amp::Command.all_commands.keys
|
|
368
|
+
new_commands = more_commands - commands
|
|
369
|
+
|
|
370
|
+
new_commands.each do |key|
|
|
371
|
+
command_to_modify = Amp::Command[key]
|
|
372
|
+
command_to_modify.name = "#{name}:#{key}" # construct the new name
|
|
373
|
+
Amp::Command.all_commands[command_to_modify.name] = Amp::Command.all_commands.delete(key) # and do the switch
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
end
|