amp 0.5.2 → 0.5.3

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 (232) hide show
  1. data/.gitignore +12 -0
  2. data/.hgignore +3 -0
  3. data/AUTHORS +1 -1
  4. data/Manifest.txt +99 -38
  5. data/README.md +3 -3
  6. data/Rakefile +53 -18
  7. data/SCHEDULE.markdown +5 -1
  8. data/TODO.markdown +120 -149
  9. data/ampfile.rb +3 -1
  10. data/bin/amp +4 -1
  11. data/ext/amp/bz2/extconf.rb +1 -1
  12. data/ext/amp/mercurial_patch/extconf.rb +1 -1
  13. data/ext/amp/mercurial_patch/mpatch.c +4 -3
  14. data/ext/amp/priority_queue/extconf.rb +1 -1
  15. data/ext/amp/support/extconf.rb +1 -1
  16. data/ext/amp/support/support.c +1 -1
  17. data/lib/amp.rb +125 -67
  18. data/lib/amp/commands/command.rb +12 -10
  19. data/lib/amp/commands/command_support.rb +8 -1
  20. data/lib/amp/commands/commands/help.rb +2 -20
  21. data/lib/amp/commands/commands/init.rb +14 -2
  22. data/lib/amp/commands/commands/templates.rb +6 -4
  23. data/lib/amp/commands/commands/version.rb +15 -1
  24. data/lib/amp/commands/commands/workflow.rb +3 -3
  25. data/lib/amp/commands/commands/workflows/git/add.rb +3 -3
  26. data/lib/amp/commands/commands/workflows/git/copy.rb +1 -1
  27. data/lib/amp/commands/commands/workflows/git/rm.rb +4 -2
  28. data/lib/amp/commands/commands/workflows/hg/add.rb +1 -1
  29. data/lib/amp/commands/commands/workflows/hg/addremove.rb +2 -2
  30. data/lib/amp/commands/commands/workflows/hg/annotate.rb +8 -2
  31. data/lib/amp/commands/commands/workflows/hg/bisect.rb +253 -0
  32. data/lib/amp/commands/commands/workflows/hg/branch.rb +1 -1
  33. data/lib/amp/commands/commands/workflows/hg/branches.rb +3 -3
  34. data/lib/amp/commands/commands/workflows/hg/bundle.rb +3 -3
  35. data/lib/amp/commands/commands/workflows/hg/clone.rb +4 -5
  36. data/lib/amp/commands/commands/workflows/hg/commit.rb +37 -1
  37. data/lib/amp/commands/commands/workflows/hg/copy.rb +2 -1
  38. data/lib/amp/commands/commands/workflows/hg/debug/index.rb +1 -1
  39. data/lib/amp/commands/commands/workflows/hg/diff.rb +3 -8
  40. data/lib/amp/commands/commands/workflows/hg/forget.rb +5 -4
  41. data/lib/amp/commands/commands/workflows/hg/identify.rb +6 -6
  42. data/lib/amp/commands/commands/workflows/hg/import.rb +1 -1
  43. data/lib/amp/commands/commands/workflows/hg/incoming.rb +2 -2
  44. data/lib/amp/commands/commands/workflows/hg/log.rb +5 -4
  45. data/lib/amp/commands/commands/workflows/hg/merge.rb +1 -1
  46. data/lib/amp/commands/commands/workflows/hg/move.rb +5 -3
  47. data/lib/amp/commands/commands/workflows/hg/outgoing.rb +1 -1
  48. data/lib/amp/commands/commands/workflows/hg/push.rb +6 -7
  49. data/lib/amp/commands/commands/workflows/hg/remove.rb +2 -2
  50. data/lib/amp/commands/commands/workflows/hg/resolve.rb +6 -23
  51. data/lib/amp/commands/commands/workflows/hg/root.rb +1 -2
  52. data/lib/amp/commands/commands/workflows/hg/status.rb +21 -12
  53. data/lib/amp/commands/commands/workflows/hg/tag.rb +2 -2
  54. data/lib/amp/commands/commands/workflows/hg/untrack.rb +12 -0
  55. data/lib/amp/commands/commands/workflows/hg/verify.rb +13 -3
  56. data/lib/amp/commands/commands/workflows/hg/what_changed.rb +18 -0
  57. data/lib/amp/commands/dispatch.rb +12 -13
  58. data/lib/amp/dependencies/amp_support.rb +1 -1
  59. data/lib/amp/dependencies/amp_support/ruby_amp_support.rb +1 -0
  60. data/lib/amp/dependencies/maruku.rb +136 -0
  61. data/lib/amp/dependencies/maruku/attributes.rb +227 -0
  62. data/lib/amp/dependencies/maruku/defaults.rb +71 -0
  63. data/lib/amp/dependencies/maruku/errors_management.rb +92 -0
  64. data/lib/amp/dependencies/maruku/helpers.rb +260 -0
  65. data/lib/amp/dependencies/maruku/input/charsource.rb +326 -0
  66. data/lib/amp/dependencies/maruku/input/extensions.rb +69 -0
  67. data/lib/amp/dependencies/maruku/input/html_helper.rb +189 -0
  68. data/lib/amp/dependencies/maruku/input/linesource.rb +111 -0
  69. data/lib/amp/dependencies/maruku/input/parse_block.rb +615 -0
  70. data/lib/amp/dependencies/maruku/input/parse_doc.rb +234 -0
  71. data/lib/amp/dependencies/maruku/input/parse_span_better.rb +746 -0
  72. data/lib/amp/dependencies/maruku/input/rubypants.rb +225 -0
  73. data/lib/amp/dependencies/maruku/input/type_detection.rb +147 -0
  74. data/lib/amp/dependencies/maruku/input_textile2/t2_parser.rb +163 -0
  75. data/lib/amp/dependencies/maruku/maruku.rb +33 -0
  76. data/lib/amp/dependencies/maruku/output/to_ansi.rb +223 -0
  77. data/lib/amp/dependencies/maruku/output/to_html.rb +991 -0
  78. data/lib/amp/dependencies/maruku/output/to_markdown.rb +164 -0
  79. data/lib/amp/dependencies/maruku/output/to_s.rb +56 -0
  80. data/lib/amp/dependencies/maruku/string_utils.rb +191 -0
  81. data/lib/amp/dependencies/maruku/structures.rb +167 -0
  82. data/lib/amp/dependencies/maruku/structures_inspect.rb +87 -0
  83. data/lib/amp/dependencies/maruku/structures_iterators.rb +61 -0
  84. data/lib/amp/dependencies/maruku/textile2.rb +1 -0
  85. data/lib/amp/dependencies/maruku/toc.rb +199 -0
  86. data/lib/amp/dependencies/maruku/usage/example1.rb +33 -0
  87. data/lib/amp/dependencies/maruku/version.rb +40 -0
  88. data/lib/amp/dependencies/priority_queue.rb +2 -1
  89. data/lib/amp/dependencies/python_config.rb +2 -1
  90. data/lib/amp/graphs/ancestor.rb +2 -1
  91. data/lib/amp/graphs/copies.rb +236 -233
  92. data/lib/amp/help/entries/__default__.erb +31 -0
  93. data/lib/amp/help/entries/commands.erb +6 -0
  94. data/lib/amp/help/entries/mdtest.md +35 -0
  95. data/lib/amp/help/entries/silly +3 -0
  96. data/lib/amp/help/help.rb +288 -0
  97. data/lib/amp/profiling_hacks.rb +5 -3
  98. data/lib/amp/repository/abstract/abstract_changeset.rb +97 -0
  99. data/lib/amp/repository/abstract/abstract_local_repo.rb +181 -0
  100. data/lib/amp/repository/abstract/abstract_staging_area.rb +180 -0
  101. data/lib/amp/repository/abstract/abstract_versioned_file.rb +100 -0
  102. data/lib/amp/repository/abstract/common_methods/changeset.rb +75 -0
  103. data/lib/amp/repository/abstract/common_methods/local_repo.rb +277 -0
  104. data/lib/amp/repository/abstract/common_methods/staging_area.rb +233 -0
  105. data/lib/amp/repository/abstract/common_methods/versioned_file.rb +71 -0
  106. data/lib/amp/repository/generic_repo_picker.rb +78 -0
  107. data/lib/amp/repository/git/repo_format/changeset.rb +336 -0
  108. data/lib/amp/repository/git/repo_format/staging_area.rb +192 -0
  109. data/lib/amp/repository/git/repo_format/versioned_file.rb +119 -0
  110. data/lib/amp/repository/git/repositories/local_repository.rb +164 -0
  111. data/lib/amp/repository/git/repository.rb +41 -0
  112. data/lib/amp/repository/mercurial/encoding/mercurial_diff.rb +382 -0
  113. data/lib/amp/repository/mercurial/encoding/mercurial_patch.rb +1 -0
  114. data/lib/amp/repository/mercurial/encoding/patch.rb +294 -0
  115. data/lib/amp/repository/mercurial/encoding/pure_ruby/ruby_mercurial_patch.rb +124 -0
  116. data/lib/amp/repository/mercurial/merging/merge_ui.rb +327 -0
  117. data/lib/amp/repository/mercurial/merging/simple_merge.rb +452 -0
  118. data/lib/amp/repository/mercurial/repo_format/branch_manager.rb +266 -0
  119. data/lib/amp/repository/mercurial/repo_format/changeset.rb +768 -0
  120. data/lib/amp/repository/mercurial/repo_format/dir_state.rb +716 -0
  121. data/lib/amp/repository/mercurial/repo_format/journal.rb +218 -0
  122. data/lib/amp/repository/mercurial/repo_format/lock.rb +210 -0
  123. data/lib/amp/repository/mercurial/repo_format/merge_state.rb +228 -0
  124. data/lib/amp/repository/mercurial/repo_format/staging_area.rb +367 -0
  125. data/lib/amp/repository/mercurial/repo_format/store.rb +487 -0
  126. data/lib/amp/repository/mercurial/repo_format/tag_manager.rb +322 -0
  127. data/lib/amp/repository/mercurial/repo_format/updatable.rb +543 -0
  128. data/lib/amp/repository/mercurial/repo_format/updater.rb +848 -0
  129. data/lib/amp/repository/mercurial/repo_format/verification.rb +433 -0
  130. data/lib/amp/repository/mercurial/repositories/bundle_repository.rb +216 -0
  131. data/lib/amp/repository/mercurial/repositories/http_repository.rb +386 -0
  132. data/lib/amp/repository/mercurial/repositories/local_repository.rb +2034 -0
  133. data/lib/amp/repository/mercurial/repository.rb +119 -0
  134. data/lib/amp/repository/mercurial/revlogs/bundle_revlogs.rb +249 -0
  135. data/lib/amp/repository/mercurial/revlogs/changegroup.rb +217 -0
  136. data/lib/amp/repository/mercurial/revlogs/changelog.rb +339 -0
  137. data/lib/amp/repository/mercurial/revlogs/file_log.rb +152 -0
  138. data/lib/amp/repository/mercurial/revlogs/index.rb +500 -0
  139. data/lib/amp/repository/mercurial/revlogs/manifest.rb +201 -0
  140. data/lib/amp/repository/mercurial/revlogs/node.rb +20 -0
  141. data/lib/amp/repository/mercurial/revlogs/revlog.rb +1026 -0
  142. data/lib/amp/repository/mercurial/revlogs/revlog_support.rb +129 -0
  143. data/lib/amp/repository/mercurial/revlogs/versioned_file.rb +597 -0
  144. data/lib/amp/repository/repository.rb +11 -88
  145. data/lib/amp/server/extension/amp_extension.rb +3 -3
  146. data/lib/amp/server/fancy_http_server.rb +1 -1
  147. data/lib/amp/server/fancy_views/_browser.haml +1 -1
  148. data/lib/amp/server/fancy_views/_diff_file.haml +1 -8
  149. data/lib/amp/server/fancy_views/changeset.haml +2 -2
  150. data/lib/amp/server/fancy_views/file.haml +1 -1
  151. data/lib/amp/server/fancy_views/file_diff.haml +1 -1
  152. data/lib/amp/support/amp_ui.rb +13 -29
  153. data/lib/amp/support/generator.rb +1 -1
  154. data/lib/amp/support/loaders.rb +1 -2
  155. data/lib/amp/support/logger.rb +10 -16
  156. data/lib/amp/support/match.rb +18 -4
  157. data/lib/amp/support/mercurial/ignore.rb +151 -0
  158. data/lib/amp/support/openers.rb +8 -3
  159. data/lib/amp/support/support.rb +91 -46
  160. data/lib/amp/templates/{blank.commit.erb → mercurial/blank.commit.erb} +0 -0
  161. data/lib/amp/templates/{blank.log.erb → mercurial/blank.log.erb} +0 -0
  162. data/lib/amp/templates/{default.commit.erb → mercurial/default.commit.erb} +0 -0
  163. data/lib/amp/templates/{default.log.erb → mercurial/default.log.erb} +0 -0
  164. data/lib/amp/templates/template.rb +18 -18
  165. data/man/amp.1 +51 -0
  166. data/site/src/about/commands.haml +1 -1
  167. data/site/src/css/amp.css +1 -1
  168. data/site/src/index.haml +3 -3
  169. data/tasks/man.rake +39 -0
  170. data/tasks/stats.rake +1 -10
  171. data/tasks/yard.rake +1 -50
  172. data/test/dirstate_tests/test_dir_state.rb +10 -8
  173. data/test/functional_tests/annotate.out +31 -0
  174. data/test/functional_tests/test_functional.rb +155 -63
  175. data/test/localrepo_tests/ampfile.rb +12 -0
  176. data/test/localrepo_tests/test_local_repo.rb +56 -57
  177. data/test/manifest_tests/test_manifest.rb +3 -5
  178. data/test/merge_tests/test_merge.rb +3 -3
  179. data/test/revlog_tests/test_revlog.rb +14 -6
  180. data/test/store_tests/test_fncache_store.rb +19 -19
  181. data/test/test_19_compatibility.rb +46 -0
  182. data/test/test_base85.rb +2 -2
  183. data/test/test_bdiff.rb +2 -2
  184. data/test/test_changegroup.rb +59 -0
  185. data/test/test_commands.rb +2 -2
  186. data/test/test_difflib.rb +2 -2
  187. data/test/test_generator.rb +34 -0
  188. data/test/test_ignore.rb +203 -0
  189. data/test/test_journal.rb +18 -13
  190. data/test/test_match.rb +2 -2
  191. data/test/test_mdiff.rb +3 -3
  192. data/test/test_mpatch.rb +3 -3
  193. data/test/test_multi_io.rb +40 -0
  194. data/test/test_support.rb +18 -2
  195. data/test/test_templates.rb +38 -0
  196. data/test/test_ui.rb +79 -0
  197. data/test/testutilities.rb +56 -0
  198. metadata +168 -49
  199. data/ext/amp/bz2/mkmf.log +0 -38
  200. data/lib/amp/encoding/mercurial_diff.rb +0 -378
  201. data/lib/amp/encoding/mercurial_patch.rb +0 -1
  202. data/lib/amp/encoding/patch.rb +0 -292
  203. data/lib/amp/encoding/pure_ruby/ruby_mercurial_patch.rb +0 -123
  204. data/lib/amp/merges/merge_state.rb +0 -164
  205. data/lib/amp/merges/merge_ui.rb +0 -322
  206. data/lib/amp/merges/simple_merge.rb +0 -450
  207. data/lib/amp/repository/branch_manager.rb +0 -234
  208. data/lib/amp/repository/dir_state.rb +0 -950
  209. data/lib/amp/repository/journal.rb +0 -203
  210. data/lib/amp/repository/lock.rb +0 -207
  211. data/lib/amp/repository/repositories/bundle_repository.rb +0 -214
  212. data/lib/amp/repository/repositories/http_repository.rb +0 -377
  213. data/lib/amp/repository/repositories/local_repository.rb +0 -2661
  214. data/lib/amp/repository/store.rb +0 -485
  215. data/lib/amp/repository/tag_manager.rb +0 -319
  216. data/lib/amp/repository/updatable.rb +0 -532
  217. data/lib/amp/repository/verification.rb +0 -431
  218. data/lib/amp/repository/versioned_file.rb +0 -475
  219. data/lib/amp/revlogs/bundle_revlogs.rb +0 -246
  220. data/lib/amp/revlogs/changegroup.rb +0 -217
  221. data/lib/amp/revlogs/changelog.rb +0 -338
  222. data/lib/amp/revlogs/changeset.rb +0 -521
  223. data/lib/amp/revlogs/file_log.rb +0 -165
  224. data/lib/amp/revlogs/index.rb +0 -493
  225. data/lib/amp/revlogs/manifest.rb +0 -195
  226. data/lib/amp/revlogs/node.rb +0 -18
  227. data/lib/amp/revlogs/revlog.rb +0 -1045
  228. data/lib/amp/revlogs/revlog_support.rb +0 -126
  229. data/lib/amp/support/ignore.rb +0 -144
  230. data/site/Rakefile +0 -38
  231. data/test/test_amp.rb +0 -9
  232. data/test/test_helper.rb +0 -15
@@ -0,0 +1,181 @@
1
+ module Amp
2
+ module Repositories
3
+ ##
4
+ # This class contains the functionality of all repositories ever.
5
+ # Methods here rely on certain base methods that are unimplemented,
6
+ # left as an exercise for the reader.
7
+
8
+ class AbstractLocalRepository
9
+ include CommonLocalRepoMethods
10
+
11
+ ##
12
+ # Returns the root of the repository (not the .hg/.git root)
13
+ #
14
+ # @return [String]
15
+ def root
16
+ raise NotImplementedError.new("root() must be implemented by subclasses of AbstractLocalRepository.")
17
+ end
18
+
19
+ ##
20
+ # Returns the staging area for the repository, which provides the ability to add/remove
21
+ # files in the next commit.
22
+ #
23
+ # @return [AbstractStagingArea]
24
+ def staging_area
25
+ raise NotImplementedError.new("staging_area() must be implemented by subclasses of AbstractLocalRepository.")
26
+ end
27
+
28
+ ##
29
+ # Has the file been modified from node1 to node2?
30
+ #
31
+ # @param [String] file the file to check
32
+ # @param [Hash] opts needs to have :node1 and :node2
33
+ # @return [Boolean] has the +file+ been modified?
34
+ def file_modified?(file, opts={})
35
+ raise NotImplementedError.new("file_modified?() must be implemented by subclasses of AbstractLocalRepository.")
36
+ end
37
+
38
+ ##
39
+ # Write +text+ to +filename+, where +filename+
40
+ # is local to the root.
41
+ #
42
+ # @param [String] filename The file as relative to the root
43
+ # @param [String] text The text to write to said file
44
+ def working_write(filename, text)
45
+ raise NotImplementedError.new("working_write() must be implemented by subclasses of AbstractLocalRepository.")
46
+ end
47
+
48
+ ##
49
+ # Commits a changeset or set of files to the repository. You will quite often
50
+ # use this method since it's basically the basis of version control systems.
51
+ #
52
+ # @api
53
+ # @param [Hash] opts the options to this method are all optional, so it's a very
54
+ # flexible method. Options listed below.
55
+ # @option opts [Array] :modified ([]) which files have been added or modified
56
+ # that you want to be added as a changeset.
57
+ # @option opts [Array] :removed ([]) which files should be removed in this
58
+ # commit?
59
+ # @option opts [Hash] :extra ({}) any extra data, such as "close" => true
60
+ # will close the active branch.
61
+ # @option opts [String] :message ("") the message for the commit. An editor
62
+ # will be opened if this is not provided.
63
+ # @option opts [Boolean] :force (false) Forces the commit, ignoring minor details
64
+ # like when you try to commit when no files have been changed.
65
+ # @option opts [Match] :match (nil) A match object to specify how to pick files
66
+ # to commit. These are useful so you don't accidentally commit ignored files,
67
+ # for example.
68
+ # @option opts [Array<String>] :parents (nil) the node IDs of the parents under
69
+ # which this changeset will be committed. No more than 2 for mercurial.
70
+ # @option opts [Boolean] :empty_ok (false) Is an empty commit message a-ok?
71
+ # @option opts [Boolean] :force_editor (false) Do we force the editor to be
72
+ # opened, even if :message is provided?
73
+ # @option opts [String] :user (ENV["HGUSER"]) the username to associate with the commit.
74
+ # Defaults to AmpConfig#username.
75
+ # @option opts [DateTime, Time, Date] :date (Time.now) the date to mark with
76
+ # the commit. Useful if you miss a deadline and want to pretend that you actually
77
+ # made it!
78
+ # @return [String] the digest referring to this entry in the changelog
79
+ def commit(opts={})
80
+ raise NotImplementedError.new("commit() must be implemented by subclasses of AbstractLocalRepository.")
81
+ end
82
+
83
+ ##
84
+ # Pushes changesets to a remote repository.
85
+ #
86
+ # @param [Repository] remote_repo the remote repository object to push to
87
+ # @param [Hash] options extra options for pushing
88
+ # @option options [Boolean] :force (false) Force pushing, even if it would create
89
+ # new heads (or some other error arises)
90
+ # @option options [Array<Fixnum, String>] :revs ([]) specify which revisions to push
91
+ # @return [Boolean] for success/failure
92
+ def push(remote_repo, options = {})
93
+ raise NotImplementedError.new("push() must be implemented by subclasses of AbstractLocalRepository.")
94
+ end
95
+
96
+ ##
97
+ # Pulls changesets from a remote repository
98
+ # Does *not* apply them to the working directory.
99
+ #
100
+ # @param [Repository] remote_repo the remote repository object to pull from
101
+ # @param [Hash] options extra options for pulling
102
+ # @option [Array<String, Fixnum>] :heads ([]) which repository heads to pull, such as
103
+ # a branch name or a sha-1 identifier
104
+ # @option [Boolean] :force (false) force the pull, ignoring any errors or warnings
105
+ # @return [Boolean] for success/failure
106
+ def pull(remote_repo, options = {})
107
+ raise NotImplementedError.new("pull() must be implemented by subclasses of AbstractLocalRepository.")
108
+ end
109
+
110
+ ##
111
+ # Returns a changeset for the given revision.
112
+ # Must support at least integer indexing as well as a string "node ID", if the repository
113
+ # system has such IDs. Also "tip" should return the tip of the revision tree.
114
+ #
115
+ # @return [AbstractChangeset]
116
+ def [](revision)
117
+ raise NotImplementedError.new("[]() must be implemented by subclasses of AbstractLocalRepository.")
118
+ end
119
+
120
+ ##
121
+ # Returns the number of changesets in the repository.
122
+ #
123
+ # @return [Fixnum]
124
+ def size
125
+ raise NotImplementedError.new("size() must be implemented by subclasses of AbstractLocalRepository.")
126
+ end
127
+
128
+ ##
129
+ # Gets a given file at the given revision, in the form of an AbstractVersionedFile object.
130
+ #
131
+ # @return [AbstractVersionedFile]
132
+ def get_file(file, revision)
133
+ raise NotImplementedError.new("get_file() must be implemented by subclasses of AbstractLocalRepository.")
134
+ end
135
+
136
+ ##
137
+ # In whatever conflict-resolution system your repository format defines, mark a given file
138
+ # as in conflict. If your format does not manage conflict resolution, re-define this method as
139
+ # a no-op.
140
+ #
141
+ # @return [Boolean]
142
+ def mark_conflicted(*filenames)
143
+ raise NotImplementedError.new("mark_conflicted() must be implemented by subclasses of AbstractLocalRepository.")
144
+ end
145
+
146
+ ##
147
+ # In whatever conflict-resolution system your repository format defines, mark a given file
148
+ # as no longer in conflict (resolved). If your format does not manage conflict resolution,
149
+ # re-define this method as a no-op.
150
+ #
151
+ # @return [Boolean]
152
+ def mark_resolved(*filenames)
153
+ raise NotImplementedError.new("mark_resolved() must be implemented by subclasses of AbstractLocalRepository.")
154
+ end
155
+
156
+ ##
157
+ # Attempts to resolve the given file, according to how mercurial manages
158
+ # merges. Needed for api compliance.
159
+ #
160
+ # @api
161
+ # @param [String] filename the file to attempt to resolve
162
+ def try_resolve_conflict
163
+ raise NotImplementedError.new("try_resolve_conflict() must be implemented by subclasses of AbstractLocalRepository.")
164
+ end
165
+
166
+ ##
167
+ # Returns all files that have not been merged. In other words, if we're
168
+ # waiting for the user to fix up their merge, then return the list of files
169
+ # we need to be correct before merging.
170
+ #
171
+ # @todo think up a better name
172
+ #
173
+ # @return [Array<Array<String, Symbol>>] an array of String-Symbol pairs - the
174
+ # filename is the first entry, the status of the merge is the second.
175
+ def uncommitted_merge_files
176
+ raise NotImplementedError.new("uncommitted_merge_files() must be implemented by subclasses of AbstractLocalRepository.")
177
+ end
178
+
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,180 @@
1
+ module Amp
2
+ module Repositories
3
+ class AbstractStagingArea
4
+ include CommonStagingAreaMethods
5
+
6
+ ##
7
+ # Marks a file to be added to the repository upon the next commit.
8
+ #
9
+ # @param [[String]] filenames a list of files to add in the next commit
10
+ # @return [Boolean] true for success, false for failure
11
+ def add(*filenames)
12
+ raise NotImplementedError.new("add() must be implemented by subclasses of AbstractStagingArea.")
13
+ end
14
+
15
+ ##
16
+ # Marks a file to be removed from the repository upon the next commit. Last argument
17
+ # can be a hash, which can take an :unlink key, specifying whether the files should actually
18
+ # be removed or not.
19
+ #
20
+ # @param [[String]] filenames a list of files to remove in the next commit
21
+ # @return [Boolean] true for success, false for failure
22
+ def remove(*filenames)
23
+ raise NotImplementedError.new("remove() must be implemented by subclasses of AbstractStagingArea.")
24
+ end
25
+
26
+ ##
27
+ # Set +file+ as normal and clean. Un-removes any files marked as removed, and
28
+ # un-adds any files marked as added.
29
+ #
30
+ # @param [Array<String>] files the name of the files to mark as normal
31
+ # @return [Boolean] success marker
32
+ def normal(*files)
33
+ raise NotImplementedError.new("normal() must be implemented by subclasses of AbstractStagingArea.")
34
+ end
35
+
36
+ ##
37
+ # Mark the files as untracked.
38
+ #
39
+ # @param [Array<String>] files the name of the files to mark as untracked
40
+ # @return [Boolean] success marker
41
+ def forget(*files)
42
+ raise NotImplementedError.new("forget() must be implemented by subclasses of AbstractStagingArea.")
43
+ end
44
+
45
+ ##
46
+ # Marks a file to be copied from the +from+ location to the +to+ location
47
+ # in the next commit, while retaining history.
48
+ #
49
+ # @param [String] from the source of the file copy
50
+ # @param [String] to the destination of the file copy
51
+ # @return [Boolean] true for success, false for failure
52
+ def copy(from, to)
53
+ raise NotImplementedError.new("copy() must be implemented by subclasses of AbstractStagingArea.")
54
+ end
55
+
56
+ ##
57
+ # Marks a file to be moved from the +from+ location to the +to+ location
58
+ # in the next commit, while retaining history.
59
+ #
60
+ # @param [String] from the source of the file move
61
+ # @param [String] to the destination of the file move
62
+ # @return [Boolean] true for success, false for failure
63
+ def move(from, to)
64
+ raise NotImplementedError.new("move() must be implemented by subclasses of AbstractStagingArea.")
65
+ end
66
+
67
+ ##
68
+ # Marks a modified file to be included in the next commit.
69
+ # If your VCS does this implicitly, this should be defined as a no-op.
70
+ #
71
+ # @param [[String]] filenames a list of files to include for committing
72
+ # @return [Boolean] true for success, false for failure
73
+ def include(*filenames)
74
+ raise NotImplementedError.new("include() must be implemented by subclasses of AbstractStagingArea.")
75
+ end
76
+ alias_method :stage, :include
77
+
78
+ ##
79
+ # Mark a modified file to not be included in the next commit.
80
+ # If your VCS does not include this idea because staging a file is implicit, this should
81
+ # be defined as a no-op.
82
+ #
83
+ # @param [[String]] filenames a list of files to remove from the staging area for committing
84
+ # @return [Boolean] true for success, false for failure
85
+ def exclude(*filenames)
86
+ raise NotImplementedError.new("exclude() must be implemented by subclasses of AbstractStagingArea.")
87
+ end
88
+ alias_method :unstage, :exclude
89
+
90
+ ##
91
+ # Returns a Symbol.
92
+ # Possible results:
93
+ # :added (subset of :included)
94
+ # :removed
95
+ # :untracked
96
+ # :included
97
+ # :normal
98
+ #
99
+ def file_status(filename)
100
+ raise NotImplementedError.new("file_status() must be implemented by subclasses of AbstractStagingArea.")
101
+ end
102
+
103
+ ##
104
+ # The directory used by the VCS to store magical information (.hg, .git, etc.).
105
+ #
106
+ # @api
107
+ # @return [String] relative to root
108
+ def vcs_dir
109
+ raise NotImplementedError.new("vcs_dir() must be implemented by subclasses of AbstractStagingArea.")
110
+ end
111
+
112
+
113
+ ##
114
+ # Returns all files tracked by the repository *for the working directory* - not
115
+ # to be confused with the most recent changeset.
116
+ #
117
+ # @api
118
+ # @return [Array<String>] all files tracked by the repository at this moment in
119
+ # time, including just-added files (for example) that haven't been committed yet.
120
+ def all_files
121
+ raise NotImplementedError.new("all_files() must be implemented by subclasses of AbstractStagingArea.")
122
+ end
123
+
124
+ ##
125
+ # Returns whether the given directory is being ignored. Optional method - defaults to
126
+ # +false+ at all times.
127
+ #
128
+ # @api-optional
129
+ # @param [String] directory the directory to check against ignoring rules
130
+ # @return [Boolean] are we ignoring this directory?
131
+ def ignoring_directory?(directory)
132
+ false
133
+ end
134
+
135
+ ##
136
+ # Returns whether the given file is being ignored. Optional method - defaults to
137
+ # +false+ at all times.
138
+ #
139
+ # @api-optional
140
+ # @param [String] file the file to check against ignoring rules
141
+ # @return [Boolean] are we ignoring this file?
142
+ def ignoring_file?(file)
143
+ false
144
+ end
145
+
146
+ ##
147
+ # Does a detailed look at a file, to see if it is clean, modified, or needs to have its
148
+ # content checked precisely.
149
+ #
150
+ # Supplements the built-in #status command so that its output will be cleaner.
151
+ #
152
+ # Defaults to report files as normal - it cannot check if a file has been modified
153
+ # without this method being overridden.
154
+ #
155
+ # @api-optional
156
+ #
157
+ # @param [String] file the filename to look up
158
+ # @param [File::Stats] st the current results of File.lstat(file)
159
+ # @return [Symbol] a symbol representing the current file's status
160
+ def file_precise_status(file, st)
161
+ return :lookup
162
+ end
163
+
164
+ ##
165
+ # Calculates the difference (in bytes) between a file and its last tracked state.
166
+ #
167
+ # Defaults to zero - in other words, it deactivates the delta feature.
168
+ #
169
+ # @api-optional
170
+ # @param [String] file the filename to look up
171
+ # @param [File::Stats] st the current results of File.lstat(file)
172
+ # @return [Fixnum] the number of bytes difference between the file and
173
+ # its last tracked state.
174
+ def calculate_delta(file, st)
175
+ 0
176
+ end
177
+
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,100 @@
1
+ module Amp
2
+ module Repositories
3
+ class AbstractVersionedFile
4
+ include CommonVersionedFileMethods
5
+
6
+ ##
7
+ # The changeset to which this versioned file belongs.
8
+ #
9
+ # @return [AbstractChangeset]
10
+ def changeset
11
+ raise NotImplementedError.new("changeset() must be implemented by subclasses of AbstractVersionedFile.")
12
+ end
13
+
14
+ ##
15
+ # The repo to which this {VersionedFile} belongs
16
+ #
17
+ # @return [AbstractLocalRepository]
18
+ def repo
19
+ raise NotImplementedError.new("repo() must be implemented by subclasses of AbstractVersionedFile.")
20
+ end
21
+ alias_method :repository, :repo
22
+
23
+ ##
24
+ # The path to this file
25
+ #
26
+ # @return [String]
27
+ def path
28
+ raise NotImplementedError.new("path() must be implemented by subclasses of AbstractVersionedFile.")
29
+ end
30
+
31
+ ##
32
+ # The revision of the file. This can be vague, so let me explain:
33
+ # This is the revision of the repo from which this VersionedFile is.
34
+ # If this is unclear, please submit a patch fixing it.
35
+ #
36
+ # @return [Integer]
37
+ def revision
38
+ raise NotImplementedError.new("revision() must be implemented by subclasses of AbstractVersionedFile.")
39
+ end
40
+
41
+ ##
42
+ # The size of this file
43
+ #
44
+ # @return [Integer]
45
+ def size
46
+ raise NotImplementedError.new("size() must be implemented by subclasses of AbstractVersionedFile.")
47
+ end
48
+
49
+ ##
50
+ # The contents of a file at the given revision
51
+ #
52
+ # @return [String] the data at the current revision
53
+ def data
54
+ raise NotImplementedError.new("data() must be implemented by subclasses of AbstractVersionedFile.")
55
+ end
56
+
57
+ ##
58
+ # The hash value for sticking this fucker in a hash.
59
+ #
60
+ # @return [Integer]
61
+ def hash
62
+ raise NotImplementedError.new("hash() must be implemented by subclasses of AbstractVersionedFile.")
63
+ end
64
+
65
+ ##
66
+ # Has this file been renamed? If so, return some useful info
67
+ def renamed?
68
+ raise NotImplementedError.new("renamed() must be implemented by subclasses of AbstractVersionedFile.")
69
+ end
70
+
71
+ ##
72
+ # Compares to either a bit of text or another versioned file.
73
+ # Returns true if different, false for the same.
74
+ # (much like <=> == 0 for the same)
75
+ #
76
+ # @param [AbstractVersionedFile, String] item what we're being compared to
77
+ # @return [Boolean] true if different, false if same.
78
+ def cmp(item)
79
+ raise NotImplementedError.new("cmp() must be implemented by subclasses of AbstractVersionedFile.")
80
+ end
81
+
82
+ ##
83
+ # Are two versioned files the same? This means same path and revision indexes.
84
+ #
85
+ # @param [AbstractVersionedFile] vfile what we're being compared to
86
+ # @return [Boolean]
87
+ def ==(vfile)
88
+ raise NotImplementedError.new("==() must be implemented by subclasses of AbstractVersionedFile.")
89
+ end
90
+
91
+ ##
92
+ # Gets the flags for this file ('x', 'l', or '')
93
+ #
94
+ # @return [String] 'x', 'l', or ''
95
+ def flags
96
+ raise NotImplementedError.new("flags() must be implemented by subclasses of AbstractVersionedFile.")
97
+ end
98
+ end
99
+ end
100
+ end