PHP ZCE mock test, interview preparation, daily lessons under chalk talk

Monday, July 30, 2012

How conflict occurs in svn?


Many times, the SVN can automatically merge changes to different parts of a file. Conflicts can arise when changes appear that don’t gel: Joe wants to remove eggs and replace it with cheese (-eggs, +cheese), and Sue wants to replace eggs with a hot dog (-eggs, +hot dog).






Basic conflicts in SVN




At this point it’s a race: if Joe checks in first, that’s the change that goes through (and Sue can’t make her change).

When changes overlap and contradict like this, SVN may report a conflict and not let you check in — it’s up to you to check in a newer version that resolves this dilemma. 



A few approaches:

  • Re-apply your changes
    . Sync to the the latest version (r4) and re-apply your changes to this file: Add hot dog to the list that already has cheese.

  • Override their changes with yours
    . Check out the latest version (r4), copy over your version, and check your version in. In effect, this removes cheese and replaces it with hot dog.




Conflicts are infrequent but can be a pain. Usually I update to the latest and re-apply my changes.



How to Remove conflicts in svn


When we commit our changes on svn, we may get an error message:
$ svn commit -m "Updated README"
Sending    README
Transmitting file data .svn: Commit failed (details follow):
svn: Out of date: '/myproject/README'
It says that the file we want to commit has changed since we last updated it. Update the file to get it up-to-date again.
$ svn update
C   README
Updated to revision 6.
The 'C' indicates there is a conflict with the README file, and Subversion does not know how to solve this.
If we now take a look at README, we'll notice that there are several markers that indicate what parts of the code are conflicting. We can easily see what we changed, and what has changed in the repository:
<<<<<<< .mine
This is fun stuff!
=======
This is a documentation file
>>>>>>> .r6

What are our options?

We have three options for resolving the conflict. Whatever to choose, make sure you confer with your colleague on the matter.


1. Scrap your changes, and go with the current work from your colleague.
This is the easiest solution. All you have to do is revert the changes you made, and update your working copy:
$ svn revert README
Reverted 'README'
$ svn update README
At revision 6.




2. Keep your changes, and dump whatever your colleague did.
Performing a simple 'ls' will show you that there are four files related to this conflict:
  • README – the original with markers
  • README.mine – your version
  • README.r5 – the original your worked with
  • README.r6 – the most update version from your colleague
To check in your changes, copy your version over the original and tell Subversion you have resolved the conflict.
$ cp README.mine README
$ svn resolved README
Resolved conflicted state of 'README'
The 'resolved' command will clean up all the special files that were generated.




3. Merge both version to a new version
If you choose this option, you will have to manually edit README. Remove the markers and add whatever you need to add here.
Subversion won't let you commit this file, so you'll have to mark it as 'resolved' as we saw during option 2:
$ svn resolved README
Resolved conflicted state of 'README'


To better understand why does conflicts occur visit http://php-geeks-wink.blogspot.in/2012/07/how-conflict-occurs-in-svn.html

Friday, July 6, 2012

Difference between innerHTML and appendChild

Jquery / Javascript : What is the difference between innerHTML and appendChild?


Answer :

  • appendChild is used to insert new node in DOM.
  • innerHTML is a property of DOM that allows to replace content of an element with different HTML, which automatically gets parsed into DOM nodes.