Dropbox, a swiss-knife tool for developers

dropbox Among the tools I consider useful, Dropbox is one ! It offers a free online storage space of 2 Gb with automatic synchronization with local directory and versioning ! I personally use to keep my digital books, guides, code snippets, software (php, apache, mysql, portable graphic software, IDEs, etc…) between two houses and workplace.

Nice features are the possibility to share contents with other dropbox users and get public links of the selected files (to let anyone to download that file). The second feature can be used to easily download our compressed files (custom libraries, frameworks) into our new hosting (wget via ssh).

Another feature I like is the “immediate upload“: if the same file (thanks probably to a hash of the file) is already on the dropbox servers (as uploaded by another dropbox user I suppose), the file is automatically copied online-to-online without the need to upload it.  Practically, any file downloaded online is probably already on dropbox, of course except personal files and compressed files. When saving the OpenOffice installer, it will be helpful.

Download and enjoy it ! (that’s an affiliate link, if you download from that link, I get  additional 250Mb of space, thanks 🙂 )

How to solve SVN conflicts. Netbeans SVN plugin tools

SVN [official site] is the most powerful open source version control software at the moment.
Introduction (for who doesn’t know it at all)
Basically, SVN is a server/client system. The server that contains the repository (source code of our application).The clients get the source code (CHECK OUT) or only the new files (UPDATE) from the server. The opposite operation is called COMMIT, and consists in sending new files to the server. Every commit generates a new repository revision; SVN mantains the content of the files in every revision with the aim not to lose code and the possibility to undo code changes.
svn conflicts

[http://telin.ugent.be/~slippens/svn-intro/fig/vc-concepts.png]
How to solve conflicts
SVN works allowing clients to get files without any locks ! It means that sometimes you may commit a file, but another client has committed the same files before. This is a conflict ! SVN requests to you to manually resolve the conflict, in order not to lose the code written by the other client (correct behaviour !).
How can you solve the conflict ? There are many solutions:
  1. Delete your local changes (REVERT). your code will be overwritten by the newest file in the repository (written not by you). Do it if you are sure you want to delete your changes.
  2. Keep ur changes and commit. Do UPDATE and SVN client will be overwrite the file (with your code between “[[[[[[[[[[[ .mine” and “=======”, and the code in the repository between the second marker and “]]]]]]]]]]]]] .rN”). SVN client will also create a copy of your changed file (file.ext.mine), the original you worked with (file.ext.rM) and the newest file in the repository(file.ext.rN).now:
    2.1Analyze differences and create a new file (recommended)
    analyze the differences (DIFF) between files, then modify the file.txt, set the conflict resolved (RESOLVE, after that SVN client allows to commit) and COMMIT.
    – 2.1.1 – For small files, you can edit directly file.txt (mind deleting the markers) and obtain a new file (operation called merging). Then set resolved and commit.
    – 2.1.2 – For bigger files, it’s a good solution to use a tool for file comparison (DIFF), for example between file.ext.mine (your modified file) and file.ext.rN (the newest in the repository). Then save the new file as file.ext, set resolved (RESOLVE) and COMMIT.

    or

    2.2Overwrite the current file in the repository with your changes (be careful !). To do it, copy file.ext.mine to file.ext, set resolved(RESOLVE) and COMMIT

Netbeans SVN plugin

Netbeans [official site] (free java-based IDE for JAVA, J2SE, C/C++, Ruby and PHP) works with the collab.net SVN command line client and provides a useful tools to manage the SVN operation on the source code.
How to do the operations above with Netbeans 6.7 (a message error dialog appears in case of conflict). Filename: file.ext. All the commands are available with right click on the file.ext, then “Subversion”.
  1. “Revert modification…” and “Revert Local Changes”
  2. Update” (the file will be coloured “red”, it’ necessary before 2.1.1 or 2.1.2), then:2.1.1 (imho the best solution). Manually merge the changes and create a new content for the “red” file (mind removing markers). “Resolve Conflicts” (now the colour will be blue, and the temporary files will be deleted), then “Commit“.

    2.1.2 (Netbeans solution, not the best solution imho) .”Show changes”, double click on the bottom panel “Subversion” on the line with the “red” file (status=local conflict). In the main window, you will see the local file (left) and the remote (right). Netbeans will show line by line the conflicts (different code in the same line), and you can choose the line to have in the new file by clicking in “Accept” on the left or on the right. then “Commit”.

    Netbeans/manual alternative to 2.1.2: Select file.ext.mine and file.ext.rN (where N is the highest), then tight click, “Tools” and “Diff”. Now create a copy with the rigth code, then copy all the content in file.ext, “Resolve Conflicts” and “Commit”. It Looks complicated but maybe it’s the best in case of lots of conflicts.

    2.2. copy the content of the hidden file file.ext.mine to file.ext (the red one), then “Resolve Conflicts” and “Commit” (strongly not recommended !!).

How to reduce conflicts
  1. Do “Update” before start changing a file !! You will reduce the possibility of conflicts
  2. Do more “commit”, for example every 30min instead of 2h (choose it in according on the number of the clients working on the same file).
  3. In case of merging you will probably have to contact other developers to be sure about merging in case your code to commit is much different. Arrange on files with other developers (you’ll avoid to have lots of conflicts when committing)
  4. Other suggestions ?

SVN to FTP/web on Windows with svn client+winscp

How to deploy a web application and to quickly deploy future updates/patches from a SVN repository into a remote web server (only with ftp access and without possibility to setup svn client) ?
Here are my suggested steps:

  1. export SVN (that is obtain the last repository without “.svn” directories)
  2. process the exported SVN (e.g. adding or deleting files before uploading)
  3. upload (1st time) or synchronize (update new files to the remote webserver)
  4. chmod folders (only 1st time or new folders)
All the 4 steps are executable from a handy shell script using:
  • Linux: svn client (1) + rsync (3)
  • Windows: svn client subversion (1) + winscp script (2)
Example of a svn to ftp batch in Windows (with subversion client and winscp, both are free):
  1. Create a profile with winscp, and set local folder “c:tempsite1” and remote folder (e.g. “/httpdocs” ).
  2. Write a batch file svn2ftpsite1.bat
    set PATHFOLDER=c:tempsite1
    svn export svn://1.2.3.4/trunk %PATHFOLDER% –force
    del %PATHFOLDER%file-not-to-upload* /q
    copy c:other-folderfile-to-add-to-site1 %PATHFOLDER%
    c:path-towinscp.exe /console “open winscp-profile” “synchronize remote” “chmod 777 uploads” “close”
  3. Save. And launch when you want to update the remote site (don’t forget to commit the svn before)
Read the winscp online scripting manual for further information.
Note: if the web server (Linux I think!) can access the SVN repository, has SSH server and subversion client, you can export directly the repository in the web server.
Note: if the web application works correctly, take note of the current repository version. in case of future problems you will be able to export that revision (svn client command line option) and restore the online web site.
Note: If you can install svn client in the web server and the repository is visible from the web server, you can use “check out” and “update” directly in the webserver, then use an apache rule to hide .svn directories
RewriteRule /.svn /errorpage