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.
Files changed (295) hide show
  1. data/.gitignore +1 -0
  2. data/.hgignore +26 -0
  3. data/AUTHORS +2 -0
  4. data/History.txt +6 -0
  5. data/LICENSE +37 -0
  6. data/MANIFESTO +7 -0
  7. data/Manifest.txt +294 -0
  8. data/README.md +129 -0
  9. data/Rakefile +102 -0
  10. data/SCHEDULE.markdown +12 -0
  11. data/STYLE +27 -0
  12. data/TODO.markdown +149 -0
  13. data/ampfile.rb +47 -0
  14. data/bin/amp +30 -0
  15. data/bin/amp1.9 +30 -0
  16. data/ext/amp/bz2/README.txt +39 -0
  17. data/ext/amp/bz2/bz2.c +1582 -0
  18. data/ext/amp/bz2/extconf.rb +77 -0
  19. data/ext/amp/bz2/mkmf.log +29 -0
  20. data/ext/amp/mercurial_patch/extconf.rb +5 -0
  21. data/ext/amp/mercurial_patch/mpatch.c +405 -0
  22. data/ext/amp/priority_queue/extconf.rb +5 -0
  23. data/ext/amp/priority_queue/priority_queue.c +947 -0
  24. data/ext/amp/support/extconf.rb +5 -0
  25. data/ext/amp/support/support.c +250 -0
  26. data/lib/amp.rb +200 -0
  27. data/lib/amp/commands/command.rb +507 -0
  28. data/lib/amp/commands/command_support.rb +137 -0
  29. data/lib/amp/commands/commands/config.rb +143 -0
  30. data/lib/amp/commands/commands/help.rb +29 -0
  31. data/lib/amp/commands/commands/init.rb +10 -0
  32. data/lib/amp/commands/commands/templates.rb +137 -0
  33. data/lib/amp/commands/commands/version.rb +7 -0
  34. data/lib/amp/commands/commands/workflow.rb +28 -0
  35. data/lib/amp/commands/commands/workflows/git/add.rb +65 -0
  36. data/lib/amp/commands/commands/workflows/git/copy.rb +27 -0
  37. data/lib/amp/commands/commands/workflows/git/mv.rb +23 -0
  38. data/lib/amp/commands/commands/workflows/git/rm.rb +60 -0
  39. data/lib/amp/commands/commands/workflows/hg/add.rb +53 -0
  40. data/lib/amp/commands/commands/workflows/hg/addremove.rb +86 -0
  41. data/lib/amp/commands/commands/workflows/hg/annotate.rb +46 -0
  42. data/lib/amp/commands/commands/workflows/hg/archive.rb +126 -0
  43. data/lib/amp/commands/commands/workflows/hg/branch.rb +28 -0
  44. data/lib/amp/commands/commands/workflows/hg/branches.rb +30 -0
  45. data/lib/amp/commands/commands/workflows/hg/bundle.rb +115 -0
  46. data/lib/amp/commands/commands/workflows/hg/clone.rb +95 -0
  47. data/lib/amp/commands/commands/workflows/hg/commit.rb +42 -0
  48. data/lib/amp/commands/commands/workflows/hg/copy.rb +31 -0
  49. data/lib/amp/commands/commands/workflows/hg/debug/dirstate.rb +32 -0
  50. data/lib/amp/commands/commands/workflows/hg/debug/index.rb +36 -0
  51. data/lib/amp/commands/commands/workflows/hg/default.rb +9 -0
  52. data/lib/amp/commands/commands/workflows/hg/diff.rb +30 -0
  53. data/lib/amp/commands/commands/workflows/hg/forget.rb +11 -0
  54. data/lib/amp/commands/commands/workflows/hg/heads.rb +25 -0
  55. data/lib/amp/commands/commands/workflows/hg/identify.rb +23 -0
  56. data/lib/amp/commands/commands/workflows/hg/import.rb +135 -0
  57. data/lib/amp/commands/commands/workflows/hg/incoming.rb +85 -0
  58. data/lib/amp/commands/commands/workflows/hg/info.rb +18 -0
  59. data/lib/amp/commands/commands/workflows/hg/log.rb +21 -0
  60. data/lib/amp/commands/commands/workflows/hg/manifest.rb +13 -0
  61. data/lib/amp/commands/commands/workflows/hg/merge.rb +53 -0
  62. data/lib/amp/commands/commands/workflows/hg/move.rb +28 -0
  63. data/lib/amp/commands/commands/workflows/hg/outgoing.rb +61 -0
  64. data/lib/amp/commands/commands/workflows/hg/pull.rb +74 -0
  65. data/lib/amp/commands/commands/workflows/hg/push.rb +20 -0
  66. data/lib/amp/commands/commands/workflows/hg/remove.rb +45 -0
  67. data/lib/amp/commands/commands/workflows/hg/resolve.rb +83 -0
  68. data/lib/amp/commands/commands/workflows/hg/revert.rb +53 -0
  69. data/lib/amp/commands/commands/workflows/hg/root.rb +13 -0
  70. data/lib/amp/commands/commands/workflows/hg/serve.rb +38 -0
  71. data/lib/amp/commands/commands/workflows/hg/status.rb +116 -0
  72. data/lib/amp/commands/commands/workflows/hg/tag.rb +69 -0
  73. data/lib/amp/commands/commands/workflows/hg/tags.rb +27 -0
  74. data/lib/amp/commands/commands/workflows/hg/tip.rb +13 -0
  75. data/lib/amp/commands/commands/workflows/hg/update.rb +27 -0
  76. data/lib/amp/commands/commands/workflows/hg/verify.rb +9 -0
  77. data/lib/amp/commands/commands/workflows/hg/view.rb +36 -0
  78. data/lib/amp/commands/dispatch.rb +181 -0
  79. data/lib/amp/commands/hooks.rb +81 -0
  80. data/lib/amp/dependencies/amp_support.rb +1 -0
  81. data/lib/amp/dependencies/amp_support/ruby_amp_support.rb +103 -0
  82. data/lib/amp/dependencies/minitar.rb +979 -0
  83. data/lib/amp/dependencies/priority_queue.rb +18 -0
  84. data/lib/amp/dependencies/priority_queue/c_priority_queue.rb +1 -0
  85. data/lib/amp/dependencies/priority_queue/poor_priority_queue.rb +46 -0
  86. data/lib/amp/dependencies/priority_queue/ruby_priority_queue.rb +525 -0
  87. data/lib/amp/dependencies/python_config.rb +211 -0
  88. data/lib/amp/dependencies/trollop.rb +713 -0
  89. data/lib/amp/dependencies/zip/ioextras.rb +155 -0
  90. data/lib/amp/dependencies/zip/stdrubyext.rb +111 -0
  91. data/lib/amp/dependencies/zip/tempfile_bugfixed.rb +186 -0
  92. data/lib/amp/dependencies/zip/zip.rb +1850 -0
  93. data/lib/amp/dependencies/zip/zipfilesystem.rb +609 -0
  94. data/lib/amp/dependencies/zip/ziprequire.rb +90 -0
  95. data/lib/amp/encoding/base85.rb +97 -0
  96. data/lib/amp/encoding/binary_diff.rb +82 -0
  97. data/lib/amp/encoding/difflib.rb +166 -0
  98. data/lib/amp/encoding/mercurial_diff.rb +378 -0
  99. data/lib/amp/encoding/mercurial_patch.rb +1 -0
  100. data/lib/amp/encoding/patch.rb +292 -0
  101. data/lib/amp/encoding/pure_ruby/ruby_mercurial_patch.rb +123 -0
  102. data/lib/amp/extensions/ditz.rb +41 -0
  103. data/lib/amp/extensions/lighthouse.rb +167 -0
  104. data/lib/amp/graphs/ancestor.rb +147 -0
  105. data/lib/amp/graphs/copies.rb +261 -0
  106. data/lib/amp/merges/merge_state.rb +164 -0
  107. data/lib/amp/merges/merge_ui.rb +322 -0
  108. data/lib/amp/merges/simple_merge.rb +450 -0
  109. data/lib/amp/profiling_hacks.rb +36 -0
  110. data/lib/amp/repository/branch_manager.rb +234 -0
  111. data/lib/amp/repository/dir_state.rb +950 -0
  112. data/lib/amp/repository/journal.rb +203 -0
  113. data/lib/amp/repository/lock.rb +207 -0
  114. data/lib/amp/repository/repositories/bundle_repository.rb +214 -0
  115. data/lib/amp/repository/repositories/http_repository.rb +377 -0
  116. data/lib/amp/repository/repositories/local_repository.rb +2661 -0
  117. data/lib/amp/repository/repository.rb +94 -0
  118. data/lib/amp/repository/store.rb +485 -0
  119. data/lib/amp/repository/tag_manager.rb +319 -0
  120. data/lib/amp/repository/updatable.rb +532 -0
  121. data/lib/amp/repository/verification.rb +431 -0
  122. data/lib/amp/repository/versioned_file.rb +475 -0
  123. data/lib/amp/revlogs/bundle_revlogs.rb +246 -0
  124. data/lib/amp/revlogs/changegroup.rb +217 -0
  125. data/lib/amp/revlogs/changelog.rb +338 -0
  126. data/lib/amp/revlogs/changeset.rb +521 -0
  127. data/lib/amp/revlogs/file_log.rb +165 -0
  128. data/lib/amp/revlogs/index.rb +493 -0
  129. data/lib/amp/revlogs/manifest.rb +195 -0
  130. data/lib/amp/revlogs/node.rb +18 -0
  131. data/lib/amp/revlogs/revlog.rb +1032 -0
  132. data/lib/amp/revlogs/revlog_support.rb +126 -0
  133. data/lib/amp/server/amp_user.rb +44 -0
  134. data/lib/amp/server/extension/amp_extension.rb +396 -0
  135. data/lib/amp/server/extension/authorization.rb +201 -0
  136. data/lib/amp/server/fancy_http_server.rb +252 -0
  137. data/lib/amp/server/fancy_views/_browser.haml +28 -0
  138. data/lib/amp/server/fancy_views/_diff_file.haml +13 -0
  139. data/lib/amp/server/fancy_views/_navbar.haml +17 -0
  140. data/lib/amp/server/fancy_views/changeset.haml +31 -0
  141. data/lib/amp/server/fancy_views/commits.haml +32 -0
  142. data/lib/amp/server/fancy_views/file.haml +35 -0
  143. data/lib/amp/server/fancy_views/file_diff.haml +23 -0
  144. data/lib/amp/server/fancy_views/harshcss/all_hallows_eve.css +72 -0
  145. data/lib/amp/server/fancy_views/harshcss/amy.css +147 -0
  146. data/lib/amp/server/fancy_views/harshcss/twilight.css +138 -0
  147. data/lib/amp/server/fancy_views/stylesheet.sass +175 -0
  148. data/lib/amp/server/http_server.rb +140 -0
  149. data/lib/amp/server/repo_user_management.rb +287 -0
  150. data/lib/amp/support/amp_config.rb +164 -0
  151. data/lib/amp/support/amp_ui.rb +287 -0
  152. data/lib/amp/support/docs.rb +54 -0
  153. data/lib/amp/support/generator.rb +78 -0
  154. data/lib/amp/support/ignore.rb +144 -0
  155. data/lib/amp/support/loaders.rb +93 -0
  156. data/lib/amp/support/logger.rb +103 -0
  157. data/lib/amp/support/match.rb +151 -0
  158. data/lib/amp/support/multi_io.rb +87 -0
  159. data/lib/amp/support/openers.rb +121 -0
  160. data/lib/amp/support/ruby_19_compatibility.rb +66 -0
  161. data/lib/amp/support/support.rb +1095 -0
  162. data/lib/amp/templates/blank.commit.erb +23 -0
  163. data/lib/amp/templates/blank.log.erb +18 -0
  164. data/lib/amp/templates/default.commit.erb +23 -0
  165. data/lib/amp/templates/default.log.erb +26 -0
  166. data/lib/amp/templates/template.rb +165 -0
  167. data/site/Rakefile +24 -0
  168. data/site/src/about/ampfile.haml +57 -0
  169. data/site/src/about/commands.haml +106 -0
  170. data/site/src/about/index.haml +33 -0
  171. data/site/src/about/performance.haml +31 -0
  172. data/site/src/about/workflows.haml +34 -0
  173. data/site/src/contribute/index.haml +65 -0
  174. data/site/src/contribute/style.haml +297 -0
  175. data/site/src/css/active4d.css +114 -0
  176. data/site/src/css/all_hallows_eve.css +72 -0
  177. data/site/src/css/all_themes.css +3299 -0
  178. data/site/src/css/amp.css +260 -0
  179. data/site/src/css/amy.css +147 -0
  180. data/site/src/css/blackboard.css +88 -0
  181. data/site/src/css/brilliance_black.css +605 -0
  182. data/site/src/css/brilliance_dull.css +599 -0
  183. data/site/src/css/cobalt.css +149 -0
  184. data/site/src/css/cur_amp.css +185 -0
  185. data/site/src/css/dawn.css +121 -0
  186. data/site/src/css/eiffel.css +121 -0
  187. data/site/src/css/espresso_libre.css +109 -0
  188. data/site/src/css/idle.css +62 -0
  189. data/site/src/css/iplastic.css +80 -0
  190. data/site/src/css/lazy.css +73 -0
  191. data/site/src/css/mac_classic.css +123 -0
  192. data/site/src/css/magicwb_amiga.css +104 -0
  193. data/site/src/css/pastels_on_dark.css +188 -0
  194. data/site/src/css/reset.css +55 -0
  195. data/site/src/css/slush_poppies.css +85 -0
  196. data/site/src/css/spacecadet.css +51 -0
  197. data/site/src/css/sunburst.css +180 -0
  198. data/site/src/css/twilight.css +137 -0
  199. data/site/src/css/zenburnesque.css +91 -0
  200. data/site/src/get/index.haml +32 -0
  201. data/site/src/helpers.rb +121 -0
  202. data/site/src/images/amp_logo.png +0 -0
  203. data/site/src/images/carbonica.png +0 -0
  204. data/site/src/images/revolution.png +0 -0
  205. data/site/src/images/tab-bg.png +0 -0
  206. data/site/src/images/tab-sliding-left.png +0 -0
  207. data/site/src/images/tab-sliding-right.png +0 -0
  208. data/site/src/include/_footer.haml +22 -0
  209. data/site/src/include/_header.haml +17 -0
  210. data/site/src/index.haml +104 -0
  211. data/site/src/learn/index.haml +46 -0
  212. data/site/src/scripts/jquery-1.3.2.min.js +19 -0
  213. data/site/src/scripts/jquery.cookie.js +96 -0
  214. data/tasks/stats.rake +155 -0
  215. data/tasks/yard.rake +171 -0
  216. data/test/dirstate_tests/dirstate +0 -0
  217. data/test/dirstate_tests/hgrc +5 -0
  218. data/test/dirstate_tests/test_dir_state.rb +192 -0
  219. data/test/functional_tests/resources/.hgignore +2 -0
  220. data/test/functional_tests/resources/STYLE.txt +25 -0
  221. data/test/functional_tests/resources/command.rb +372 -0
  222. data/test/functional_tests/resources/commands/annotate.rb +57 -0
  223. data/test/functional_tests/resources/commands/experimental/lolcats.rb +17 -0
  224. data/test/functional_tests/resources/commands/heads.rb +22 -0
  225. data/test/functional_tests/resources/commands/manifest.rb +12 -0
  226. data/test/functional_tests/resources/commands/status.rb +90 -0
  227. data/test/functional_tests/resources/version2/.hgignore +5 -0
  228. data/test/functional_tests/resources/version2/STYLE.txt +25 -0
  229. data/test/functional_tests/resources/version2/command.rb +372 -0
  230. data/test/functional_tests/resources/version2/commands/annotate.rb +45 -0
  231. data/test/functional_tests/resources/version2/commands/experimental/lolcats.rb +17 -0
  232. data/test/functional_tests/resources/version2/commands/heads.rb +22 -0
  233. data/test/functional_tests/resources/version2/commands/manifest.rb +12 -0
  234. data/test/functional_tests/resources/version2/commands/status.rb +90 -0
  235. data/test/functional_tests/resources/version3/.hgignore +5 -0
  236. data/test/functional_tests/resources/version3/STYLE.txt +31 -0
  237. data/test/functional_tests/resources/version3/command.rb +376 -0
  238. data/test/functional_tests/resources/version3/commands/annotate.rb +45 -0
  239. data/test/functional_tests/resources/version3/commands/experimental/lolcats.rb +17 -0
  240. data/test/functional_tests/resources/version3/commands/heads.rb +22 -0
  241. data/test/functional_tests/resources/version3/commands/manifest.rb +12 -0
  242. data/test/functional_tests/resources/version3/commands/status.rb +90 -0
  243. data/test/functional_tests/resources/version4/.hgignore +5 -0
  244. data/test/functional_tests/resources/version4/STYLE.txt +31 -0
  245. data/test/functional_tests/resources/version4/command.rb +376 -0
  246. data/test/functional_tests/resources/version4/commands/experimental/lolcats.rb +17 -0
  247. data/test/functional_tests/resources/version4/commands/heads.rb +22 -0
  248. data/test/functional_tests/resources/version4/commands/manifest.rb +12 -0
  249. data/test/functional_tests/resources/version4/commands/stats.rb +25 -0
  250. data/test/functional_tests/resources/version4/commands/status.rb +90 -0
  251. data/test/functional_tests/resources/version5_1/.hgignore +5 -0
  252. data/test/functional_tests/resources/version5_1/STYLE.txt +2 -0
  253. data/test/functional_tests/resources/version5_1/command.rb +374 -0
  254. data/test/functional_tests/resources/version5_1/commands/experimental/lolcats.rb +17 -0
  255. data/test/functional_tests/resources/version5_1/commands/heads.rb +22 -0
  256. data/test/functional_tests/resources/version5_1/commands/manifest.rb +12 -0
  257. data/test/functional_tests/resources/version5_1/commands/stats.rb +25 -0
  258. data/test/functional_tests/resources/version5_1/commands/status.rb +90 -0
  259. data/test/functional_tests/resources/version5_2/.hgignore +5 -0
  260. data/test/functional_tests/resources/version5_2/STYLE.txt +14 -0
  261. data/test/functional_tests/resources/version5_2/command.rb +376 -0
  262. data/test/functional_tests/resources/version5_2/commands/experimental/lolcats.rb +17 -0
  263. data/test/functional_tests/resources/version5_2/commands/manifest.rb +12 -0
  264. data/test/functional_tests/resources/version5_2/commands/newz.rb +12 -0
  265. data/test/functional_tests/resources/version5_2/commands/stats.rb +25 -0
  266. data/test/functional_tests/resources/version5_2/commands/status.rb +90 -0
  267. data/test/functional_tests/test_functional.rb +604 -0
  268. data/test/localrepo_tests/test_local_repo.rb +121 -0
  269. data/test/localrepo_tests/testrepo.tar.gz +0 -0
  270. data/test/manifest_tests/00manifest.i +0 -0
  271. data/test/manifest_tests/test_manifest.rb +72 -0
  272. data/test/merge_tests/base.txt +10 -0
  273. data/test/merge_tests/expected.local.txt +16 -0
  274. data/test/merge_tests/local.txt +11 -0
  275. data/test/merge_tests/remote.txt +11 -0
  276. data/test/merge_tests/test_merge.rb +26 -0
  277. data/test/revlog_tests/00changelog.i +0 -0
  278. data/test/revlog_tests/revision_added_changelog.i +0 -0
  279. data/test/revlog_tests/test_adding_index.i +0 -0
  280. data/test/revlog_tests/test_revlog.rb +333 -0
  281. data/test/revlog_tests/testindex.i +0 -0
  282. data/test/store_tests/store.tar.gz +0 -0
  283. data/test/store_tests/test_fncache_store.rb +122 -0
  284. data/test/test_amp.rb +9 -0
  285. data/test/test_base85.rb +14 -0
  286. data/test/test_bdiff.rb +42 -0
  287. data/test/test_commands.rb +122 -0
  288. data/test/test_difflib.rb +50 -0
  289. data/test/test_helper.rb +15 -0
  290. data/test/test_journal.rb +29 -0
  291. data/test/test_match.rb +134 -0
  292. data/test/test_mdiff.rb +74 -0
  293. data/test/test_mpatch.rb +14 -0
  294. data/test/test_support.rb +24 -0
  295. metadata +385 -0
@@ -0,0 +1,175 @@
1
+ !lightblue = #ddddff
2
+ !medblue = #bbbbff
3
+ !darkblue = #aaaaff
4
+ =pushleft
5
+ :position relative
6
+ :float left
7
+ :clear left
8
+ body
9
+ :font-family "Lucida Grande"
10
+ :line-height 1.1em
11
+ :font-size 80%
12
+ a
13
+ :text-decoration none
14
+ :color #3333dd
15
+ &:hover
16
+ :text-decoration underline
17
+ #main_container
18
+ :position relative
19
+
20
+ h2.header
21
+ +pushleft
22
+ #navbar
23
+ :position absolute
24
+ :top 10px
25
+ :left 10px
26
+ :background-color #ddd
27
+ :width 140px
28
+ ul
29
+ :padding 0
30
+ :text-align left
31
+ :font-size 12px
32
+ :font-family "Lucida Grande"
33
+ li
34
+ :padding 6px
35
+ :background-color #ddd
36
+ :border none
37
+ a
38
+ :text-decoration none
39
+ :color black
40
+ li:hover, li.selected
41
+ :background-color #f8f8f8
42
+ :border-left solid 2px #444
43
+ :padding-left 4px
44
+ #navbar ul, #navbar li
45
+ :list-style-type none
46
+ :margin 0
47
+ #main
48
+ :padding-left 160px
49
+ .shortlog
50
+ +pushleft
51
+ tr
52
+ :background-color #DDFFE3
53
+ :border-bottom solid 1px #555
54
+ :padding 3px 0
55
+ :width 100%
56
+ :float left
57
+ &:hover, &.selected
58
+ :background-color #bbddc3
59
+ .index
60
+ :width 35px
61
+ .user
62
+ :width 150px
63
+ .date
64
+ :width 150px
65
+ .description a
66
+ :text-decoration none
67
+ &:hover
68
+ :text-decoration underline
69
+ .pagebutton
70
+ +pushleft
71
+ :background-color = !lightblue
72
+ :padding 3px
73
+ :margin 2px
74
+ :text-decoration none
75
+ :color black
76
+ &:hover
77
+ :background-color = !medblue
78
+ :padding 2px
79
+ :border solid 1px = !darkblue
80
+ .browser-list
81
+ +pushleft
82
+ tr
83
+ :background-color #DDFFE3
84
+ :border-bottom solid 1px #555
85
+ :padding 3px 0
86
+ :width 100%
87
+ :float left
88
+ &:hover, &.selected
89
+ :background-color #bbddc3
90
+ .filename
91
+ :width 200px
92
+ a
93
+ :color = #3333cc
94
+ :text-decoration none
95
+ .date
96
+ :width 25%
97
+ .message
98
+ :width 50%
99
+ .browser-file
100
+ +pushleft
101
+ :width 100%
102
+ .source-holder
103
+ :position relative
104
+ :float left
105
+ :clear left
106
+ :background-color #eee
107
+ :border solid 1px #ddd
108
+ :width 90%
109
+ :padding 15px
110
+ :overflow-x auto
111
+ pre
112
+ +pushleft
113
+ :font-size 14px
114
+ :line-height 1.1em
115
+ :width 100%
116
+ :overflow-x auto
117
+ ul.versions
118
+ +pushleft
119
+ :width 800px
120
+ :list-style-type none
121
+ li
122
+ :position relative
123
+ :float left
124
+ :clear none
125
+ :width 120px
126
+ :text-align center
127
+ :padding-top 2px
128
+ :margin 1px
129
+ :height 20px
130
+ :font-size 12px
131
+ :list-style-type none
132
+ :background-color = !medblue
133
+ a
134
+ :color black
135
+ :text-decoration none
136
+ &:hover
137
+ :background-color = !lightblue
138
+ :border = solid 1px !darkblue
139
+ :width 118px
140
+ :height 19px
141
+ :padding-top 1px
142
+ .changeset-desc
143
+ +pushleft
144
+ blockquote
145
+ +pushleft
146
+ :border-left solid 2px #444
147
+ :margin 1em 0 1em 0
148
+ :padding 0px 0px 0px 8px
149
+ .two-column
150
+ +pushleft
151
+ td.label
152
+ :text-align right
153
+ :color #999
154
+ td.data
155
+ :text-align left
156
+ :color #222
157
+ .diff-list
158
+ +pushleft
159
+ :width 100%
160
+ &>li
161
+ :list-style-type none
162
+ .diff
163
+ :width 90%
164
+ :overflow-x auto
165
+ .diff, .diff li, pre
166
+ :list-style-type none
167
+ :margin 0
168
+ :padding 1px 0px
169
+ :size 12px
170
+ .diff-add
171
+ :background-color #aaffaa
172
+ .diff-del
173
+ :background-color #ffaaaa
174
+ .diff-ctx
175
+ :background-color #aaaaaa
@@ -0,0 +1,140 @@
1
+ require 'rubygems'
2
+ require 'sinatra/base'
3
+ require 'rack/deflater'
4
+ need { 'extension/amp_extension' }
5
+ need { 'extension/authorization' }
6
+
7
+ module Amp
8
+ module Servers
9
+ ##
10
+ # = HTTPServer
11
+ # General HTTP Server that serves up a Mercurial repository under the
12
+ # Mercurial HTTP protocol. Any mercurial client (including Amp) can use
13
+ # this server for push/pull operations, clones, and so on.
14
+ # Note: this server only provides methods for dealing with Mercurial clients.
15
+ # It is not a full-blown web server with a web interface to the repository.
16
+ #
17
+ # It is worth noting that one may serve many repositories using one server
18
+ # using this class. Spiffy, eh?
19
+ class HTTPServer < Sinatra::Base
20
+ register Sinatra::AmpExtension
21
+ helpers Sinatra::AmpRepoMethods
22
+ end
23
+
24
+ ##
25
+ # = HTTPAuthorizedServer
26
+ # General HTTP Server that has some form of authentication. Implements
27
+ # user-logic methods, as every subclass will have the same interface
28
+ # for adding/removing users. Note: this server only provides methods
29
+ # for dealing with Mercurial clients. It is not a full-blown web server
30
+ # with a web interface to the repository. The users you add to an
31
+ # HTTPAuthorizedServer are the credentials a user must provide when pushing
32
+ # to a repository (for example), or checking out a private repository.
33
+ #
34
+ # It is worth noting that one may serve many repositories using one server
35
+ # using this class. Spiffy, eh?
36
+ class HTTPAuthorizedServer < HTTPServer
37
+
38
+ def self.set_storage(manner, opts={})
39
+ manner = manner.to_sym
40
+
41
+ case manner
42
+ when :sequel
43
+ set :user_db_name, (opts[:user_db_name] || "users")
44
+ extend RepoUserManagement::SequelSQLite3
45
+ when :memory
46
+ extend RepoUserManagement::Memory
47
+ else
48
+ raise "Unknown storage manner #{manner.inspect}"
49
+ end
50
+
51
+ # since you can only set the storage once...
52
+ def self.set_storage(*args); end # this will redefine this method to do nothing
53
+ end
54
+
55
+ def self.set_permission(style, *args)
56
+ case style
57
+ when :writer
58
+ set_writer *args
59
+ when :reader
60
+ set_reader *args
61
+ else
62
+ raise ArgumentError.new("Unknown permission level: #{style.to_s.inspect}")
63
+ end
64
+ end
65
+
66
+ ##
67
+ # Sets whether to use digest or basic authentication. May only be called once,
68
+ # for now.
69
+ #
70
+ # @param [Symbol, String] manner the type of authentication
71
+ def self.set_authentication(manner, opts={})
72
+ case manner.to_sym
73
+ when :basic
74
+ helpers Sinatra::BasicAuthorization
75
+ when :digest
76
+ helpers Sinatra::DigestAuthorization
77
+ end
78
+ def self.set_authentication; end
79
+ end
80
+
81
+ set :authorization_realm, "Amp Repository"
82
+
83
+ def repos; self.class.repos; end
84
+ def users; self.class.users; end
85
+
86
+ ##
87
+ # This block is run on every single request, before the server code for the request is processed.
88
+ before do
89
+ cmd = params["cmd"]
90
+ repo = self.class.amp_repositories[request.path_info]
91
+
92
+ if cmd.nil? or cmd.empty? or !repos[repo] or !repos[repo][:private] && command_reads?(cmd)
93
+ true
94
+ else
95
+ login_required
96
+ end
97
+ end
98
+
99
+ ##
100
+ # General helper methods for the server
101
+ helpers do
102
+ ##
103
+ # Is the repository URL private? The URL is expected to be good.
104
+ #
105
+ # @param [String] repo the URL to the repository. Expected to be correct
106
+ def repo_is_private?(repo)
107
+ repos[repo][:private]
108
+ end
109
+
110
+ ##
111
+ # Is the repository URL public?
112
+ #
113
+ # @param [String] repo the URL to the repository. Expected to be correct
114
+ def repo_is_public?(repo)
115
+ !repo_is_private?(repo)
116
+ end
117
+
118
+ ##
119
+ # Pay attention kids -- this returns a HASH!!!!!!!!
120
+ # This is a hash of :user, :read, and :write
121
+ #
122
+ # @param [String] repo path to the repo on the web
123
+ # @param [String] username the dude we're looking for
124
+ # @return [{:user => Amp::Servers::User, :read => Boolean, :write => Boolean}]
125
+ def get_user_and_permissions(repo, username)
126
+ if u = repos[repo][:users][username]
127
+ return u
128
+ end
129
+
130
+ {:user => User.public_user,
131
+ :read => (repos[repo][:private] ? false : true),
132
+ :write => false
133
+ }
134
+ end
135
+ end
136
+ end
137
+
138
+ end
139
+ end
140
+
@@ -0,0 +1,287 @@
1
+ ##
2
+ # == RepoUserManagement
3
+ # This module manages the repository-user relationships that occur.
4
+ # Information is stored in memory.
5
+ module Amp
6
+ module Servers
7
+ module RepoUserManagement
8
+ module Memory
9
+
10
+ ##
11
+ # All the repositories stored in a hash.
12
+ # @example repos['monkey'] = {:users => {String => {:user => Amp::Servers::User,
13
+ # :read => Boolean, :write => Boolean}},
14
+ # :private => Boolean}
15
+ def repos; @repos ||= {}; @repos.default = {}; @repos; end
16
+
17
+ def users; @users ||= {}; end
18
+
19
+ ##
20
+ # Adds a user to the system. This is not repository specific.
21
+ #
22
+ # @param [Hash] user_info The user data, in hash form. Passed to {User.from_hash}
23
+ # @option user_info [String] :username The username for the user
24
+ # @option user_info [String] :password The cleartext (unencrypted) password.
25
+ def add_user(user_info={})
26
+ new_user = User.from_hash user_info
27
+ users[new_user.username] = new_user # universal list of users
28
+ end
29
+ alias_method :<<, :add_user
30
+
31
+
32
+ ##
33
+ # Adds a given username/password combination to the system, for a given
34
+ # repository, with write privileges.
35
+ #
36
+ # @param [Repository] repository The repository to which are associating the user
37
+ # @param [Amp::Servers::User] user The user to give write priveleges to
38
+ def set_writer(repository, user)
39
+ repos[repository] ||= {:users => {}, :private => false}
40
+ repos[repository][:users][user.username] ||= {:user => user, :read => true, :write => true}
41
+ repos[repository][:users][user.username][:read] = true # these are unnecessary if we are adding a user
42
+ repos[repository][:users][user.username][:write] = true
43
+ end
44
+
45
+ ##
46
+ # Adds a given username/password combination to the system, for a given
47
+ # repository, with read-only privileges. This will override any other settings
48
+ # previously set. For example, a call to #set_writer and then #set_reader would
49
+ # be as though #set_writer never happened.
50
+ #
51
+ # @param [Repository] repository The repository to which are associating the user
52
+ # @param [Amp::Servers::User] user The user to give write priveleges to
53
+ def set_reader(repository, user)
54
+ repos[repository] ||= {:users => {}, :private => false}
55
+ repos[repository][:users][user.username] ||= {:user => user, :read => true, :write => false}
56
+ repos[repository][:users][user.username][:read] = true
57
+ repos[repository][:users][user.username][:write] = false
58
+ end
59
+
60
+ ##
61
+ # Sets the given repository's privacy levels. Repositories default to being
62
+ # public, and must be set to be private using this method. This method can also
63
+ # be used to later make a private repository public without stopping the server.
64
+ #
65
+ # @param [Repository] repository The repository for which to set privacy settings
66
+ # @param [Boolean] _private (true) whether the repository should be private or not
67
+ def set_private(repository, _private=true)
68
+ repos[repository][:private] = !!_private
69
+ end
70
+
71
+ end
72
+
73
+ module Sequel
74
+
75
+ def self.extended(klass)
76
+ require 'sequel'
77
+
78
+ # Set up the database
79
+ # Oh gods please have mercy on my soul
80
+ const_set 'DB', Sequel.sqlite("amp_serve_#{klass.user_db_name}.db")
81
+
82
+ DB.create_table :users do
83
+ primary_key :id
84
+ String :username, :unique => true, :null => false
85
+ String :password, :null => false
86
+ end
87
+
88
+ DB.create_table :repos do
89
+ primary_key :id
90
+ String :url, :unique => true, :null => false
91
+ String :path, :null => false
92
+ boolean :private, :default => false
93
+ end
94
+
95
+ DB.create_table :permissions do
96
+ foreign_key :repo_id, :repos
97
+ foreign_key :user_id, :users
98
+ boolean :read
99
+ boolean :write
100
+ end
101
+
102
+ # find room in your heart to forgive me
103
+ # constants can't be assigned to in a method
104
+ const_set 'USERS', DB[:users]
105
+ const_set 'REPOS', DB[:repos]
106
+ const_set 'PERMS', DB[:permissions]
107
+ end
108
+
109
+ ##
110
+ # All the repositories stored in a hash.
111
+ #
112
+ # @todo slow as fuck
113
+ # @example repos['monkey'] = {:users => {String => {:user => Amp::Servers::User,
114
+ # :read => Boolean, :write => Boolean}},
115
+ # :private => Boolean}
116
+ def repos
117
+ REPOS.inject({}) do |h, v|
118
+ uss = PERMS[:repo_id => v[:id]]
119
+ q = uss.map do |p|
120
+ {:user => USERS[:user_id => p[:user_id]],
121
+ :read => p[:read], :write => p[:write] }
122
+ end
123
+ z = q.inject({}) {|h, v| h.merge v[:user][:username] => v }
124
+
125
+ h.merge v[:url] => {:users => z, :private => v[:private]}
126
+ end
127
+ end
128
+
129
+ def users
130
+ USERS.inject({}) do |s, v|
131
+ s.merge v[:username] => v
132
+ end
133
+ end
134
+
135
+ ##
136
+ # Adds a user to the system. This is not repository specific.
137
+ #
138
+ # @param [Hash] user_info The user data, in hash form. Passed to {User.from_hash}
139
+ # @option user_info [String] :username The username for the user
140
+ # @option user_info [String] :password The cleartext (unencrypted) password.
141
+ def add_user(user_info={})
142
+ USERS << user_info
143
+ end
144
+ alias_method :<<, :add_user
145
+
146
+ ##
147
+ # Adds a given username/password combination to the system, for a given
148
+ # repository, with write privileges.
149
+ #
150
+ # @todo don't know if this actually works
151
+ # @param [Repository] repository The repository to which are associating the user
152
+ # @param [Amp::Servers::User] user The user to give write priveleges to
153
+ def set_writer(repository, user)
154
+ perm = PERMS.filter 'repo_id = ? and user_id = ?', REPOS.first(:url => repository).id, user[:id]
155
+ perm.update :read => true
156
+ perm.update :write => true
157
+ end
158
+
159
+ ##
160
+ # Adds a given username/password combination to the system, for a given
161
+ # repository, with read-only privileges. This will override any other settings
162
+ # previously set. For example, a call to #set_writer and then #set_reader would
163
+ # be as though #set_writer never happened.
164
+ #
165
+ # @todo don't know if this actually works
166
+ # @param [Repository] repository The repository to which are associating the user
167
+ # @param [Amp::Servers::User] user The user to give write priveleges to
168
+ def set_reader(repository, user)
169
+ perm = PERMS.filter 'repo_id = ? and user_id = ?', REPOS.first(:url => repository).id, user[:id]
170
+ perm.update :read => true
171
+ perm.update :write => false
172
+ end
173
+
174
+ ##
175
+ # Sets the given repository's privacy levels. Repositories default to being
176
+ # public, and must be set to be private using this method. This method can also
177
+ # be used to later make a private repository public without stopping the server.
178
+ #
179
+ # @todo don't know if this actually works
180
+ # @param [Repository] repository The repository for which to set privacy settings
181
+ # @param [Boolean] _private (true) whether the repository should be private or not
182
+ def set_private(repository, _private=true)
183
+ REPOS[:url => repository] = {:private => true}
184
+ end
185
+
186
+ end
187
+
188
+ module DataMapper
189
+
190
+ def self.extended(klass)
191
+ require 'dm-core'
192
+
193
+ users = Class.new do
194
+ include DataMapper::Resource
195
+ property :username, String
196
+ property :password, String
197
+
198
+ has n, :perms
199
+ end
200
+ const_set 'User', users
201
+
202
+ perms = Class.new do
203
+ include DataMapper::Resource
204
+ property :read
205
+ property :write
206
+
207
+ belongs_to :user
208
+ belongs_to :repo
209
+ end
210
+ const_set 'Perm', perms
211
+
212
+ repo = Class.new do
213
+ include DataMapper::Resource
214
+ property :url, String
215
+ property :path, String
216
+
217
+ has n, :perms
218
+ end
219
+ const_set 'Repo', repo
220
+ end
221
+
222
+ ##
223
+ # All the repositories stored in a hash.
224
+ #
225
+ # @todo slow as fuck
226
+ # @example repos['monkey'] = {:users => {String => {:user => Amp::Servers::User,
227
+ # :read => Boolean, :write => Boolean}},
228
+ # :private => Boolean}
229
+ def repos
230
+
231
+ end
232
+
233
+ def users
234
+
235
+ end
236
+
237
+ ##
238
+ # Adds a user to the system. This is not repository specific.
239
+ #
240
+ # @param [Hash] user_info The user data, in hash form. Passed to {User.from_hash}
241
+ # @option user_info [String] :username The username for the user
242
+ # @option user_info [String] :password The cleartext (unencrypted) password.
243
+ def add_user(user_info={})
244
+
245
+ end
246
+ alias_method :<<, :add_user
247
+
248
+ ##
249
+ # Adds a given username/password combination to the system, for a given
250
+ # repository, with write privileges.
251
+ #
252
+ # @todo don't know if this actually works
253
+ # @param [Repository] repository The repository to which are associating the user
254
+ # @param [Amp::Servers::User] user The user to give write priveleges to
255
+ def set_writer(repository, user)
256
+
257
+ end
258
+
259
+ ##
260
+ # Adds a given username/password combination to the system, for a given
261
+ # repository, with read-only privileges. This will override any other settings
262
+ # previously set. For example, a call to #set_writer and then #set_reader would
263
+ # be as though #set_writer never happened.
264
+ #
265
+ # @todo don't know if this actually works
266
+ # @param [Repository] repository The repository to which are associating the user
267
+ # @param [Amp::Servers::User] user The user to give write priveleges to
268
+ def set_reader(repository, user)
269
+
270
+ end
271
+
272
+ ##
273
+ # Sets the given repository's privacy levels. Repositories default to being
274
+ # public, and must be set to be private using this method. This method can also
275
+ # be used to later make a private repository public without stopping the server.
276
+ #
277
+ # @todo don't know if this actually works
278
+ # @param [Repository] repository The repository for which to set privacy settings
279
+ # @param [Boolean] _private (true) whether the repository should be private or not
280
+ def set_private(repository, _private=true)
281
+
282
+ end
283
+
284
+ end
285
+ end
286
+ end
287
+ end