• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to merge code from 2 versions of the same program?

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a version say 1.0
Have changed something for it and named it 1.1, with some
changes I want to it to remain intact, while
some of it reverted. How do I merge 1.0 and 1.1
with the only significant changes to revert?
Any good Netbeans plugin?
Thanks
Jack
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you running on Windows, Linux or Mac? For Windows, try WinMerge, it should let you do what you want. There are also diff tools for Linux that let you do this kind of merging.
 
Ranch Hand
Posts: 574
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perforce is free if you're on your own. I would stuff 1.0 into it, branch to 1.1, then merge the branch back to the trunk.

If nothing else using Perforce will expose you to a professional level SCM tool while you're learning how to program.

/ Perforce rocks
// don't work for them
/// and have to admit, I have a bunch of RCS directories in my file system.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd also suggest using a version control system. I personally find distributed systems, such as git or Mercurial, better suited for personal use (both of these are completely free, regardless on your status). Moreover, with git you could upload your project onto GitHub and get a backup of your project for free.

In any case, you'll have to do the merge manually, so that you can discard the changes you don't want. Mercurial does have a good merging tool, but it merges non-conflicting changes manually automatically, which isn't what you want. You might still need to use a separate tool (such as already mentioned WinMerge) to be able to accept or reject changes in one go during the merge. Once you start using a version control system, it would be better to keep changes you don't plan to incorporate into a main branch in a separate branch, as the partial merge you need now is quite error prone.

Edited to remove confusion.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't checked NetBeans for that, but the Eclipse IDE has a "compare with" feature that allows comparing and merging 2 files within an Eclipse workspace. I've used it fairly often, since I have several projects that each are forced to keep their own copies of a file that (ideally) is identical in all of them.

The Linux (and other Unix/Unix-like) OS has a rich set of text comparison utilities, starting with the grandaddy of them all - the "diff" utility. You can find Windows implementations of diff, although they're not part of the standard OS distribution like in *n*x systems. I've used the Emacs text editor's compare/merge utilities quite a bit.

However, once you have reached the point where you have different versions of the same program to keep under control, I agree with previous posters. Use a Version Control System. The two most popular VCS's at the moment are git and Subversion (svn), but there are many others as well, both free and commercial.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic