问题
In Netbeans when I make a dozen changes that break more than they fix, usually I find the culprit right away by looking at the history, find the culprit, fix it, and go on my merry way. Takes very little time.
But often I find that Netbeans shows nearly 100 changes. Almost all of them involve changes like the two pairs of history lines below (older line listed first in each pair):
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
// </editor-fold>//GEN-END:initComponents
// </editor-fold>
The vast majority of the changes seem to only occur on statements generated by Swing design.
Why do //GEN-BEGIN:initComponents
and //GEN-END:initComponents
get added onto lines I didn't change?
What did I do to cause this?
How can I avoid this? (Other than quit using Swing design, which I already have in other projects, but this is an older project that I'm sort of stuck with.)
What can I do to fix it so I can just see the lines I changed?
I went here but it doesn't tell how "You can also remove the //GEN-FIRST and //GEN-LAST to make them editable in Netbeans."
回答1:
The folded code is regenerated, based on GUI editor properties, each time you build; the effect you describe is not unexpected. Alter a specific property, e.g. by using the Customize Code…
dialog, and see how the generated code changes. While the source code editor can collapse generated code, the history views cannot.
Some mitigation strategies:
Limit use of the GUI editor to the relatively small number of enclosing containers that really need it, as shown here.
Use the
History View
navigation controls to move among available changes.Identify critical revisions in the
Message
column of theDiff Viewer
pane.Check
Options > Team > History
settings to match your workflow.Search for
History View
in the help dialog for additional guidance.
来源:https://stackoverflow.com/questions/25817867/netbeans-history-shows-100-changes-but-i-made-only-a-few-how-do-i-avoid-this