eclipse - How to undo / redo selective parts of code? -
i using eclipse.
it happens lot when develop code (assume developed sequentially, top bottom):
part 1 (*) part 2 part 3 part 4 (*) part 5
but figured out parts 1 , 4 (marked (*)) wrong , others fine. question how can undo 2 parts (1 , 4) without undoing rest?
if undo selectively, great. note reverting code version 1 loses parts 2, 3 , 5 correct parts , should remain in code. note these parts mixed in 1 or 2 code blocks (not in separate blocks).
example:
part 1: add method f1(x, y) , move code main() f1() --> incorrect (should reverted) part 2: add method f2(a, b, c, d) --> correct (should remain) part 3: change part of main() implementation --> correct (should remain) part 4: change f2 signature f2(s, n) --> incorrect (should reverted) part 5: change body of f2 --> correct (should remain)
the current approach use is:
- keeping copy of latest version somewhere (e.g., in temporary text file), undo before part 1, , add correct parts temporary text file source code.
- manual comparison of different versions, , resolving conflicts.
does think of easier, yet more automatic way of selecting change undo , 1 keep?
eclipse keeps history of changes few days (configured in preferences in 'general > workspace > local history'). can right click on file , select 'compare > local history' see differences between 2 version of file. can copy changes old version current version.
for longer term should use version control system such svn or git. there eclipse plugins these let similar 'compare with' operations - covering entire history of file (provided commit changes regularily).
Comments
Post a Comment