Lo and behold, this past Wednesday, after waiting all day for the Drupal 6.4 update that was rumored to be coming out, it finally was released at around 6:30pm MDT. We saw it at the DBUG Meetup during setup, and I knew that once again it was time to do some updating. At pingVision, we have an entire dev/test/production process for all of our clients' and our own sites. But when it comes to my own sites, I prefer to do it myself as much as possible so that I can keep my fingers in code and configuration, even while my more official presidential responsibilities tend to pull me in other directions.
And yet my own sites are still under Subversion, so it's not just a matter of uploading the new code and being done with it. No, I have to do it through SVN.
Now if you are like me (and unlike our developers), and have a general preference for a good GUI over using the command line, and are working on OS X and using version control like Subversion, then you likely have run into the problem that the architects of Finder have not deigned to solve: You cannot "merge" folders in OS X using Finder. No, Finder will overwrite folders completely.
Why is this a problem? Anyone who uses Subversion (or other version controller) will know what I'm talking about: If you try to just overwrite wholesale a folder that's under version control, you end up deleting the hidden .svn folder, which has the versioning information. And that leads to Dante's SVN Inferno, where all sorts of error demons torment you while you wail with pangs of regret: Oh, why didn't I merge that folder instead of replacing it?
Using Unix command line, you can of course use mv -v to merge folders, but that forces you to use command line. Since OS X is built upon Unix, I and many others wonder why Finder does not offer this option, not even with contorting combinations of control, option, command and shift.
It's ridiculous. –Especially when you consider that your basic (s)ftp applications can merge folders without a problem. This isn't rocket science.
A trick to merge folders on Mac I figured out a couple of years ago (when I was first introduced to SVN workflows) is this: ftp from your computer to your computer, using your favorite ftp application.
That's right, rather than copy or drag files from folder to folder using Finder, you drag files from folder to folder using ftp. (I use Transmit, but this will work with any ftp app that can merge folders. A free one I can recommend is Cyberduck.)
To enable this approach, all you need to do is turn on ftp access in OS X.
You do this in Preferences -> Sharing.
Click the checkbox to enable "file sharing".
Then, with the file sharing option highlighted, as pictured, click on the Options button down in the lower right-hand area of the window.
This reveals the kinds of file sharing you want to enable, and one of them is ftp. Enable that.
Underneath you will now see a message that provides the IP address where your computer can be reached. You just enter that IP address into your ftp app as the remote server. You may need to enter your username and password for your Mac.
That's it. Now just drag folders over from your desktop into the appropriate area on your ftp app and the merge will happen.
Note: Depending upon the ftp app, you may need to set appropriate preferences to merge folders. Here are the settings I use in Transmit:
This way you can maintain your website in a dev environment on your Mac desktop or laptop, and manage updating tasks easily without having to do SVN gymnastics or work in Terminal.
I welcome your comments.
- Tags: Subversion, development, Drupal, Mac, OS X, tips and tricks








Comments
Jacques writes:
I'm a Macintosh user since forever and it's just recently that I've been introduced to the "Merge" vocabulary other Drupal user takes for granted.
I never quite understood the need for merging. But since I'm doing more and more Drupal development, now I understand the need for merging.
Thank you very much for your clever solution through FTP.
nev writes:
merging folders have ALWAYS been my expectation.
I just set up my laptop for my dad to use with Leopard, and lo and behold, I found out OSX doesn't merge the items in the folders.
It basically deletes the older one it's copying over. This is HORRIBLE. As I was organizing folders whom my dad accidentally made copies of and edited in multiple areas. After I dragged it over the folder... thinking it would ask me to replace old/new files within.. but I found out later the folder shrunk in size! Lucky I had a backup on network.
Imagine if somebody dragged the "DCIM" folder from their camera's memory card... or even just the subfolders separately... they'd be in for a shock. @_@
jay writes:
I discovered this the hard way when making my first real consolidated backup off my iMac. I had about 10 years of file history in my "my documents" folder and needed to merge the version from my prior computer with the updates from my new computer... so I did what I'd have done on Window, drag the newer folder over the older folder and drop... all my old files gone.. and no undo, not in trash, just unrecoverably and instantly gone.
I sadly offloaded my backup onto my ipod and the next time I encountered a similar need, I faced having to either individually pull one file at a time from hundreds of folders, or mount the drive over the network from a PC and deal with ethernet lag. Took me 8 hours to consolidate a 4 gig folder.
This solution of using FTP clients is really a cludge too... but I suppose it's the best we've got. Between weird finder behaviors (this and permissions/sharing) and basic missing iphone features (copy/paste, save files, and tethering)
All in all I may be forced to give up the many things I really love about Apple, on account of the fact that they seem completely unconcerned with the "needs" of users like me.
nev writes:
It's Steve Job's ways of simplifying and reducing clutter @_@ :rolleyes: ....
Maybe he finally lost a bunch of stuff just like us... so there comes the "time machine" function! hehehe
Andrew writes:
If you use Eclipse for development, then you can drag folders in and it will merge them like Windows Explorer. I imagine other cross-platform IDE's will do the same.
However, there's still the problem of upgrading code, and finding files which have been *removed*. I usually just end up using the shell (find + diff), but I haven't found a good GUI option for for upgrading large Drupal installs.
K.Barron writes:
Laura,
Have you seen the filemerge utility that is kept hidden in /Developer/Applications/Utilities ?
Provides a nice interface to diff'ing and merging files *and* folders - might save you some grief.
Laura writes:
FileMerge was the first thing I tried, and I even tried it again before writing this post in hopes that the Leopard version offered more usability, but it's a rather opaque kind of interface, and this last time I ran into file permission problems -- strangeness. Anyway, it is helpful for seeing what is dropped/deleted. But since the file merging I do is via SVN, most of its features are overkill for me.
veggieryan writes:
I also use SyncDifferent for such feats.
Nice interface.
christefano writes:
For those of you using Path Finder instead of the standard Finder, please vote for the file merging feature at http://feedback.cocoatech.com/pages/gene...
Tj writes:
Blah! Finally getting sick of a non *nix based local enviro so I am switching over to Mac. I am really disappointed with alot of these tools, I miss having EVERYTHING in one package, debugger, terminals, ftp/sftp/ftps, svn and cvs support etc etc.
It really is to bad tortoiseSVN is not available its such a great application. Eclipse is what I have stuck with for now even though its deathly slow :(
drifteaur writes:
That's why I revert to Midnight Commander - a good old Norton Commander lookalike that you can install from MacPorts for instance (port install mc). It does merges just fine.
lemp writes:
Have a look at Changes (http://changesapp.com/). You can use it to merge folders AND files.
Duncan Babbage writes:
What a great tip! Thanks for that idea—I'd struggled with the same thing myself but didn't come up with this nice solution. My copy of Transmit is now reconfigured for an additional purpose. :)
FolderMergin'Guy writes:
Here's a tiny GUI AppleScript called Merge Folders 1.0.1; it's freeware I've found that seems to do exactly what everyone is asking for, if I understand correctly.
It uses the UNIX cp command, so it ends up acting just like a "normal" OS in the sense that it just merges multiple folders together, maintaining the structural integrity of all sub-folders, and not overwriting files with the same name. I was very surprised to find it, because it works wonderfully. It's got a GUI, and it presents you with a browse dialog asking for the source folder(s). You don't have to browse, though; you can just drag the source folder(s) into the browse dialog. Then it asks for a destination; again, just drag the destination folder. It then asks what to do about existing files: Overwrite, Cancel, or Skip? Hit "Skip"; you now have a merged folder in the destination. All sub-folders and directory structures seem to be maintained perfectly.
Here's the link; just click the link to "Merge Folders 1.0.1" to download once you get to the page:
http://scriptbuilders.net/files/mergefol...
Since it's freeware I'm assuming the author won't mind my posting the script here; his name is Bruce Philips and his website is http://brucep.net/
And here's the script:
on run
choose folder with prompt "Get contents of these folders:" default location (path to home folder) ¬
with showing package contents and multiple selections allowed
open (result)
end run
on open droppedItems
choose folder with prompt "Merge into this folder:" default location (path to home folder) ¬
with showing package contents
set target to quoted form of POSIX path of result
display dialog "How to handle existing files?" buttons {"Overwrite", "Cancel", "Skip"} default button 3
if (button returned of result) is "Overwrite" then
set overwriteOption to "f"
else
set overwriteOption to "n"
end if
repeat with thisItem in droppedItems
if (folder of (info for thisItem without size)) is true then
get quoted form of POSIX path of thisItem
try
do shell script "cd " & result & "; /bin/cp -RP" & overwriteOption & " ./* " & target
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "OK" default button 1 with icon caution
end try
end if
end repeat
display dialog "Script finished." buttons "OK" default button 1 with icon note
end open
Paul Skolnick writes:
I'm a little late to this thread, but the biggest problem with the FTP solution seems to be that all folders (and the files within them) take on the date of the FTP rather than keeping the date they had in the archive.
That seems to be a horrendous problem if what you're trying to do is create and periodically update folders for archival or backup purposes.
Laura writes:
Good point. I've noticed that MobileMe re-sets the date of the files as well, which is very annoying.
There's a setting in many FTP applications to keep the source file's date/time. I don't see it in Transmit, but I believe that was an option in Cyberduck (which also is open source and free).
Anonymous writes:
I use windows for this. It's easy, drag a same named folder on top of a folder and "replace". There are some little things Apple really needs to get a clue about.
Anonymous writes:
I believe the cli app ditto does this. According to Apple, their implementation of ditto defaults to preserve extended attributes (be cautious- many apps don't preserve the extended attributes) and resource forks. So a ditto command between the two folder contents should do the trick:
>> ditto myfirstfolder/folder1 ~/folder2
in the above instance I'm moving/merging the contents of folder1 into folder2. In the default mode, this will copy anything within folder1 into folder2 (if you want, folder1 can have the same name in both cases, "~/folder1" in the example above- I don't think ditto cares). It will overwrite anything already there, but will keep anything in folder2 that isn't in folder1. In this way, it will merge the contents. I believe there's also a flag to overwrite only if new, or to ask for overwrite. Check out "man ditto" at the command line.
Hope this helps a bit,
-Allen
KWarp writes:
Thanks for suggesting the FTP work around. I used Transmit's Syncronize feature to update a few hundred files in a directory structure and it worked flawlessly.
Post new comment