Tuesday, August 21, 2012

IE Shenanigan Part 1: Javascript Array

NO trailing comma/s on your javascript arrays.

<script type='text/javascript'>

    var myArray = {
        "a":"apple",
        "b":"banana",
        "c":"carrot", // this, here, is a trailing comma
    }

</script>

If you encounter a javascript error in your page when using Internet Explorer, you might want to check your javascript arrays for trailing commas.  While other browsers don't mind, apparently IE doesn't want those kinds of things, so better remove them and try loading your page again.


Sunday, August 5, 2012

SVN: Merging a Branch to Trunk

svn merge - apply the changes between two sources to a working copy path

Usage:
    svn merge <source> -r<X>:<Y> <dest>
where X is the revision from where your branch was copied, and Y is the revision you want to merge your branch into.  The value of Y is usually the latest revision of trunk, or HEAD.

Switching a branch back to trunk
Note:  \ means that the command continues on to the succeeding line/s.
  1. Get the revision number from when your branch was created.
    • Option 1:  switch to the branch, and find the revision your branch began at:

           svn switch http://examplesvn.com/svn/  \
                project/branches/branch_name

           svn log --stop-on-copy

      This will display the commits that have been made in branch_name back to the point it was created.  The oldest revision here will be used as the value of X.

    • Option 2:  find the revision your branch began at without switching:

           svn log --stop-on-copy http://examplesvn.com/  \
                svn/project/branches/branch_name


      This, too, will behave the same way as option 1.

  2. Switch to destination, in this case, trunk.

         svn switch http://examplesvn.com/svn/project/trunk

  3. Test-run the merging.

         svn merge http://examplesvn.com/svn/project/  \
              branches/branch_name -rX:HEAD . --dry-run


    where X is the revision when branch_name was created, and HEAD (the actual string, not a representative of a value) is the latest revision of your current working copy, trunk, which is also your destination set to ".".  This command will simulate the actual merging, display the conflicts, if any (this is what you want to watch out for), and the rest of the changes to be made if this was an actual merge.

    Note.  This is actually a good practice, since you will see what's going to happen upon merging, without the risk of destroying your current working copy.

  4. Merge.  If the dry-run is successful and looks good to you, proceed with merging:

         svn merge http://examplesvn.com/svn/project/  \
              branches/branch_name -rX:HEAD .


  5. Check status.  Check if the changes are reflected.

         svn status

  6. Commit.  If everything is ok - changes are reflected, conflicts have been resolved, etc - commit the current changes by the merge.

         svn commit -m "MERGING branches/branch_name to trunk"

And that's it. :)