├── COPYING
├── README.org
└── magit-review.el
/COPYING:
--------------------------------------------------------------------------------
1 |
2 | GNU GENERAL PUBLIC LICENSE
3 | Version 3, 29 June 2007
4 |
5 | Copyright (C) 2007 Free Software Foundation, Inc.
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The GNU General Public License is a free, copyleft license for
12 | software and other kinds of works.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | the GNU General Public License is intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users. We, the Free Software Foundation, use the
19 | GNU General Public License for most of our software; it applies also to
20 | any other work released this way by its authors. You can apply it to
21 | your programs, too.
22 |
23 | When we speak of free software, we are referring to freedom, not
24 | price. Our General Public Licenses are designed to make sure that you
25 | have the freedom to distribute copies of free software (and charge for
26 | them if you wish), that you receive source code or can get it if you
27 | want it, that you can change the software or use pieces of it in new
28 | free programs, and that you know you can do these things.
29 |
30 | To protect your rights, we need to prevent others from denying you
31 | these rights or asking you to surrender the rights. Therefore, you have
32 | certain responsibilities if you distribute copies of the software, or if
33 | you modify it: responsibilities to respect the freedom of others.
34 |
35 | For example, if you distribute copies of such a program, whether
36 | gratis or for a fee, you must pass on to the recipients the same
37 | freedoms that you received. You must make sure that they, too, receive
38 | or can get the source code. And you must show them these terms so they
39 | know their rights.
40 |
41 | Developers that use the GNU GPL protect your rights with two steps:
42 | (1) assert copyright on the software, and (2) offer you this License
43 | giving you legal permission to copy, distribute and/or modify it.
44 |
45 | For the developers' and authors' protection, the GPL clearly explains
46 | that there is no warranty for this free software. For both users' and
47 | authors' sake, the GPL requires that modified versions be marked as
48 | changed, so that their problems will not be attributed erroneously to
49 | authors of previous versions.
50 |
51 | Some devices are designed to deny users access to install or run
52 | modified versions of the software inside them, although the manufacturer
53 | can do so. This is fundamentally incompatible with the aim of
54 | protecting users' freedom to change the software. The systematic
55 | pattern of such abuse occurs in the area of products for individuals to
56 | use, which is precisely where it is most unacceptable. Therefore, we
57 | have designed this version of the GPL to prohibit the practice for those
58 | products. If such problems arise substantially in other domains, we
59 | stand ready to extend this provision to those domains in future versions
60 | of the GPL, as needed to protect the freedom of users.
61 |
62 | Finally, every program is threatened constantly by software patents.
63 | States should not allow patents to restrict development and use of
64 | software on general-purpose computers, but in those that do, we wish to
65 | avoid the special danger that patents applied to a free program could
66 | make it effectively proprietary. To prevent this, the GPL assures that
67 | patents cannot be used to render the program non-free.
68 |
69 | The precise terms and conditions for copying, distribution and
70 | modification follow.
71 |
72 | TERMS AND CONDITIONS
73 |
74 | 0. Definitions.
75 |
76 | "This License" refers to version 3 of the GNU General Public License.
77 |
78 | "Copyright" also means copyright-like laws that apply to other kinds of
79 | works, such as semiconductor masks.
80 |
81 | "The Program" refers to any copyrightable work licensed under this
82 | License. Each licensee is addressed as "you". "Licensees" and
83 | "recipients" may be individuals or organizations.
84 |
85 | To "modify" a work means to copy from or adapt all or part of the work
86 | in a fashion requiring copyright permission, other than the making of an
87 | exact copy. The resulting work is called a "modified version" of the
88 | earlier work or a work "based on" the earlier work.
89 |
90 | A "covered work" means either the unmodified Program or a work based
91 | on the Program.
92 |
93 | To "propagate" a work means to do anything with it that, without
94 | permission, would make you directly or secondarily liable for
95 | infringement under applicable copyright law, except executing it on a
96 | computer or modifying a private copy. Propagation includes copying,
97 | distribution (with or without modification), making available to the
98 | public, and in some countries other activities as well.
99 |
100 | To "convey" a work means any kind of propagation that enables other
101 | parties to make or receive copies. Mere interaction with a user through
102 | a computer network, with no transfer of a copy, is not conveying.
103 |
104 | An interactive user interface displays "Appropriate Legal Notices"
105 | to the extent that it includes a convenient and prominently visible
106 | feature that (1) displays an appropriate copyright notice, and (2)
107 | tells the user that there is no warranty for the work (except to the
108 | extent that warranties are provided), that licensees may convey the
109 | work under this License, and how to view a copy of this License. If
110 | the interface presents a list of user commands or options, such as a
111 | menu, a prominent item in the list meets this criterion.
112 |
113 | 1. Source Code.
114 |
115 | The "source code" for a work means the preferred form of the work
116 | for making modifications to it. "Object code" means any non-source
117 | form of a work.
118 |
119 | A "Standard Interface" means an interface that either is an official
120 | standard defined by a recognized standards body, or, in the case of
121 | interfaces specified for a particular programming language, one that
122 | is widely used among developers working in that language.
123 |
124 | The "System Libraries" of an executable work include anything, other
125 | than the work as a whole, that (a) is included in the normal form of
126 | packaging a Major Component, but which is not part of that Major
127 | Component, and (b) serves only to enable use of the work with that
128 | Major Component, or to implement a Standard Interface for which an
129 | implementation is available to the public in source code form. A
130 | "Major Component", in this context, means a major essential component
131 | (kernel, window system, and so on) of the specific operating system
132 | (if any) on which the executable work runs, or a compiler used to
133 | produce the work, or an object code interpreter used to run it.
134 |
135 | The "Corresponding Source" for a work in object code form means all
136 | the source code needed to generate, install, and (for an executable
137 | work) run the object code and to modify the work, including scripts to
138 | control those activities. However, it does not include the work's
139 | System Libraries, or general-purpose tools or generally available free
140 | programs which are used unmodified in performing those activities but
141 | which are not part of the work. For example, Corresponding Source
142 | includes interface definition files associated with source files for
143 | the work, and the source code for shared libraries and dynamically
144 | linked subprograms that the work is specifically designed to require,
145 | such as by intimate data communication or control flow between those
146 | subprograms and other parts of the work.
147 |
148 | The Corresponding Source need not include anything that users
149 | can regenerate automatically from other parts of the Corresponding
150 | Source.
151 |
152 | The Corresponding Source for a work in source code form is that
153 | same work.
154 |
155 | 2. Basic Permissions.
156 |
157 | All rights granted under this License are granted for the term of
158 | copyright on the Program, and are irrevocable provided the stated
159 | conditions are met. This License explicitly affirms your unlimited
160 | permission to run the unmodified Program. The output from running a
161 | covered work is covered by this License only if the output, given its
162 | content, constitutes a covered work. This License acknowledges your
163 | rights of fair use or other equivalent, as provided by copyright law.
164 |
165 | You may make, run and propagate covered works that you do not
166 | convey, without conditions so long as your license otherwise remains
167 | in force. You may convey covered works to others for the sole purpose
168 | of having them make modifications exclusively for you, or provide you
169 | with facilities for running those works, provided that you comply with
170 | the terms of this License in conveying all material for which you do
171 | not control copyright. Those thus making or running the covered works
172 | for you must do so exclusively on your behalf, under your direction
173 | and control, on terms that prohibit them from making any copies of
174 | your copyrighted material outside their relationship with you.
175 |
176 | Conveying under any other circumstances is permitted solely under
177 | the conditions stated below. Sublicensing is not allowed; section 10
178 | makes it unnecessary.
179 |
180 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
181 |
182 | No covered work shall be deemed part of an effective technological
183 | measure under any applicable law fulfilling obligations under article
184 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
185 | similar laws prohibiting or restricting circumvention of such
186 | measures.
187 |
188 | When you convey a covered work, you waive any legal power to forbid
189 | circumvention of technological measures to the extent such circumvention
190 | is effected by exercising rights under this License with respect to
191 | the covered work, and you disclaim any intention to limit operation or
192 | modification of the work as a means of enforcing, against the work's
193 | users, your or third parties' legal rights to forbid circumvention of
194 | technological measures.
195 |
196 | 4. Conveying Verbatim Copies.
197 |
198 | You may convey verbatim copies of the Program's source code as you
199 | receive it, in any medium, provided that you conspicuously and
200 | appropriately publish on each copy an appropriate copyright notice;
201 | keep intact all notices stating that this License and any
202 | non-permissive terms added in accord with section 7 apply to the code;
203 | keep intact all notices of the absence of any warranty; and give all
204 | recipients a copy of this License along with the Program.
205 |
206 | You may charge any price or no price for each copy that you convey,
207 | and you may offer support or warranty protection for a fee.
208 |
209 | 5. Conveying Modified Source Versions.
210 |
211 | You may convey a work based on the Program, or the modifications to
212 | produce it from the Program, in the form of source code under the
213 | terms of section 4, provided that you also meet all of these conditions:
214 |
215 | a) The work must carry prominent notices stating that you modified
216 | it, and giving a relevant date.
217 |
218 | b) The work must carry prominent notices stating that it is
219 | released under this License and any conditions added under section
220 | 7. This requirement modifies the requirement in section 4 to
221 | "keep intact all notices".
222 |
223 | c) You must license the entire work, as a whole, under this
224 | License to anyone who comes into possession of a copy. This
225 | License will therefore apply, along with any applicable section 7
226 | additional terms, to the whole of the work, and all its parts,
227 | regardless of how they are packaged. This License gives no
228 | permission to license the work in any other way, but it does not
229 | invalidate such permission if you have separately received it.
230 |
231 | d) If the work has interactive user interfaces, each must display
232 | Appropriate Legal Notices; however, if the Program has interactive
233 | interfaces that do not display Appropriate Legal Notices, your
234 | work need not make them do so.
235 |
236 | A compilation of a covered work with other separate and independent
237 | works, which are not by their nature extensions of the covered work,
238 | and which are not combined with it such as to form a larger program,
239 | in or on a volume of a storage or distribution medium, is called an
240 | "aggregate" if the compilation and its resulting copyright are not
241 | used to limit the access or legal rights of the compilation's users
242 | beyond what the individual works permit. Inclusion of a covered work
243 | in an aggregate does not cause this License to apply to the other
244 | parts of the aggregate.
245 |
246 | 6. Conveying Non-Source Forms.
247 |
248 | You may convey a covered work in object code form under the terms
249 | of sections 4 and 5, provided that you also convey the
250 | machine-readable Corresponding Source under the terms of this License,
251 | in one of these ways:
252 |
253 | a) Convey the object code in, or embodied in, a physical product
254 | (including a physical distribution medium), accompanied by the
255 | Corresponding Source fixed on a durable physical medium
256 | customarily used for software interchange.
257 |
258 | b) Convey the object code in, or embodied in, a physical product
259 | (including a physical distribution medium), accompanied by a
260 | written offer, valid for at least three years and valid for as
261 | long as you offer spare parts or customer support for that product
262 | model, to give anyone who possesses the object code either (1) a
263 | copy of the Corresponding Source for all the software in the
264 | product that is covered by this License, on a durable physical
265 | medium customarily used for software interchange, for a price no
266 | more than your reasonable cost of physically performing this
267 | conveying of source, or (2) access to copy the
268 | Corresponding Source from a network server at no charge.
269 |
270 | c) Convey individual copies of the object code with a copy of the
271 | written offer to provide the Corresponding Source. This
272 | alternative is allowed only occasionally and noncommercially, and
273 | only if you received the object code with such an offer, in accord
274 | with subsection 6b.
275 |
276 | d) Convey the object code by offering access from a designated
277 | place (gratis or for a charge), and offer equivalent access to the
278 | Corresponding Source in the same way through the same place at no
279 | further charge. You need not require recipients to copy the
280 | Corresponding Source along with the object code. If the place to
281 | copy the object code is a network server, the Corresponding Source
282 | may be on a different server (operated by you or a third party)
283 | that supports equivalent copying facilities, provided you maintain
284 | clear directions next to the object code saying where to find the
285 | Corresponding Source. Regardless of what server hosts the
286 | Corresponding Source, you remain obligated to ensure that it is
287 | available for as long as needed to satisfy these requirements.
288 |
289 | e) Convey the object code using peer-to-peer transmission, provided
290 | you inform other peers where the object code and Corresponding
291 | Source of the work are being offered to the general public at no
292 | charge under subsection 6d.
293 |
294 | A separable portion of the object code, whose source code is excluded
295 | from the Corresponding Source as a System Library, need not be
296 | included in conveying the object code work.
297 |
298 | A "User Product" is either (1) a "consumer product", which means any
299 | tangible personal property which is normally used for personal, family,
300 | or household purposes, or (2) anything designed or sold for incorporation
301 | into a dwelling. In determining whether a product is a consumer product,
302 | doubtful cases shall be resolved in favor of coverage. For a particular
303 | product received by a particular user, "normally used" refers to a
304 | typical or common use of that class of product, regardless of the status
305 | of the particular user or of the way in which the particular user
306 | actually uses, or expects or is expected to use, the product. A product
307 | is a consumer product regardless of whether the product has substantial
308 | commercial, industrial or non-consumer uses, unless such uses represent
309 | the only significant mode of use of the product.
310 |
311 | "Installation Information" for a User Product means any methods,
312 | procedures, authorization keys, or other information required to install
313 | and execute modified versions of a covered work in that User Product from
314 | a modified version of its Corresponding Source. The information must
315 | suffice to ensure that the continued functioning of the modified object
316 | code is in no case prevented or interfered with solely because
317 | modification has been made.
318 |
319 | If you convey an object code work under this section in, or with, or
320 | specifically for use in, a User Product, and the conveying occurs as
321 | part of a transaction in which the right of possession and use of the
322 | User Product is transferred to the recipient in perpetuity or for a
323 | fixed term (regardless of how the transaction is characterized), the
324 | Corresponding Source conveyed under this section must be accompanied
325 | by the Installation Information. But this requirement does not apply
326 | if neither you nor any third party retains the ability to install
327 | modified object code on the User Product (for example, the work has
328 | been installed in ROM).
329 |
330 | The requirement to provide Installation Information does not include a
331 | requirement to continue to provide support service, warranty, or updates
332 | for a work that has been modified or installed by the recipient, or for
333 | the User Product in which it has been modified or installed. Access to a
334 | network may be denied when the modification itself materially and
335 | adversely affects the operation of the network or violates the rules and
336 | protocols for communication across the network.
337 |
338 | Corresponding Source conveyed, and Installation Information provided,
339 | in accord with this section must be in a format that is publicly
340 | documented (and with an implementation available to the public in
341 | source code form), and must require no special password or key for
342 | unpacking, reading or copying.
343 |
344 | 7. Additional Terms.
345 |
346 | "Additional permissions" are terms that supplement the terms of this
347 | License by making exceptions from one or more of its conditions.
348 | Additional permissions that are applicable to the entire Program shall
349 | be treated as though they were included in this License, to the extent
350 | that they are valid under applicable law. If additional permissions
351 | apply only to part of the Program, that part may be used separately
352 | under those permissions, but the entire Program remains governed by
353 | this License without regard to the additional permissions.
354 |
355 | When you convey a copy of a covered work, you may at your option
356 | remove any additional permissions from that copy, or from any part of
357 | it. (Additional permissions may be written to require their own
358 | removal in certain cases when you modify the work.) You may place
359 | additional permissions on material, added by you to a covered work,
360 | for which you have or can give appropriate copyright permission.
361 |
362 | Notwithstanding any other provision of this License, for material you
363 | add to a covered work, you may (if authorized by the copyright holders of
364 | that material) supplement the terms of this License with terms:
365 |
366 | a) Disclaiming warranty or limiting liability differently from the
367 | terms of sections 15 and 16 of this License; or
368 |
369 | b) Requiring preservation of specified reasonable legal notices or
370 | author attributions in that material or in the Appropriate Legal
371 | Notices displayed by works containing it; or
372 |
373 | c) Prohibiting misrepresentation of the origin of that material, or
374 | requiring that modified versions of such material be marked in
375 | reasonable ways as different from the original version; or
376 |
377 | d) Limiting the use for publicity purposes of names of licensors or
378 | authors of the material; or
379 |
380 | e) Declining to grant rights under trademark law for use of some
381 | trade names, trademarks, or service marks; or
382 |
383 | f) Requiring indemnification of licensors and authors of that
384 | material by anyone who conveys the material (or modified versions of
385 | it) with contractual assumptions of liability to the recipient, for
386 | any liability that these contractual assumptions directly impose on
387 | those licensors and authors.
388 |
389 | All other non-permissive additional terms are considered "further
390 | restrictions" within the meaning of section 10. If the Program as you
391 | received it, or any part of it, contains a notice stating that it is
392 | governed by this License along with a term that is a further
393 | restriction, you may remove that term. If a license document contains
394 | a further restriction but permits relicensing or conveying under this
395 | License, you may add to a covered work material governed by the terms
396 | of that license document, provided that the further restriction does
397 | not survive such relicensing or conveying.
398 |
399 | If you add terms to a covered work in accord with this section, you
400 | must place, in the relevant source files, a statement of the
401 | additional terms that apply to those files, or a notice indicating
402 | where to find the applicable terms.
403 |
404 | Additional terms, permissive or non-permissive, may be stated in the
405 | form of a separately written license, or stated as exceptions;
406 | the above requirements apply either way.
407 |
408 | 8. Termination.
409 |
410 | You may not propagate or modify a covered work except as expressly
411 | provided under this License. Any attempt otherwise to propagate or
412 | modify it is void, and will automatically terminate your rights under
413 | this License (including any patent licenses granted under the third
414 | paragraph of section 11).
415 |
416 | However, if you cease all violation of this License, then your
417 | license from a particular copyright holder is reinstated (a)
418 | provisionally, unless and until the copyright holder explicitly and
419 | finally terminates your license, and (b) permanently, if the copyright
420 | holder fails to notify you of the violation by some reasonable means
421 | prior to 60 days after the cessation.
422 |
423 | Moreover, your license from a particular copyright holder is
424 | reinstated permanently if the copyright holder notifies you of the
425 | violation by some reasonable means, this is the first time you have
426 | received notice of violation of this License (for any work) from that
427 | copyright holder, and you cure the violation prior to 30 days after
428 | your receipt of the notice.
429 |
430 | Termination of your rights under this section does not terminate the
431 | licenses of parties who have received copies or rights from you under
432 | this License. If your rights have been terminated and not permanently
433 | reinstated, you do not qualify to receive new licenses for the same
434 | material under section 10.
435 |
436 | 9. Acceptance Not Required for Having Copies.
437 |
438 | You are not required to accept this License in order to receive or
439 | run a copy of the Program. Ancillary propagation of a covered work
440 | occurring solely as a consequence of using peer-to-peer transmission
441 | to receive a copy likewise does not require acceptance. However,
442 | nothing other than this License grants you permission to propagate or
443 | modify any covered work. These actions infringe copyright if you do
444 | not accept this License. Therefore, by modifying or propagating a
445 | covered work, you indicate your acceptance of this License to do so.
446 |
447 | 10. Automatic Licensing of Downstream Recipients.
448 |
449 | Each time you convey a covered work, the recipient automatically
450 | receives a license from the original licensors, to run, modify and
451 | propagate that work, subject to this License. You are not responsible
452 | for enforcing compliance by third parties with this License.
453 |
454 | An "entity transaction" is a transaction transferring control of an
455 | organization, or substantially all assets of one, or subdividing an
456 | organization, or merging organizations. If propagation of a covered
457 | work results from an entity transaction, each party to that
458 | transaction who receives a copy of the work also receives whatever
459 | licenses to the work the party's predecessor in interest had or could
460 | give under the previous paragraph, plus a right to possession of the
461 | Corresponding Source of the work from the predecessor in interest, if
462 | the predecessor has it or can get it with reasonable efforts.
463 |
464 | You may not impose any further restrictions on the exercise of the
465 | rights granted or affirmed under this License. For example, you may
466 | not impose a license fee, royalty, or other charge for exercise of
467 | rights granted under this License, and you may not initiate litigation
468 | (including a cross-claim or counterclaim in a lawsuit) alleging that
469 | any patent claim is infringed by making, using, selling, offering for
470 | sale, or importing the Program or any portion of it.
471 |
472 | 11. Patents.
473 |
474 | A "contributor" is a copyright holder who authorizes use under this
475 | License of the Program or a work on which the Program is based. The
476 | work thus licensed is called the contributor's "contributor version".
477 |
478 | A contributor's "essential patent claims" are all patent claims
479 | owned or controlled by the contributor, whether already acquired or
480 | hereafter acquired, that would be infringed by some manner, permitted
481 | by this License, of making, using, or selling its contributor version,
482 | but do not include claims that would be infringed only as a
483 | consequence of further modification of the contributor version. For
484 | purposes of this definition, "control" includes the right to grant
485 | patent sublicenses in a manner consistent with the requirements of
486 | this License.
487 |
488 | Each contributor grants you a non-exclusive, worldwide, royalty-free
489 | patent license under the contributor's essential patent claims, to
490 | make, use, sell, offer for sale, import and otherwise run, modify and
491 | propagate the contents of its contributor version.
492 |
493 | In the following three paragraphs, a "patent license" is any express
494 | agreement or commitment, however denominated, not to enforce a patent
495 | (such as an express permission to practice a patent or covenant not to
496 | sue for patent infringement). To "grant" such a patent license to a
497 | party means to make such an agreement or commitment not to enforce a
498 | patent against the party.
499 |
500 | If you convey a covered work, knowingly relying on a patent license,
501 | and the Corresponding Source of the work is not available for anyone
502 | to copy, free of charge and under the terms of this License, through a
503 | publicly available network server or other readily accessible means,
504 | then you must either (1) cause the Corresponding Source to be so
505 | available, or (2) arrange to deprive yourself of the benefit of the
506 | patent license for this particular work, or (3) arrange, in a manner
507 | consistent with the requirements of this License, to extend the patent
508 | license to downstream recipients. "Knowingly relying" means you have
509 | actual knowledge that, but for the patent license, your conveying the
510 | covered work in a country, or your recipient's use of the covered work
511 | in a country, would infringe one or more identifiable patents in that
512 | country that you have reason to believe are valid.
513 |
514 | If, pursuant to or in connection with a single transaction or
515 | arrangement, you convey, or propagate by procuring conveyance of, a
516 | covered work, and grant a patent license to some of the parties
517 | receiving the covered work authorizing them to use, propagate, modify
518 | or convey a specific copy of the covered work, then the patent license
519 | you grant is automatically extended to all recipients of the covered
520 | work and works based on it.
521 |
522 | A patent license is "discriminatory" if it does not include within
523 | the scope of its coverage, prohibits the exercise of, or is
524 | conditioned on the non-exercise of one or more of the rights that are
525 | specifically granted under this License. You may not convey a covered
526 | work if you are a party to an arrangement with a third party that is
527 | in the business of distributing software, under which you make payment
528 | to the third party based on the extent of your activity of conveying
529 | the work, and under which the third party grants, to any of the
530 | parties who would receive the covered work from you, a discriminatory
531 | patent license (a) in connection with copies of the covered work
532 | conveyed by you (or copies made from those copies), or (b) primarily
533 | for and in connection with specific products or compilations that
534 | contain the covered work, unless you entered into that arrangement,
535 | or that patent license was granted, prior to 28 March 2007.
536 |
537 | Nothing in this License shall be construed as excluding or limiting
538 | any implied license or other defenses to infringement that may
539 | otherwise be available to you under applicable patent law.
540 |
541 | 12. No Surrender of Others' Freedom.
542 |
543 | If conditions are imposed on you (whether by court order, agreement or
544 | otherwise) that contradict the conditions of this License, they do not
545 | excuse you from the conditions of this License. If you cannot convey a
546 | covered work so as to satisfy simultaneously your obligations under this
547 | License and any other pertinent obligations, then as a consequence you may
548 | not convey it at all. For example, if you agree to terms that obligate you
549 | to collect a royalty for further conveying from those to whom you convey
550 | the Program, the only way you could satisfy both those terms and this
551 | License would be to refrain entirely from conveying the Program.
552 |
553 | 13. Use with the GNU Affero General Public License.
554 |
555 | Notwithstanding any other provision of this License, you have
556 | permission to link or combine any covered work with a work licensed
557 | under version 3 of the GNU Affero General Public License into a single
558 | combined work, and to convey the resulting work. The terms of this
559 | License will continue to apply to the part which is the covered work,
560 | but the special requirements of the GNU Affero General Public License,
561 | section 13, concerning interaction through a network will apply to the
562 | combination as such.
563 |
564 | 14. Revised Versions of this License.
565 |
566 | The Free Software Foundation may publish revised and/or new versions of
567 | the GNU General Public License from time to time. Such new versions will
568 | be similar in spirit to the present version, but may differ in detail to
569 | address new problems or concerns.
570 |
571 | Each version is given a distinguishing version number. If the
572 | Program specifies that a certain numbered version of the GNU General
573 | Public License "or any later version" applies to it, you have the
574 | option of following the terms and conditions either of that numbered
575 | version or of any later version published by the Free Software
576 | Foundation. If the Program does not specify a version number of the
577 | GNU General Public License, you may choose any version ever published
578 | by the Free Software Foundation.
579 |
580 | If the Program specifies that a proxy can decide which future
581 | versions of the GNU General Public License can be used, that proxy's
582 | public statement of acceptance of a version permanently authorizes you
583 | to choose that version for the Program.
584 |
585 | Later license versions may give you additional or different
586 | permissions. However, no additional obligations are imposed on any
587 | author or copyright holder as a result of your choosing to follow a
588 | later version.
589 |
590 | 15. Disclaimer of Warranty.
591 |
592 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
593 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
594 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
595 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
596 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
597 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
598 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
599 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
600 |
601 | 16. Limitation of Liability.
602 |
603 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
604 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
605 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
606 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
607 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
608 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
609 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
610 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
611 | SUCH DAMAGES.
612 |
613 | 17. Interpretation of Sections 15 and 16.
614 |
615 | If the disclaimer of warranty and limitation of liability provided
616 | above cannot be given local legal effect according to their terms,
617 | reviewing courts shall apply local law that most closely approximates
618 | an absolute waiver of all civil liability in connection with the
619 | Program, unless a warranty or assumption of liability accompanies a
620 | copy of the Program in return for a fee.
621 |
622 | END OF TERMS AND CONDITIONS
623 |
624 | How to Apply These Terms to Your New Programs
625 |
626 | If you develop a new program, and you want it to be of the greatest
627 | possible use to the public, the best way to achieve this is to make it
628 | free software which everyone can redistribute and change under these terms.
629 |
630 | To do so, attach the following notices to the program. It is safest
631 | to attach them to the start of each source file to most effectively
632 | state the exclusion of warranty; and each file should have at least
633 | the "copyright" line and a pointer to where the full notice is found.
634 |
635 |
636 | Copyright (C)
637 |
638 | This program is free software: you can redistribute it and/or modify
639 | it under the terms of the GNU General Public License as published by
640 | the Free Software Foundation, either version 3 of the License, or
641 | (at your option) any later version.
642 |
643 | This program is distributed in the hope that it will be useful,
644 | but WITHOUT ANY WARRANTY; without even the implied warranty of
645 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
646 | GNU General Public License for more details.
647 |
648 | You should have received a copy of the GNU General Public License
649 | along with this program. If not, see .
650 |
651 | Also add information on how to contact you by electronic and paper mail.
652 |
653 | If the program does terminal interaction, make it output a short
654 | notice like this when it starts in an interactive mode:
655 |
656 | Copyright (C)
657 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
658 | This is free software, and you are welcome to redistribute it
659 | under certain conditions; type `show c' for details.
660 |
661 | The hypothetical commands `show w' and `show c' should show the appropriate
662 | parts of the General Public License. Of course, your program's commands
663 | might be different; for a GUI interface, you would use an "about box".
664 |
665 | You should also get your employer (if you work as a programmer) or school,
666 | if any, to sign a "copyright disclaimer" for the program, if necessary.
667 | For more information on this, and how to apply and follow the GNU GPL, see
668 | .
669 |
670 | The GNU General Public License does not permit incorporating your program
671 | into proprietary programs. If your program is a subroutine library, you
672 | may consider it more useful to permit linking proprietary applications with
673 | the library. If this is what you want to do, use the GNU Lesser General
674 | Public License instead of this License. But first, please read
675 | .
676 |
677 |
--------------------------------------------------------------------------------
/README.org:
--------------------------------------------------------------------------------
1 | # Written in 2013 by Christopher Allan Webber
2 | #
3 | # To the extent possible under law, the author(s) have dedicated all
4 | # copyright and related and neighboring rights to this
5 | # documentation/README file to the public domain worldwide. This
6 | # software is distributed without any warranty.
7 | #
8 | # You should have received a copy of the CC0 Public Domain
9 | # Dedication along with this software. If not, see
10 | # .
11 |
12 | * About magit-review
13 | ** Motivation
14 |
15 | For a long time I used magit-wazzap to handle all my code reviews.
16 | magit-wazzup is awesome... who doesn't want a buffer where they can
17 | see all branches with new commits for them to check out at once?
18 |
19 | But I found that as my project grew, magit-wazzup failed to scale for
20 | me:
21 | - It was too slow. My project had about 500 or so branches and
22 | magit-wazzup would check *all* of them if they had new commits and
23 | format them all for display. magit-wazzup had an interface to mark
24 | something as "ignored" but it didn't really work for me because the
25 | branches that should have been ignored didn't show up for me to
26 | ignore them anyway!
27 | - I also found magit-wazzup's ignore tool annoying because I didn't
28 | have a nice way to double check later that I really wanted things
29 | that were ignored to stay ignored.
30 | - Sometimes I wanted to mark a few branches as "I need to review
31 | these" and jump to a limited view of wazzup so I could just focus
32 | on the branches I knew needed attention.
33 |
34 | If these irritations sound familiar to you, you might like
35 | magit-review (if not, you might want to just stick with magit-wazzup;
36 | it's admittedly slightly simpler). And if you already like
37 | magit-wazzup, you'll be happy to see that magit-review basically works
38 | the same way, with just a few small enhancements.
39 |
40 | ** magit-review's strategy
41 |
42 | magit-review works pretty much the same as magit-wazzup except that it
43 | adds two features: states and filters. You can mark a branch with
44 | some sort of state (magit-review will serialize this so that it's
45 | remembered) and apply a filter so that only branches that match that
46 | state actually show up. For more information on how to actually make
47 | use of that strategy, read on.
48 |
49 | ** License
50 |
51 | magit-review is licensed under the GNU GPL v3 or later, just like
52 | GNU Emacs.
53 |
54 | This document is waived into the public domain under CC0 1.0.
55 |
56 | * Using magit-review
57 | ** Installing
58 |
59 | Put magit-review.el on your elisp path or something. ;)
60 |
61 | Honestly, I just do:
62 |
63 | #+begin_src emacs-lisp
64 | (load-file "~/devel/magit-review/magit-review.el")
65 | #+end_src
66 |
67 | ** Invoking magit-review
68 |
69 | First, open magit:
70 |
71 | : M-x magit-status
72 |
73 | Next, open magit-review:
74 |
75 | : M-x magit-review
76 |
77 | At this point you should have an interface that looks exactly like
78 | magit-wazzup, except you'll notice there's a header above all the
79 | commits that says "Branches in unknown:"
80 |
81 | This is because you haven't filed any branches into any states yet.
82 | Let's figure out how to switch filters and states so you can make the
83 | most of magit-review.
84 |
85 | ** States and filters
86 |
87 | *** Switching filters via bookmarks
88 |
89 | Filters, as said, switch our branches based on their state. There's a
90 | small rule syntax for switching the active filters, but we'll avoid
91 | going into how that works for now. For the moment, let's try
92 | switching filters the easy way.
93 |
94 | The default filter is "general" mode. We'll explain the details of
95 | how filter rules work later, but the rule for this is:
96 | : "tracked=all ignored=none other=new"
97 |
98 | This means that:
99 | - Every branch that is marked to be "tracked" is shown, whether it
100 | has new commits or not. (If you haven't changed any states,
101 | nothing should be tracked yet because you haven't marked anything
102 | as such.)
103 | - Anything marked as "ignored" will be ignored whether it has new
104 | commits or not.
105 | - Anything else will be checked first wither it has new commits. If
106 | it has new commits, it'll be shown; otherwise it won't show up at
107 | all.
108 |
109 | Let's try switching to another filter. Press the "t" key. This
110 | brings up the fil"t"er bookmarks menu. Try pressing "a" for "all".
111 | If you have branches that have no new commits in them, these will also
112 | now show up. You can switch things back by pressing "t" and then "g"
113 | to switch back to the "general" filter again.
114 |
115 | *** Changing a branch's state
116 |
117 | But maybe that general view takes too long to load. Augh! There's
118 | plenty of branches that just don't /have/ anything anymore. Why
119 | should you wait for them to show up when you /know/ they don't have
120 | any commits?
121 |
122 | So, let's switch to the "nothing new" filter. This will help you hunt
123 | for branches that don't have anything new in them anymore so just
124 | shouldn't be displayed. Press "t" then "nn" to switch to the nothing
125 | new filter now.
126 |
127 | Are there a bunch of branches here that say there are no commits? On
128 | mine there are, and they look like this:
129 |
130 | : (no commits) master (willkg)
131 | :
132 | : (no commits) keyboard_nav (willkg)
133 | :
134 | : (no commits) 401-plugins (willkg)
135 | :
136 | : (no commits) sqltests (tryggvib)
137 |
138 | Okay. So we don't need these to show up any more, so let's tell
139 | magit-review not to look for them anymore. We want to switch them to
140 | the ignored:nothing-new state. That way they won't take up any more
141 | time when we're in the general filter.
142 |
143 | Move your cursor over one of these branches and press "s" to bring up
144 | the states bookmark menu. Press "in"... this should set the state to
145 | "ignored:nothing-new" which means "we're ignoring this because we
146 | don't think this has any new commits in it any more." (You could set
147 | up a filter to double check that you're right and that these branches
148 | haven't somehow gotten new commits later... magit-review makes that
149 | easy.) The color of this branch should change indicating its state
150 | has changed.
151 |
152 | We can verify that this branch is moved over to the
153 | "ignored:nothing-new" state by switching our filter. Press "t" then
154 | "ia" to switch to the filter that shows all branches currently marked
155 | as ignored. You should see the branch you just marked show up.
156 |
157 | Okay, awesome. Maybe you've changed a bunch of branches now. Switch
158 | back to the general view ("t" then "g")... if your situation is like
159 | mine was, it should load a lot faster now!
160 |
161 | But wait... augh! There's still some branches here that we just don't
162 | care about any more. On my general view I currently see this branch:
163 |
164 | : 4 unmerged commits in flatpages (willkg)
165 |
166 | Ugh! We merged that branch! The problem is that we rebased it
167 | locally before merging, so it *looks* like it has new commits. But it
168 | doesn't really! We don't want it to bother us anymore when we're
169 | looking at our general review overview... let's get it out of here!
170 |
171 | Type "s" then "ii"... this switches the state to "ignored:ignored",
172 | which means that it doesn't *matter* to us that this has new commits,
173 | we just don't ever want to see it ever again because it's irrelevant
174 | now.
175 |
176 | Awesome! If you hit "g" to refresh the buffer, it shouldn't show up
177 | any more.
178 |
179 | Okay... wait a second, did you notice that the two states that we set
180 | both started with "ignored:"? That's because states generally come in
181 | two pieces: "general:specific". For example, the general workflow of
182 | magit-review is that we either want to track things or we want to
183 | ignore them. But we might want to do so for different reasons. For
184 | example, we wanted to ignore some branches because they didn't have
185 | any new commits, and we wanted to ignore some other branches because
186 | they do have some new commits but they're just not relevant anymore.
187 | It's important to have those distinctions (okay, it's important to
188 | me): if new commits appear in the ignored:nothing-new section we'll
189 | want to find them and move them out of there. That's not true of
190 | ignored:ignored because we want to ignore them forever.
191 |
192 | We'll explain the meaning of the builtin states and filters in the
193 | next section, but for now let's try doing one more state thing:
194 | sometimes you want to mark something as being tracked so you can focus
195 | on a shorter list of things to review. Let's try that: select a
196 | branch you need to review. For example, in my case I have a branch
197 | that my friend spaetz has been requesting I look at, and I'm like,
198 | yeah yeah, it's on my radar! I've hit on this one to look at
199 | the list of branches, so it's expanded. Locally, it looks like this
200 | to me:
201 |
202 | : 3 unmerged commits in WIP/large_uploads (spaetz)
203 | : aab5af4 * Don't read full image media into RAM on copying (#419)
204 | : f2abb7b * Make Cloudfiles copy memory efficient too (#419)
205 | : f9b5d9c * Make copying to/from storage systems memory efficient (#419)
206 |
207 | But let's /really/ move it onto my radar by marking it as tracked.
208 | Hit "s" then "tr" which moves it to "tracked:review". Now I can
209 | filter to seeing just tracked:review things... or even in the general
210 | section, this branch shows up in a completely different section than
211 | the ones that aren't marked:
212 |
213 | : Branches in tracked:review:
214 | :
215 | : 3 unmerged commits in WIP/large_uploads (spaetz)
216 | : aab5af4 * Don't read full image media into RAM on copying (#419)
217 | : f2abb7b * Make Cloudfiles copy memory efficient too (#419)
218 | : f9b5d9c * Make copying to/from storage systems memory efficient (#419)
219 |
220 | Whew! I'd better get to that one soon. ;)
221 |
222 | *** Builtin states and filters and their meanings
223 |
224 | The default list of states is fairly short. As said, states fall into
225 | two categories: things to review and things to ignore (you
226 | don't /have/ to use these paradigms, these are just the default ones).
227 |
228 | - *tracked:review* -- This is something that needs to be reviewed and
229 | merged. It's on a "shortlist" of things you need to look at.
230 | You'll get to it... you promise!
231 | - *tracked:deferred* -- This is something you're keeping an eye on
232 | but which isn't on your immediate review queue. Very likely,
233 | you're waiting on something. For example, you may have reviewed it
234 | and passed it back to the original author and are asking them to
235 | make some changes before you are ready to merge it.
236 | - *ignored:nothing-new* -- The last time you looked at this there
237 | weren't any new commits in it. That doesn't mean there aren't
238 | now... somehow that might change (you may want to use a filter so
239 | you can check on this from time to time and pull things out of this
240 | state) but at the very least don't slow down our general view by
241 | scanning them for new commits.
242 | - *ignored:ignored* -- There may be new commits in here or there may
243 | not... you really don't care, you just don't want to see these
244 | branches anymore.
245 |
246 | There's also a "special state" which is "unknown"... which means there
247 | is no branch state set at all. (You can filter on this special state,
248 | and switching the branch to unknown will actually clear the state
249 | altogether.)
250 |
251 | *** Switching states and filters manually
252 |
253 | If you want to set a state manually, that's really easy. Instead of
254 | hitting "s" to use the state shortcuts, use "S" instead to change it
255 | manually.
256 |
257 | Similarly, instead of using "t" to change the filter via a bookmark,
258 | you can hit "T" to change it manually. However, before you do that,
259 | you should probably understand how filters work!
260 |
261 | ** Understanding the filter syntax
262 |
263 | The filter syntax is very minimal. It basically works like:
264 |
265 | : "state=directive another:state=directive"
266 |
267 | In other words, you set multiple filter components separated by
268 | spaces. Each filter component has a state (yes, you know what states
269 | are by now) and a directive that says what should be done with
270 | whatever branch matches that state. Each filter is looked at in
271 | order; the first rule that matches is accepted.
272 |
273 | So let's look at a real-world example.
274 |
275 | : "tracked:review=all ignored=none unknown=new other=none"
276 |
277 | Okay, this is simple! (It could be written more concisely, but I
278 | wanted a comprehensive example.) Let's look at each piece in turn.
279 |
280 | - *tracked:review=all* -- If something is marked as tracked:review,
281 | this matches. The directive is "all" so it will be shown
282 | regardless of whether it has new commits (useful... you can move
283 | anything that no longer has new commits because it was merged into
284 | ignored:nothing-new if you forgot about it)
285 | - *ignored=none* -- /Any/ branch that is in the ignored general state
286 | will be ignored. It doesn't matter if it's in ignored:ignored or
287 | ignored:nothing-new, it will be ignored. Notice how this is
288 | different from the above rule, which is much more specific about
289 | state, while this is more general.
290 | - *unknown=new* -- As said above, unknown is a special state meaning
291 | that it has no state. According to this rule, only branches with
292 | new commits will be shown if they have no assigned state.
293 |
294 | There's also one rule that doesn't need to be in this filter, but it's
295 | here for demonstration purposes:
296 |
297 | - *other=none* -- This rule is somewhat superfluous here because
298 | "none" is the default directive for anything that doesn't have a
299 | matching rule (you can change this by changing the variable
300 | 'magit-review/default-directive if you like). "other" is the other
301 | special state, and it's a catch-all (so it should always go
302 | last... magit-review isn't smart enough to reorder things so
303 | anything after this rule is effectivel ignored). So as you can
304 | probably guess, in this case, something in say tracked:deferred
305 | would be caught by this rule and be told not to be displayed (even
306 | though that's the default anyway...)
307 |
308 | Valid directives are:
309 | - all (show everything)
310 | - none (show nothing)
311 | - new (show only things with new commits)
312 | - nothing-new (show only things that have no new commits)
313 |
314 | Knowing this, we can create some fancy filters. For example, to skip
315 | over everything ignored but otherwise show anything that has new
316 | commits:
317 |
318 | : "ignored=none other=new"
319 |
320 | Or, to double check that our pile of branches in
321 | ignored:nothing-new *really* doesn't have anything new in it (who
322 | knows, that could have changed when we weren't looking!):
323 |
324 | : "ignored:nothing-new:new"
325 |
326 | Likewise, to clean out stuff you tracked but that actually doesn't
327 | have anything new anymore (so you should move it to
328 | ignored:nothing-new):
329 |
330 | : "tracked=nothing-new"
331 |
332 | Note the tricky distinction between ignored:nothing-new the state and
333 | nothing-new the directive. ;)
334 |
335 | ** Making your own state and filter bookmarks
336 |
337 | As said, you're not restricted to the states and filters that come
338 | packaged with magit-review... they're just the states and filters that
339 | make sense to the author. But say you want to use the following
340 | states:
341 |
342 | - *workified:do-it-now* -- This is when your boss is yelling at you
343 | because you needed to get this done /yesterday/!
344 | - *workified:review-it* -- This is something at your work that you
345 | need to code review. You should probably look at it, you promised
346 | Sal that you'd check over her code soon!
347 | - *workified:waiting-review* -- This is something that you passed off
348 | for someone else to review, or something. I don't know, you come
349 | up with the rules. ;)
350 |
351 | That's fine! Go for it. Go ahead and do it! You can just set these
352 | states manually by using "T" and everything will be fine and great! ;)
353 |
354 | However... you might want to not do this manually. That's fairly
355 | tedious! So we have an easy solution: use bookmarks!
356 |
357 | Bookmarks have a fairly simple syntax. Here they are as defined in
358 | the magit-review source code:
359 |
360 | #+begin_src emacs-lisp
361 | (defvar magit-review/filter-bookmarks
362 | '(("g" "General" "tracked=all ignored=none other=new")
363 | ("tr" "Tracked review" "tracked:review=new other=none")
364 | ("ia" "Ignored all" "ignored=all other=none")
365 | ("ii" "ignored:ignored all" "ignored:ignored=all other=none")
366 | ("in" "ignored new" "ignored=new other=none")
367 | ("nn" "nothing new" "ignored:nothing-new=none other=nothing-new")
368 | ("a" "All" "other=all"))
369 | "Modify this to change the keyboard keys which set the current filter.
370 |
371 | Works like:
372 | ((\"shortcut\" \"Description\" \"state\"))
373 |
374 | Note that after running this you probably want to eval
375 | (magit-review/add-filter-bookmark-keys)")
376 |
377 | (defvar magit-review/state-bookmarks
378 | '(("tr" "tracked:review" "tracked:review")
379 | ("td" "tracked:deferred" "tracked:deferred")
380 | ("ii" "ignored:ignored" "ignored:ignored")
381 | ("in" "ignored:nothing-new" "ignored:nothing-new")
382 | ("c" "clear state" nil))
383 | "Modify this to change the keyboard keys which set which state.
384 |
385 | Works like:
386 | ((\"shortcut\" \"Description\" \"state\"))
387 |
388 | Note that after running this you probably want to eval
389 | (magit-review/add-state-bookmark-keys)")
390 | #+end_src
391 |
392 | Fairly simple in both cases. So say you wanted to add some state
393 | bookmarks so you can set these really easily.
394 |
395 | #+begin_src emacs-lisp
396 | (setq magit-review/state-bookmarks
397 | (append
398 | magit-review/state-bookmarks
399 | '(("wd" "Work: do it now" "workified:do-it-now")
400 | ("wr" "Work: review it" "workified:review-it")
401 | ("ww" "Work: waiting on review" "workified:waiting-review"))))
402 | ; You must run this in order for the bookmark keys to get regenerated
403 | (magit-review/add-state-bookmark-keys)
404 |
405 | (setq magit-review/filter-bookmarks
406 | (append
407 | magit-review/filter-bookmarks
408 | '(("wd" "Work: do/review it queue" "workified:do-it-now=all workified:review-it:new")
409 | ("wa" "Work: all" "workified=all"))))
410 | ; You must run this in order for the bookmark keys to get regenerated
411 | (magit-review/add-filter-bookmark-keys)
412 | #+end_src
413 |
414 | As you can probably tell in both types of bookmarks, the syntax is roughly:
415 |
416 | : '(("key" "description" "state/filter"))
417 |
418 | Now you have your own workflow!
419 |
420 | ** Where things get stored
421 |
422 | Easy! magit-review stores things in a big ol json dump in
423 | .git/info/magit-review.
424 |
425 | * Things to do
426 | ** TODO Sorting the state categories in the display
427 | ** TODO Changing filters manually
428 | ** TODO Make sure all our docstrings are still accurate
429 | ** TODO Forbid users from setting the state "other"; that's a special case
430 | ** TODO Notes
431 |
--------------------------------------------------------------------------------
/magit-review.el:
--------------------------------------------------------------------------------
1 | ;; -*- mode: emacs-lisp; lexical-binding: t; -*-
2 |
3 | ;; Magit-review
4 | ;; ------------
5 | ;;
6 | ;; Copyright (C) 2012, 2013 Christopher Allan Webber
7 | ;;
8 | ;; magit-review is free software; you can redistribute it and/or
9 | ;; modify it under the terms of the GNU General Public License as
10 | ;; published by the Free Software Foundation; either version 3, or (at
11 | ;; your option) any later version.
12 | ;;
13 | ;; Magit is distributed in the hope that it will be useful, but WITHOUT
14 | ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 | ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 | ;; License for more details.
17 | ;;
18 | ;; You should have received a copy of the GNU General Public License
19 | ;; along with this program. If not, see .
20 |
21 | ;; This borrows significant ideas (and a few small code snippets) from
22 | ;; magit wazzup.
23 |
24 |
25 | ;; This is a BUFFER LOCAL VARIABLE, do not set.
26 | (defvar magit-review/review-state
27 | nil
28 | "State of reviews in this magit-review buffer.
29 |
30 | Contains the user marks of what is and isn't in what state of review.
31 |
32 | Doesn't contain info on whether or not there's anything new to be
33 | seen in the branch.
34 |
35 | Buffer-local; do not set manually!")
36 | (make-variable-buffer-local 'magit-review/review-state)
37 |
38 | ;;; Maybe eventually we'll have a "save manually" feature
39 | ;; (defvar magit-review/review-state-changed
40 | ;; nil
41 | ;; "Whether or not the review state has changed since last being serialized")
42 | ;; (make-variable-buffer-local 'magit-review/review-state-changed)
43 |
44 | (defvar magit-review-head nil
45 | "The integration head for the current review buffer.
46 | This is only non-nil in review buffers.")
47 | (make-variable-buffer-local 'magit-review-head)
48 |
49 |
50 | ;; (defface magit-review-section-state-changed
51 | ;; '((t :inherit magit-header :background "saddle brown"))
52 | ;; "Face for when a section's state has changed."
53 | ;; :group 'magit-faces)
54 |
55 |
56 | ;;; Format of review metadata
57 | ;;; -------------------------
58 | ;;
59 | ;; Here's a mini json representation:
60 | ;;
61 | ;; {"refs/remotes/bretts/bug419-chunk-reads": {
62 | ;; "state": "tracked:review",
63 | ;; "notes": "We'll come back to this later"},
64 | ;; "refs/remotes/bretts/keyboard_nav": {
65 | ;; "state": "tracked:deferred"},
66 | ;; "refs/remotes/bretts/master": {
67 | ;; "state": "tracked:review"},
68 | ;; "refs/remotes/bretts/newlayout": {
69 | ;; "state": "ignored:ignored"},
70 | ;; "refs/remotes/bretts/newlayout-stage": {
71 | ;; "state": "ignored:nothingnew"},
72 | ;; "refs/remotes/chemhacker/349_rssfeed": {
73 | ;; "state": "ignored:ignored"},
74 | ;; "refs/remotes/chemhacker/bug178_userlist": {
75 | ;; "state": "ignored:nothingnew"}}
76 |
77 |
78 | ;; Review file management
79 | ;; ----------------------
80 | ;;
81 | ;; Review file is jsonified versions of the local
82 | ;; magit-review/review-state hash-table variable.
83 |
84 | ; Get the review file
85 | (defun magit-review/get-review-file ()
86 | (concat (magit-git-dir) "info/magit-review"))
87 |
88 |
89 | ; Load review file
90 | (defun magit-review/read-review-file ()
91 | "Read the review file and get back an hash-table"
92 | (let ((magit-review-file (magit-review/get-review-file))
93 | (json-key-type 'string)
94 | (json-object-type 'hash-table))
95 | (if (file-exists-p magit-review-file)
96 | (json-read-file magit-review-file)
97 | (make-hash-table :test 'equal))))
98 |
99 | (defun magit-review/load-review-file ()
100 | "Read the review file into the buffer-local state of reviewing"
101 | (setq magit-review/review-state (magit-review/read-review-file)))
102 |
103 |
104 | ; Serialize current state
105 | (defun magit-review/serialize-review-state ()
106 | "Serialize the current state of reviews to file."
107 | (let ((magit-review-file (magit-review/get-review-file))
108 | (jsonified-review-state
109 | (json-encode-hash-table magit-review/review-state)))
110 | ; Move the old file aside
111 | (magit-review/move-old-review-file-if-exists)
112 | ; Write a new file
113 | (with-temp-file
114 | magit-review-file
115 | (insert jsonified-review-state))))
116 |
117 |
118 | (defun magit-review/move-old-review-file-if-exists ()
119 | "If the old magit-review file exists, move it aside."
120 | (let ((magit-review-file (magit-review/get-review-file)))
121 | (if (file-exists-p magit-review-file)
122 | (rename-file magit-review-file
123 | (concat (magit-git-dir) "info/magit-review.old")
124 | t))))
125 |
126 |
127 | ;; Branch filtering
128 | ;; ----------------
129 |
130 | (defvar magit-review/filter-rule
131 | "tracked=all ignored=none other=new"
132 | "String to state how things are being filtered.
133 |
134 | Basically, with a string like:
135 |
136 | tracked=all ignored=none other=new
137 |
138 | this will mean:
139 | - All tracked branches (eg, tracked:review or tracked:deferred,
140 | whatever) will be shown, regardless of whether there's new commits or not.
141 | - All ignored branches (eg, ignored:ignored and
142 | ignored:nothingnew) will be ignored, regardless of whatever
143 | - Anything else will be displayed, but *only* if there are new commits.
144 |
145 | You can get more specific also, like:
146 | tracked:review=all tracked:deferred=new ignored=none other=new
147 |
148 | Valid states are... well anything, though convention is to use
149 | \"tracked\" and \"ignored\" for keeping note of what to track or
150 | ignore... but you could use anything. There are some special
151 | cases though... \"unknown\" means it does not have any state
152 | assigned to it, and \"other\" is used to say \"anything that has
153 | not matched yet will match this\", and you should always set it
154 | last in your filter rule if using.
155 |
156 | Valid directives are:
157 | - all (show everything)
158 | - none (show nothing)
159 | - new (show only things with new commits)
160 | - nothing-new (show only things that have no new commits)
161 | ")
162 |
163 | (defun magit-review/parse-filter-string (&optional filter-string)
164 | "Take a filter string and break it into filter coponents.
165 |
166 | So:
167 | tracked=all ignored=none other=new
168 |
169 | will become:
170 | ((\"tracked\" \"all\")
171 | (\"ignored\" \"none\")
172 | (\"other\" \"new\"))
173 |
174 | You can pass this FILTER-STRING; otherwise it will process
175 | magit-review/filter-rule"
176 | (let ((filter-string (or filter-string magit-review/filter-rule)))
177 | (mapcar
178 | (lambda (item) (split-string item "="))
179 | (split-string filter-string))))
180 |
181 |
182 | (defun magit-review/determine-matching-rule (branch-state rules)
183 | "Return a matching rule... if we can find one.
184 |
185 | Note: if the branch doesn't have a state, it's convention to set
186 | it as \"untracked\" before passing it in here.
187 | "
188 | (let ((branch-state-components (split-string branch-state ":")))
189 | (block matching-rule-finder
190 | (loop
191 | for rule in rules do
192 | (let* ((rule-state (car rule))
193 | (rule-state-components (split-string rule-state ":")))
194 | (if (or
195 | ; it's other, which should always go last, so this is a catch-all
196 | (equal rule-state "other")
197 | ; they're the same thing; that's a match
198 | (equal rule-state branch-state)
199 | ; this is a "catch-many" rule, and it's multi-component
200 | (and (= (length rule-state-components) 1)
201 | (> (length branch-state-components) 1)
202 | (equal (car branch-state-components) rule-state))
203 | ; the branch state is none and this is an "untracked" rule
204 | (and (equal branch-state nil)
205 | (equal rule-state "untracked")))
206 | (return-from matching-rule-finder rule)))))))
207 |
208 |
209 | (defun magit-review/has-new-commits (branch-name &optional head)
210 | "See if this branch has any new commits in it."
211 | (> (length (magit-git-lines
212 | "log" "--pretty=oneline"
213 | (concat (or head "HEAD") ".." branch-name)))
214 | 0))
215 |
216 | (defun magit-review/should-include-branch (branch-name rule-directive &optional head)
217 | "Should we include anything new in this branch? Check!"
218 | (cond
219 | ; always include branches under an "all" directive
220 | ((equal rule-directive "all") t)
221 | ; never include any branches marked none
222 | ((equal rule-directive "none") nil)
223 | ((and (equal rule-directive "new")
224 | (magit-review/has-new-commits branch-name head)) t)
225 | ((and (equal rule-directive "nothing-new")
226 | (not (magit-review/has-new-commits branch-name head))) t)))
227 |
228 |
229 | (defvar magit-review/default-directive
230 | "none"
231 | "Default directive if we don't find a matching rule.")
232 |
233 |
234 | (defun magit-review/filter-branches (&optional head refs-to-check filter-rules)
235 | "Return a filtered set of branches
236 |
237 | This function weeds out the ones that shouldn't be shown.
238 |
239 | The returned a plist which will look something like:
240 | (\"untracked\" (\"refs/remotes/bretts/keyboard_nav\"
241 | \"refs/remotes/bretts/master\")
242 | \"tracked:review\" (\"refs/remotes/bretts/newlayout\"
243 | \"refs/remotes/bretts/newlayout-stage\"))
244 | "
245 | (let ((refs-to-check
246 | (or refs-to-check
247 | (magit-list-interesting-refs)))
248 | (filter-rules (or filter-rules (magit-review/parse-filter-string)))
249 | (filtered-branches (make-hash-table :test 'equal)))
250 | (mapc
251 | (lambda (branch)
252 | (let* ((branch-name (car branch))
253 | (branch-ref (cdr branch))
254 | (branch-record (gethash branch-ref magit-review/review-state))
255 | (branch-state
256 | (if branch-record
257 | (or (gethash "state" branch-record)
258 | "unknown")
259 | "unknown"))
260 | ;; (branch-rule
261 | ;; (magit-review/determine-matching-rule
262 | ;; branch-ref branch-state filter-rules))
263 | (matching-rule
264 | (magit-review/determine-matching-rule
265 | branch-state filter-rules))
266 | (matching-rule-state
267 | (if matching-rule
268 | (car matching-rule)
269 | "unknown"))
270 | (matching-rule-directive
271 | (if matching-rule
272 | (nth 1 matching-rule)
273 | magit-review/default-directive)))
274 | ; If we should include the branch, let's include it!
275 | (if (magit-review/should-include-branch
276 | branch-ref matching-rule-directive head)
277 |
278 | ; File this branch with the other branches of its type
279 | (puthash
280 | branch-state
281 | (cons branch (gethash branch-state filtered-branches))
282 | filtered-branches))))
283 | refs-to-check)
284 | filtered-branches))
285 |
286 |
287 | ;; magit-review display
288 | (defun magit-review/refresh-review-buffer (head)
289 | ; load the review-state file if we haven't yet
290 | (if (not magit-review/review-state)
291 | (magit-review/load-review-file))
292 |
293 | (setq magit-review-head head)
294 |
295 | (magit-create-buffer-sections
296 | (let ((branches-to-show (magit-review/filter-branches head)))
297 | (maphash
298 | (lambda (state branches)
299 | (magit-with-section 'reviewbuf nil
300 | (insert (format "Branches in %s:\n\n" state))
301 | (dolist (branch branches)
302 | (let* ((branch-name (car branch))
303 | (branch-ref (cdr branch))
304 | (magit-section-hidden-default t)
305 | (n (length (magit-git-lines "log" "--pretty=oneline"
306 | (concat head ".." branch-ref)))))
307 | (if (> n 0)
308 | (magit-set-section-info
309 | branch-ref
310 | (magit-git-section
311 | (cons branch-ref 'review)
312 | (format "%s unmerged commits in %s"
313 | n branch-name)
314 | 'magit-wash-log
315 | "log"
316 | (format "--max-count=%s" magit-log-cutoff-length)
317 | "--abbrev-commit"
318 | (format "--abbrev=%s" magit-sha1-abbrev-length)
319 | "--graph"
320 | "--pretty=oneline"
321 | (format "%s..%s" head branch-ref)
322 | "--"))
323 | (progn
324 | ; I'm not sure whether or not this needs to be a section
325 | (magit-with-section branch-ref 'review
326 | (insert
327 | (propertize
328 | (format "(no commits) %s" branch-name)
329 | 'face 'magit-section-title)
330 | "\n"))
331 | (insert "\n")))))))
332 | branches-to-show))))
333 |
334 |
335 | (defun magit-review/get-branch-ref-at-point ()
336 | "Get the branch ref at point if we're hovering over a function"
337 | (save-excursion
338 | (beginning-of-line)
339 | (let ((section (plist-get (text-properties-at (point)) 'magit-section)))
340 | (cond ((eq (magit-section-type section) 'review)
341 | (magit-section-title section))
342 | ((eq (magit-section-type section) 'commit)
343 | (magit-section-title (magit-section-parent section)))))))
344 |
345 |
346 | (defun magit-review/move-point-to-top-of-branch ()
347 | (interactive)
348 | (beginning-of-line)
349 | (let ((section (plist-get (text-properties-at (point)) 'magit-section)))
350 | (if (eq (magit-section-type section) 'commit)
351 | (magit-goto-parent-section))))
352 |
353 | (defun magit-review/visually-mark-state-change ()
354 | "Visually mark the state change on the branch at point"
355 | (save-excursion
356 | (magit-review/move-point-to-top-of-branch)
357 | (let ((overlay (make-overlay (line-beginning-position) (line-end-position))))
358 | (overlay-put overlay 'face 'mode-line-inactive))))
359 |
360 | (defun magit-review/get-current-branch-state (branch-ref)
361 | "Get the current state of this branch.
362 |
363 | If branch has no state, returns nil."
364 | (let ((branch-record (gethash branch-ref magit-review/review-state)))
365 | (if branch-record
366 | (gethash "state" branch-record))))
367 |
368 |
369 | (defun magit-review/switch-state-manually (&optional state)
370 | (interactive)
371 | (let* ((branch-ref (magit-review/get-branch-ref-at-point))
372 | (current-state (magit-review/get-current-branch-state branch-ref))
373 | (input-state
374 | (or state
375 | (read-from-minibuffer
376 | (format "Switch to what state? (currently %s): "
377 | (or current-state "unknown"))
378 | current-state)))
379 | (branch-record
380 | (or (gethash branch-ref magit-review/review-state)
381 | (make-hash-table :test 'equal)))
382 | (is-unknown (member input-state '(nil "unknown"))))
383 | (cond
384 | ; if it's not unknown... set it
385 | ((not is-unknown)
386 | (progn
387 | (puthash "state" input-state branch-record)
388 | (puthash branch-ref branch-record magit-review/review-state)))
389 | ; is unknown, but previously had a value... unset it
390 | ((and current-state is-unknown)
391 | (progn
392 | (remhash "state" branch-record)
393 | (puthash branch-ref branch-record magit-review/review-state))))
394 | (magit-review/visually-mark-state-change)
395 | (magit-review/serialize-review-state)))
396 |
397 | (defun magit-review/apply-state-to-branch (state)
398 | (interactive)
399 | (magit-review/switch-state-manually state))
400 |
401 |
402 | ;; Keys stuff
403 | ;; ----------
404 |
405 | (defvar magit-review/filter-bookmarks
406 | '(("g" "General" "tracked=all ignored=none other=new")
407 | ("tr" "Tracked review" "tracked:review=new other=none")
408 | ("ia" "Ignored all" "ignored=all other=none")
409 | ("ii" "ignored:ignored all" "ignored:ignored=all other=none")
410 | ("in" "ignored new" "ignored=new other=none")
411 | ("nn" "nothing new" "ignored:nothing-new=none other=nothing-new")
412 | ("a" "All" "other=all"))
413 | "Modify this to change the keyboard keys which set the current filter.
414 |
415 | Works like:
416 | ((\"shortcut\" \"Description\" \"state\"))
417 |
418 | Note that after running this you probably want to eval
419 | (magit-review/add-filter-bookmark-keys)")
420 |
421 | (defvar magit-review/state-bookmarks
422 | '(("tr" "tracked:review" "tracked:review")
423 | ("td" "tracked:deferred" "tracked:deferred")
424 | ("ii" "ignored:ignored" "ignored:ignored")
425 | ("in" "ignored:nothing-new" "ignored:nothing-new")
426 | ("c" "clear state" nil))
427 | "Modify this to change the keyboard keys which set which state.
428 |
429 | Works like:
430 | ((\"shortcut\" \"Description\" \"state\"))
431 |
432 | Note that after running this you probably want to eval
433 | (magit-review/add-state-bookmark-keys)")
434 |
435 | (defun magit-review/add-state-bookmark-keys ()
436 | "Add state change bookmark keys"
437 | (magit-review/add-filters-generic
438 | 'review-state-bookmark magit-review/state-bookmarks
439 | 'magit-review/apply-state-to-branch))
440 |
441 |
442 | (defun magit-review/apply-filter (filter)
443 | (make-local-variable 'magit-review/filter-rule)
444 | (setq magit-review/filter-rule filter))
445 |
446 | (defun magit-review/apply-filter-and-refresh (filter)
447 | (interactive)
448 | (magit-review/apply-filter filter)
449 | (magit-review/add-filter-bookmark-keys)
450 | (magit-review/refresh-review-buffer
451 | (or magit-review-head "HEAD")))
452 |
453 |
454 | (defun magit-review/add-filters-generic (group bookmarks func)
455 | ;; (re-)create the group
456 | (magit-key-mode-add-group group)
457 | (loop
458 | for (key description args) in bookmarks do
459 | (progn
460 | (magit-key-mode-insert-action
461 | group key description
462 | ; Generate a curried function that changes the args
463 | (let ((this-arg args))
464 | (lambda ()
465 | (interactive)
466 | (funcall func this-arg))))))
467 | (magit-key-mode-generate group))
468 |
469 |
470 | (defun magit-review/add-filter-bookmark-keys ()
471 | "Add filter/bookmark keys"
472 | (magit-review/add-filters-generic
473 | 'review-filter-bookmark magit-review/filter-bookmarks
474 | 'magit-review/apply-filter-and-refresh))
475 |
476 |
477 | (defvar magit-review-mode-map
478 | (let ((map (make-sparse-keymap)))
479 | (define-key map (kbd "t") 'magit-key-mode-popup-review-filter-bookmark)
480 | (define-key map (kbd "T") 'magit-review/switch-filter-manually)
481 | (define-key map (kbd "s") 'magit-key-mode-popup-review-state-bookmark)
482 | (define-key map (kbd "S") 'magit-review/switch-state-manually)
483 | map))
484 |
485 | (magit-review/add-filter-bookmark-keys)
486 | (magit-review/add-state-bookmark-keys)
487 |
488 |
489 | ;; Mode stuff
490 | ;; ----------
491 |
492 |
493 | (define-derived-mode magit-review-mode magit-mode "Magit Review"
494 | "Mode for looking at commits that could be merged from other branches.
495 |
496 | \\{magit-review-mode-map}"
497 | :group 'magit)
498 |
499 | (defun magit-review ()
500 | (interactive)
501 | (let ((topdir (magit-get-top-dir default-directory))
502 | (current-branch (magit-get-current-branch)))
503 | (magit-buffer-switch "*magit-review*")
504 | (magit-mode-init topdir 'magit-review-mode
505 | #'magit-review/refresh-review-buffer
506 | current-branch)))
507 |
--------------------------------------------------------------------------------