[GSOC] Interactive patch selection for commit/Mercurial Queues/record/import
Peter Hosey
boredzo at gmail.com
Mon Mar 30 09:24:37 CDT 2009
On Mar 30, 2009, at 05:01:20, Justin Peng wrote:
> |
> |---- changes of a hunk
> |
> |---- changes of a class in a hunk
> |
> |----changes of a function in a
> class
First, not all classes look the same. Classes in C++, Java, Python,
and Objective-C all look different. The ideal implementation of a
class parser would be modular so that users could add class parsers
for their own favorite languages.
Second, not everything in a Mercurial repository is in a class. Source
code may be procedural or functional instead of object-oriented; for
example, anything written in C is procedural. Procedural and
functional source code does not have any classes.
Moreover, any non-trivial program contains strings files, Makefiles/
project files, documentation, and other textual data that is not
source code. So you will need to handle the case of no classes *or
functions* whatsoever.
Even when you are looking at source code, class and function parsers
are *really hard* even for one language, since you have to work around
comments and (in Python) multi-line strings. Now multiply that work by
at least four. That's what you're proposing. And for any language you
don't support, plus all the textual files that aren't object-oriented
source code, you'll need to support skipping the class and function
levels anyway.
Therefore, I'm not sure class and function parsing would fit into the
same Summer of Code as the unified interactive-hunk-selection facility
in general. It would probably be nice to have eventually, but it's a
lot of work.
Third, you forgot a level:
> |
> |---- changes of a hunk
> |
> |---- changes of a class in a hunk
> |
> |----changes of a function in a
> class
|
|----changes of lines (in a
function or otherwise)
Sometimes I've added two lines at the same time that really should be
in separate (patches|commits). It would be helpful if the record
extension (or in-core successor to it) allowed me to select specific
lines of a hunk so that I can put them in separate (patches|commits)
without having to go back, delete stuff, save, hope power doesn't go
out, record, undo the deletion, save.
Additionally, as Rafael Villar Burke pointed out while I was writing
this, line granularity works for any text, not just source code.
More information about the Mercurial
mailing list