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,54 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'yard'
|
|
3
|
+
|
|
4
|
+
YARD::Registry.load
|
|
5
|
+
|
|
6
|
+
module Docable
|
|
7
|
+
|
|
8
|
+
def tag_callbacks; @tag_callbacks ||= {}; end
|
|
9
|
+
|
|
10
|
+
def tag_callback(name, &block)
|
|
11
|
+
tag_callbacks[name] = block
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def docs_for(method)
|
|
15
|
+
klass = YARD::Registry.all(:class).detect do |k|
|
|
16
|
+
k.name == name.split("::").last.to_sym
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
meth = klass.meths.detect {|m| m.name == method }
|
|
20
|
+
|
|
21
|
+
puts "=== Documentation for #{self}##{method}"
|
|
22
|
+
puts meth.docstring
|
|
23
|
+
puts "---"
|
|
24
|
+
puts meth.signature
|
|
25
|
+
puts
|
|
26
|
+
|
|
27
|
+
tag_callbacks.to_a.sort.each do |(tag, block)|
|
|
28
|
+
if meth.has_tag? tag
|
|
29
|
+
puts
|
|
30
|
+
tags = meth.tags.select {|t| t.tag_name == tag.to_s }
|
|
31
|
+
block.call meth, tags
|
|
32
|
+
puts
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
puts "It can be found at #{meth.file}:#{meth.line}"
|
|
37
|
+
puts "==="
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class Object
|
|
42
|
+
extend Docable
|
|
43
|
+
|
|
44
|
+
tag_callback :param do |meth, tags|
|
|
45
|
+
puts "Arguments are:"
|
|
46
|
+
tags.each do |p|
|
|
47
|
+
puts "\t[#{p.types.join ', '}] #{p.name} #{"|" if p.text } #{p.text}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
tag_callback :tags do |meth, tags|
|
|
52
|
+
puts "Tagged with: #{tags.map {|t| t.tags }.join ', '}"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
##
|
|
2
|
+
# Stolen/heavily modified from
|
|
3
|
+
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/140603
|
|
4
|
+
# Thanks man
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
# Example generator. Note that we put +nil+ at the end to indicate the end of generation.
|
|
8
|
+
# class Fibonacci < Generator
|
|
9
|
+
# def generator_loop
|
|
10
|
+
# previous, current=0,1
|
|
11
|
+
# 10.times do
|
|
12
|
+
#
|
|
13
|
+
# # works
|
|
14
|
+
# yield_gen current
|
|
15
|
+
# previous, current = current, previous + current
|
|
16
|
+
# end
|
|
17
|
+
# nil
|
|
18
|
+
# end
|
|
19
|
+
# end
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# Generic generator. woo. Implement +generator_loop+ to make a concrete subclass.
|
|
23
|
+
#
|
|
24
|
+
# Allows you to create an object that lazily generates values and yields them
|
|
25
|
+
# when the next() method is called.
|
|
26
|
+
class Generator
|
|
27
|
+
|
|
28
|
+
##
|
|
29
|
+
# Generic initializer for a Generator. If you subclass, you must caller super
|
|
30
|
+
# to initialize the continuation ivars.
|
|
31
|
+
def initialize
|
|
32
|
+
@current_context = nil
|
|
33
|
+
reset
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
##
|
|
37
|
+
# Runs the next iteration of the generator. Uses continuations to jump across
|
|
38
|
+
# the stack all willy-nilly like.
|
|
39
|
+
#
|
|
40
|
+
# @return [Object] the next generated object.
|
|
41
|
+
def next
|
|
42
|
+
# by setting @current_context to +here+, when @current_context is called, next() will
|
|
43
|
+
# return to its caller.
|
|
44
|
+
callcc do |here|
|
|
45
|
+
@current_context = here
|
|
46
|
+
if @yield_context
|
|
47
|
+
# Run next iteration of the running loop
|
|
48
|
+
@yield_context.call
|
|
49
|
+
else
|
|
50
|
+
# Start the loop
|
|
51
|
+
generator_loop
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# Resets the generator from the beginning
|
|
58
|
+
def reset
|
|
59
|
+
@yield_context = nil
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# Yields a value from within the generator_loop method to the caller of +next+.
|
|
66
|
+
# This method actually is what returns a value from a call to next through the
|
|
67
|
+
# roundabout nature of continuations.
|
|
68
|
+
#
|
|
69
|
+
# @param value the value to return from +next+
|
|
70
|
+
def yield_gen(value)
|
|
71
|
+
callcc do |cont|
|
|
72
|
+
@yield_context = cont
|
|
73
|
+
@current_context.call value # causes next() to immediately return +value+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
module Amp
|
|
2
|
+
module Ignore
|
|
3
|
+
extend self
|
|
4
|
+
|
|
5
|
+
COMMENT = /((^|[^\\])(\\\\)*)#.*/
|
|
6
|
+
SYNTAXES = {'re' => :regexp, 'regexp' => :regexp, 'glob' => :glob,
|
|
7
|
+
'relglob' => :relglob, 'relre' => :regexp, 'path' => :glob,
|
|
8
|
+
'relpath' => :relglob}
|
|
9
|
+
##
|
|
10
|
+
# Parses the ignore file, +file+ (or ".hgignore")
|
|
11
|
+
#
|
|
12
|
+
# @param [String] root the root of the repo
|
|
13
|
+
# @param [Array<String>] files absolute paths to files
|
|
14
|
+
def parse_ignore(root, files=[])
|
|
15
|
+
patterns = {} # not sure what this is
|
|
16
|
+
|
|
17
|
+
files.each do |file|
|
|
18
|
+
syntax = 're' # default syntax
|
|
19
|
+
text = File.read File.join(root,file) rescue next
|
|
20
|
+
pattern = matcher_for_text text
|
|
21
|
+
patterns[file] = pattern if pattern
|
|
22
|
+
end # files.each
|
|
23
|
+
|
|
24
|
+
all_patterns = patterns.values.flatten
|
|
25
|
+
# let the system know that nothing is ignored
|
|
26
|
+
return proc { false } if all_patterns.empty?
|
|
27
|
+
# here's the proc to do the tests
|
|
28
|
+
regexps_to_proc all_patterns
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# Parse the lines into valid syntax
|
|
33
|
+
#
|
|
34
|
+
# @param [String] file and open file
|
|
35
|
+
def parse_lines(text)
|
|
36
|
+
lines = text.split("\n").map do |line|
|
|
37
|
+
if line =~ /#/
|
|
38
|
+
line.sub! COMMENT, "\\1"
|
|
39
|
+
line.gsub! "\\#", "#"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
line.rstrip!
|
|
43
|
+
line.empty? ? nil : line
|
|
44
|
+
end
|
|
45
|
+
lines.compact
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
##
|
|
49
|
+
# Produces an array of regexps which can be used
|
|
50
|
+
# for matching files
|
|
51
|
+
#
|
|
52
|
+
# @param [String] text the text to parse
|
|
53
|
+
# @return [[Regexp]] the regexps generated from the strings and syntaxes
|
|
54
|
+
def matcher_for_text(text)
|
|
55
|
+
return [] unless text
|
|
56
|
+
syntax = nil
|
|
57
|
+
patterns = parse_lines(text).map do |line|
|
|
58
|
+
next if line.empty?
|
|
59
|
+
# check for syntax changes
|
|
60
|
+
if line =~ /^syntax:/
|
|
61
|
+
syntax = SYNTAXES[line[7..-1].strip] || :regexp
|
|
62
|
+
next # move on
|
|
63
|
+
end
|
|
64
|
+
parse_line syntax, line # could be nil, so we need to compact it
|
|
65
|
+
end # parsed_lines(text)
|
|
66
|
+
patterns.compact # kill the nils
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
##
|
|
70
|
+
# Much like matcher_for_text, except tailored to single line strings
|
|
71
|
+
#
|
|
72
|
+
# @see matcher_for_text
|
|
73
|
+
# @param [String] string the string to parse
|
|
74
|
+
# @return [Regexp] the regexps generated from the strings and syntaxes
|
|
75
|
+
def matcher_for_string(string)
|
|
76
|
+
scanpt = string =~ /(\w+):(.+)/
|
|
77
|
+
if scanpt.nil?
|
|
78
|
+
# just a line, no specified syntax
|
|
79
|
+
syntax = 'regexp'
|
|
80
|
+
# no syntax, the whole thing is a pattern
|
|
81
|
+
include_regexp = string
|
|
82
|
+
else
|
|
83
|
+
syntax = $1 # the syntax is the first match
|
|
84
|
+
include_regexp = $2.strip # the rest of the string is the pattern
|
|
85
|
+
end
|
|
86
|
+
include_syntax = syntax.to_sym
|
|
87
|
+
parse_line include_syntax, include_regexp
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
##
|
|
91
|
+
# Turns a single line, given a syntax, into either
|
|
92
|
+
# a valid regexp or nil. If it is nil, it means the
|
|
93
|
+
# syntax was incorrect.
|
|
94
|
+
#
|
|
95
|
+
# @param [Symbol] syntax the syntax to parse with (:regexp, :glob, :relglob)
|
|
96
|
+
# @param [String] line the line to parse
|
|
97
|
+
# @return [NilClass, Regexp] nil means the syntax was a bad choice
|
|
98
|
+
def parse_line(syntax, line)
|
|
99
|
+
return nil unless syntax
|
|
100
|
+
|
|
101
|
+
# find more valid syntax stuff
|
|
102
|
+
# we need to make everything here valid regexps
|
|
103
|
+
case syntax.to_sym
|
|
104
|
+
when :regexp
|
|
105
|
+
# basic regex
|
|
106
|
+
pattern = /#{line}/
|
|
107
|
+
when :glob, :relglob
|
|
108
|
+
# glob: glob (shell style), relative to the root of the repository
|
|
109
|
+
# relglob: glob, except we just match somewhere in the string, not from the root of
|
|
110
|
+
# the repository
|
|
111
|
+
ps = line.split '/**/'
|
|
112
|
+
ps.map! do |l|
|
|
113
|
+
parts = l.split '*' # split it up and we'll escape all the parts
|
|
114
|
+
parts.map! {|p| Regexp.escape p }
|
|
115
|
+
/#{parts.join '[^/]*'}/ # anything but a slash, ie, no change in directories
|
|
116
|
+
end
|
|
117
|
+
joined = ps.join '/(?:.*/)*'
|
|
118
|
+
pattern = (syntax.to_sym == :glob) ? /^#{joined}/ : /#{joined}/
|
|
119
|
+
else
|
|
120
|
+
pattern = nil
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
pattern
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
##
|
|
127
|
+
# Converts all the ignored regexps into a proc that matches against all of these
|
|
128
|
+
# regexps. That way we can pass around a single proc that checks if a file is ignored.
|
|
129
|
+
#
|
|
130
|
+
# @param [Array<Regexp>] regexps all of the regexes that we need to match against
|
|
131
|
+
# @return [Proc] a proc that, when called with a file's path, will return whether
|
|
132
|
+
# it matches any of the regexps.
|
|
133
|
+
def regexps_to_proc(*regexps)
|
|
134
|
+
regexps = regexps.flatten.compact # needed because of possible nils
|
|
135
|
+
if regexps.empty?
|
|
136
|
+
proc { false }
|
|
137
|
+
else
|
|
138
|
+
proc { |file| regexps.any? {|p| file =~ p } }
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
alias_method :regexp_to_proc, :regexps_to_proc
|
|
142
|
+
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# taken straight from the need gem!
|
|
2
|
+
# need takes a block which should contain a string of the relative path to the file
|
|
3
|
+
# you wish to need.
|
|
4
|
+
$times = []
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
# Loads a given file, relative to the directory of the file executing the need statement.
|
|
8
|
+
#
|
|
9
|
+
# @example need { "silly.rb" }
|
|
10
|
+
# @example need("silly.rb")
|
|
11
|
+
# @param [String] file the file to load
|
|
12
|
+
def need(file=nil, &block)
|
|
13
|
+
# do some timing if we're still benchmarking
|
|
14
|
+
s = Time.now if ENV["TESTING"] == "true"
|
|
15
|
+
|
|
16
|
+
if block_given?
|
|
17
|
+
if RUBY_VERSION < "1.9" && (!defined?(RUBY_ENGINE) || RUBY_ENGINE != 'rbx')
|
|
18
|
+
require File.expand_path(File.join(File.dirname(eval("__FILE__", block.binding)),block.call)) # 1.9 hack
|
|
19
|
+
else
|
|
20
|
+
require File.expand_path(File.join(File.dirname(caller_file(0)),block.call))
|
|
21
|
+
end
|
|
22
|
+
elsif file
|
|
23
|
+
require File.expand_path(File.join(File.dirname(__FILE__),file))
|
|
24
|
+
end
|
|
25
|
+
# do some timing if we're still benchmarking
|
|
26
|
+
$times << [Time.now - s, block ? block.call : file] if ENV["TESTING"] == "true"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# Loads an entire directory, relative to the caller's file
|
|
31
|
+
#
|
|
32
|
+
# @example require_dir { "commands/**/*.rb" }
|
|
33
|
+
# @param [String] dir the directory, in glob format, to load
|
|
34
|
+
# @yield returns the string of the directory
|
|
35
|
+
def require_dir(dir=nil, &block)
|
|
36
|
+
# do some timing if we're still benchmarking
|
|
37
|
+
s = Time.now if ENV["TESTING"] == "true"
|
|
38
|
+
|
|
39
|
+
if block_given?
|
|
40
|
+
Dir[File.join(Amp::CODE_ROOT, block.call)].each do |f|
|
|
41
|
+
unless File.directory? f
|
|
42
|
+
f = f[Amp::CODE_ROOT.size+1..-1]
|
|
43
|
+
require f
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
else
|
|
47
|
+
Dir[dir].each {|f| require f unless File.directory? f }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# do some timing if we're still benchmarking
|
|
51
|
+
$times << [Time.now - s, block ? block.call : file] if ENV["TESTING"] == "true"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
##
|
|
55
|
+
# Finds the caller's file path. +level+ specifies how far down the call stack to look.
|
|
56
|
+
#
|
|
57
|
+
# @param [Fixnum] level the point in the call stack to look - 0 = top, 1 = caller, etc.
|
|
58
|
+
# @return [String, NilClass] the path to the caller function's file.
|
|
59
|
+
def caller_file(level=0)
|
|
60
|
+
if caller[level] # call stack big enough?
|
|
61
|
+
if RUBY_VERSION < "1.9" # this is for 1.8
|
|
62
|
+
File.expand_path(caller[level].split(":").first)
|
|
63
|
+
else
|
|
64
|
+
File.expand_path(caller[level+1].split(":").first)
|
|
65
|
+
end
|
|
66
|
+
end # returns nil by default
|
|
67
|
+
end
|
|
68
|
+
private :caller_file
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# Loads a C extension, or an alternate file if the C cannot be loaded for any reason
|
|
72
|
+
# (such as the user not compiling it).
|
|
73
|
+
#
|
|
74
|
+
# @param [String] path_to_c the path to the C library. Will be loaded relative to
|
|
75
|
+
# the caller's file.
|
|
76
|
+
# @param [String] path_to_alt the path to the pure ruby version of the C library. Will
|
|
77
|
+
# be loaded relative to the caller's file
|
|
78
|
+
def amp_c_extension(path_to_c, path_to_alt)
|
|
79
|
+
|
|
80
|
+
if $USE_RUBY
|
|
81
|
+
Amp::UI.debug "Loading alternative ruby: #{path_to_alt}"
|
|
82
|
+
require File.join(File.dirname(caller_file(1)), path_to_alt)
|
|
83
|
+
return
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
begin
|
|
87
|
+
offset = RUBY_VERSION < "1.9" ? 1 : 0
|
|
88
|
+
require File.expand_path(File.join(File.dirname(caller_file(offset)), path_to_c))
|
|
89
|
+
rescue LoadError # C Version could not be found, try ruby version
|
|
90
|
+
Amp::UI.debug "Loading alternative ruby: #{path_to_alt}"
|
|
91
|
+
require File.join(File.dirname(caller_file(1)), path_to_alt)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'delegate'
|
|
2
|
+
require 'logger'
|
|
3
|
+
module Amp
|
|
4
|
+
module Support
|
|
5
|
+
module SingletonLogger
|
|
6
|
+
attr_accessor :singleton_object
|
|
7
|
+
def global_logger
|
|
8
|
+
singleton_object
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def warn(*args); global_logger.warn(*args); end
|
|
12
|
+
def info(*args); global_logger.info(*args); end
|
|
13
|
+
def fatal(*args); global_logger.fatal(*args); end
|
|
14
|
+
def error(*args); global_logger.error(*args); end
|
|
15
|
+
def debug(*args); global_logger.debug(*args); end
|
|
16
|
+
|
|
17
|
+
def method_missing(meth, *args, &block)
|
|
18
|
+
if global_logger.respond_to?(meth)
|
|
19
|
+
global_logger.__send__(meth, *args, &block)
|
|
20
|
+
else
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class IOForwarder
|
|
27
|
+
def initialize(output)
|
|
28
|
+
@output = output
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def warn(input); @output.puts(input); end
|
|
32
|
+
def info(input); @output.puts(input); end
|
|
33
|
+
def fatal(input); @output.puts(input); end
|
|
34
|
+
def error(input); @output.puts(input); end
|
|
35
|
+
def debug(input); @output.puts(input); end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class Logger < DelegateClass(::Logger)
|
|
39
|
+
extend SingletonLogger
|
|
40
|
+
|
|
41
|
+
def initialize(output)
|
|
42
|
+
@show_times = true
|
|
43
|
+
@output = output
|
|
44
|
+
@source = ::Logger.new(output)
|
|
45
|
+
@indent = 0
|
|
46
|
+
super(@source)
|
|
47
|
+
self.class.singleton_object = self
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def show_times=(bool)
|
|
51
|
+
if @show_times && !bool # turn off times
|
|
52
|
+
@normal_source = @source
|
|
53
|
+
@source = IOForwarder.new(@output)
|
|
54
|
+
elsif !@show_times && bool # turn it back on
|
|
55
|
+
@source = @normal_source
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def section(section_name)
|
|
60
|
+
info("<#{section_name}>").indent
|
|
61
|
+
yield
|
|
62
|
+
outdent.info("</#{section_name}>")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def indent
|
|
66
|
+
@indent += 1
|
|
67
|
+
self
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def outdent
|
|
71
|
+
@indent -= 1
|
|
72
|
+
self
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def warn(input); @source.warn( "\t\t"*@indent + input); self; end
|
|
76
|
+
def info(input); @source.info( "\t\t"*@indent + input); self; end
|
|
77
|
+
def fatal(input); @source.fatal("\t\t"*@indent + input); self; end
|
|
78
|
+
def error(input); @source.error("\t\t"*@indent + input); self; end
|
|
79
|
+
def debug(input); @source.debug("\t\t"*@indent + input); self; end
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def level=(level)
|
|
83
|
+
receiver = @source
|
|
84
|
+
case level
|
|
85
|
+
when :warn
|
|
86
|
+
receiver.level = ::Logger::WARN
|
|
87
|
+
when :fatal
|
|
88
|
+
receiver.level = ::Logger::FATAL
|
|
89
|
+
when :error
|
|
90
|
+
receiver.level = ::Logger::ERROR
|
|
91
|
+
when :info
|
|
92
|
+
receiver.level = ::Logger::INFO
|
|
93
|
+
when :debug
|
|
94
|
+
receiver.level = ::Logger::DEBUG
|
|
95
|
+
when :none
|
|
96
|
+
receiver.level = ::Logger::UNKNOWN
|
|
97
|
+
else
|
|
98
|
+
receiver.level = level
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|