Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Rob McBroom <textmate-pGZRK53tQFdBDgjK7y7TUQ <at> public.gmane.org>
Subject: working with "remote projects"
Newsgroups: gmane.editors.textmate.general
Date: Thursday 12th April 2007 18:06:44 UTC (over 10 years ago)
Inspired by a [recent thread][1], I've come up with a couple of  
commands to facilitate using TextMate's project features on a remote  
directory. To sum up, the problem is: I want to work with files in a  
TextMate project from the local filesystem (for speed, Subversion  
compatibility, and other reasons), but the files I'm working on are  
useless unless they're on some remote machine.

I say "remote projects" in quotes because the project is actually  
local, but created from a directory that is intended to be an exact  
copy of one from a remote machine. The commands are similar in spirit  
to some of Dreamweaver's "Site" features, for those who care about  
such things. I've been using these commands pretty heavily on a  
project at work and am pleased with the results, so I thought I'd share.

The two commands are "Get Remote Project" and "Upload Project  
Changes". The commands have a global scope (ideally, they would be  
scoped to "files that belong to a project", but I don't know if  
that's possible). They essentially save all files and call `rsync - 
au` on your directory in different directions. The basic process is  
that you create a project in TextMate from a local directory, then  
set a variable in that project called `WHERE_I_CAME_FROM` that  
contains a location rsync understands, like `[email protected]:/remote/ 
path`. When you're ready to see the changes on the server, use the  
"Upload Project Changes" command.

## Setting up a project

Here are two ways to set up such a project:
(Note the trailing / on the rsync "source" path. It matters.)

   * Get the files and create the project

       1. Make a local copy

             mkdir foo
             rsync -au [email protected]:/remote/path/ foo

       2. Open the directory as a project in TextMate

             mate foo

       3. Set `WHERE_I_CAME_FROM` in the project to `[email protected]:/ 
remote/path/`
       4. Save the project

   * Create the project and get the files

       1. Create and open the project in TextMate

             mkdir foo
             mate foo

       2. Set `WHERE_I_CAME_FROM` in the project to `[email protected]:/ 
remote/path/`
       3. Run the "Get Remote Project" command (currently ⌃⌘P)
       4. Watch your files appear in the drawer
       5. Save the project

I prefer the second method right now, but if the final two steps in  
the first method could be automated (set a project variable and save  
the project), the whole process could be turned into a shell script,  
or possibly a command in TextMate.

## Subversion

I haven't had any issues using this method when the remote directory  
in question is a Subversion working copy. You basically end up with  
another working copy (and it's normal with Subversion to have working  
copies spread everywhere, so this is no big deal). I've been doing  
commits and other modifications to the working copy locally and have  
had no issues using rsync to update the remote side afterward  
(although, theoretically, you could acheive the same thing by running  
`svn update` on the remote copy).

## Outstanding Issues

   * Deleted files

     If you delete a file from your disk/project, the deletion won't  
be replicated. You need to either remove the file in both places  
manually, or if using Subversion `svn update` the other end after the  
removal has been committed to the repository. There is a `--delete`  
option in rsync, but I consider it too dangerous to be on by default.

   * Keyboard Shortcut

     ⌃⌘P wasn't my first choice. I'm open to suggestions.  
According to the manual, project related shortcuts should use ⌃⌘,  
but I don't think this has been stricly followed which made it hard  
to find something. There are other commands using ⌃⌘P and since  
they have a more specific scope than these "remote project" commands,  
they will win in those scopes.

     As for overriding ⌘S to run these commands, that would be  
convenient in many situations, but innappropriate in most. The  
commands really only need to be used if you're in a project and  
`WHERE_I_CAME_FROM` is set, so it wouldn't really be appropriate to  
have ⌘S trigger them unconditionally as they currently exist.

   * Extended Attributes

     If you're going from Mac to Mac, you might consider adding the - 
E option to the rsync command to be sure metadata is included. It's  
not there by default because most of my remote machines are running  
Solaris and -E makes rsync on Solaris poop in its pants. Perhaps  
there should be another variable that could be set in TextMate or a  
specific project that holds your preferred rsync options for these  
commands.

   * Project variable name

     I'm sure I should use something more grown-up sounding than  
`WHERE_I_CAME_FROM` in the long run, but what? I didn't see any  
naming conventions for project variables in the manual. Are `TM_*`  
variables meant to be only things that the application is aware of or  
should all TextMate specific variables start with that?

## Other commands?

I've thought about adding a TextMate command that will do an `svn  
update` on the remote path. This would be for deleted files or for  
people who aren't comfortable updating the various `.svn` directories  
using rsync (I know you're out there).

I've also considered adding a command that will run `rsync -aun` in  
both directions to show you what will happen if you run one of the  
commands without actually making the changes. Would either of these  
be useful?

If you have need for something like this, try these commands out and  
let me know what you think. Thanks.

[1]: http://thread.gmane.org/gmane.editors.textmate.general/18573

---
Rob McBroom
<http://www.skurfer.com/>
I didn't "switch" to Apple... my OS did.
 
CD: 3ms