



There doesn't seem to be a nice, standalone work-alike of rsync for Windows users ( please post in the comments if you know of one! ) but that doesn't stop me from using rsync a lot on OS X and Linux, for all sorts of crazy things. Here's an example of a Macro I use when developing Komodo extensions that uses rsync.
The problem I'm solving is that, while developing an extension, it is much quicker to unpack the extension's jar file in the app extension directory and edit those files directly ( after tweaking chrome.manifest to point the app to the right place ). Once you get things working though, you'll want to sync any changed files from the extension install back to where your project lives.
if (isDryRun == 'Yes') {
cmd += " -n";
}
ko.run.runEncodedCommand(window, cmd);
var source_dir = '/path/to/source/directory/';
var target_dir = '/path/to/target/directory/';
var cmd = 'rsync -avz "'+source_dir+'" "'+target_dir+'"';
var isDryRun = ko.dialogs.yesNo('Dry Run?');
if (isDryRun == 'Yes') {
cmd += " -n";
}
ko.run.runEncodedCommand(window, cmd);The somewhat clever part of the above code is that it asks me if I want to do a dry run of the sync first. If I click 'Yes', the '-n' argument is added to the command to put rsync in dry run mode, allowing you to check what will be transfered by the operation.
Hey Jeff,
Good thread, very interesting. Just thought I'd comment on "There doesn't seem to be a nice, standalone work-alike of rsync for Windows users ( please post in the comments if you know of one! )". I think cwrsync at http://www.itefix.no/cwrsync/ is a pretty nice package for Windows. Interested in your opinion.
Cheers,
Stan
After some googling I came across this as well:
http://footboot.net/rsync-win/
Both seem to be essentially the same in that they take the necessary bits out of cygwin and package them separately. Cygwin kind of leaves a bad taste in my mouth personally ( never could quite get used to it ) but it is nice to see bits of it being hacked and and used separately, in particular for rsync.
So, if you adjust my code above to work on windows, does it work?
--
JeffG
The rsync stuff is extremely useful, however, at the MozCamp we had last weekend, we learned something neat. Instead of copying the files to the extension directory, you can just make a file that points to the location of your dev directory. If your extension directory name would normally be "myextension@foo.com" then you create a file with that name instead, and the contents is the path to your development directory. No rsyncing necessary :)
Not sure I understand, do you mean a symlink?
--
JeffG
SIMPLY AMAZING! I just tried this for an extension I am working on. In my install.rdf file I’ve got “snippets@psp-webtech.co.uk†as my extension ID. I uninstalled my extension from Komodo’s Extension Manager. Then went on and created a blank file “snippets@psp-webtech.co.uk†under my profile’s extension directory (in my case “C:\Documents and Settings\Stanimir Angeloff\Application Data\ActiveState\KomodoEdit\4.3\host-psp-stan\XRE\extensionsâ€). Then on the first line of this file I put “D:\Workspace\htdocs\komodo\xpi\src†where my extension is. I had to make a few changes to my chrome.manifest file and now it’s all working. Beautiful.
I found more information here under “pointer fileâ€: http://kb.mozillazine.org/Getting_started_with_extension_development
Jeff: I am sorry, but I haven’t tried the rsync module under Windows yet. I will update this post once I manage to get around it.
shanec: You are a star! Thank you.
Just tried it too, works like a charm!
Stan: will need to cook up some better use of rsync as an example. The obvious use would be rsyncing your local project files to a remote server?
--
JeffG
I have just tried your macro and it works with a couple of changes applied in my case.
Here is a list of suggestions:
- I prefer using the long options format, so I have replaced “-avz†with “--archive --verbose –compressâ€
- I have subdirectories in my project root, so I had to add “--recursive†to sync those as well.
- When updating the remote server, I usually keep the timestamps synced as well, add “--timesâ€.
- If you would like to sync removed items, add “--deleteâ€. In my case I have renamed a couple of folders so it’s worth turning this on by default.
- If you are syncing between two *nix station you may want to preserve the executable attribute, add “--executabilityâ€.
- Optionally --owner, --group, --devices, --specials are useful in a *nix environment.
For some reason cwrsync doesn’t report the progress on my machine, so I had to add one more option “--progressâ€. So my final command line looked something like this:
rsync --archive --verbose –compress --recursive --times --delete –progress {...} {...}Thanks for the idea Jeff. This will save me a lot of time going in and out of my FTP proggy. Cheers.
I was thinking of maybe creating an rsync extension that encapsulated a lot of those options in some sort of UI. Another thing it could do is package cwrsync or similar ( seeing as cwrsync is under all open licenses ) for Windows systems. unsure how the UI would be expressed, maybe as a dialog that can be fired from an 'rsync' project template?
It would also be great to set --exclude patterns, and also force the -n so you could throw up a confirm dialog that shows a nice list of the affected files.
--
JeffG
This definitely sounds like a killer feature to me. I do a lot of deployments on staging and live servers and as the projects grow they become almost impossible to manage just by FTP-ing changes over. Rsync is a great idea, but having to deal with command line tools is not my way of doing things. However if this is integrated in the IDE and doesn’t require much effort to set up and manage then I’d say we’ve just made Komodo the best IDE out there. Here’s how I picture things working, these are just ideas so everyone’s welcome to comment on them:
I like the way Komodo is handling remote files in the toolbox / project pane. You go about setting up an FTP connection which later on is made available in a drop down list. If we follow the same approach here, I would go about setting up an rsync connection to a staging server. When a new project is created inside Komodo ideally under the Project’s configuration another option will appear on the left – “Publishing†or similar. All previously created rsync connections will be listed in here along with options, such as the target folder, exclude/include patterns, rsync options (–times, –recursive, etc.). When right clicking on a folder another menu item will appear “Publish†and under it we’ll have “Push changes†and “List changesâ€. The former will run rsync in live mode, pushing the changes to the selected server and target directory, showing any progress in the output pane. The latter will do a dry run and will list the changes in a new dialog with options to turn certain files/folders on/off.
I know all this involves huge amounts of work, but nevertheless it’s nice to just imagine it working inside of Komodo.
Hope this makes sense,
- Stan