Sync

Published October 07, 2009
Advertisement
Took a quick break from Squishy tonight to develop a new command line tool.

Basically I've given up on SVN as I found it overkill for a solo developer working on two machines on a home network, plus having to manually remove files from the repository and manually add new ones was becoming a pain.

I then got sick of having to copy over the entire projects for Squishy and Squed to the laptop and back, especially since this is now a twice-daily chore since the weather is on the turn to winter and I'm taking my laptop into work to do some development at lunchtime.

So I've spent this evening writing a little utility called sync. You start in the root directory of your local copy and create a .sync file that contains the path to another copy.

When you want to update, you open a command prompt pointing at the root directory of the local structure, then just type "sync".

sync then builds a list of all the files and directories in the local structure and in the other structure, then takes the following steps:

1) Sort the contents of the two structures by path length, longest first
2) If a file is in the local copy but not the remote copy, delete it
3) If a directory is in the local copy but not the remote copy, delete it
4) Sort the contents of the two structures by path length, shortest first
5) If a directory is in the remote copy but not the local copy, create it
6) If a file is in the remote copy but not the local copy, copy it over
7) If a file in the remote copy has a last-modified date more recent than its partner in the local copy, overwrite the local file with the remote version

In other words, convert the local structure into an exact copy of the remote structure, but by only making the changes that are actually necessary.

sync ignores all files that start with a dot, so the .sync files and any other files I may need to have unaffected are left alone.

The sorting is to ensure that we only ever remove empty directories and we only ever create files or directories in parent directories that already exist, simplifying the process a little.

Obviously it performs no version control, but I wasn't using SVN for that anyway, just to automate only having to network-copy files when I needed to. But SVN would not automatically remove and create files and directories as needed, or deal with file renaming.

This is really designed very specifically for a solo developer to work on more than one machine, accessible by a local network (i.e. normal file paths, not urls) where you don't want to merge two versions but only ever one-way-update one version to another.

Have theory-tested it but wouldn't call it field-tested yet. Happy to release it if it is of use to anyone else.
Previous Entry Small cog in a big wheel
Next Entry Website
0 likes 4 comments

Comments

benryves
I'd have to most respectfully disagree with you - version control has been an absolute lifesaver for me, even when working on personal projects on a single machine. [smile] When a bug crops up that I hadn't noticed before I can roll the code back to a previous date easily then work forwards until the bug reappears, at which point I can see exactly what was changed and why there is now a problem. (Maybe I'm just more of an error-prone programmer than you are, of course). [wink] Adding and removing files is not much of an effort, either, if you're using a shell extension like TortoiseSVN.

The sync tool sounds very useful, but I'm not sure how much it does that isn't already covered by the built-in robocopy tool. I suppose, at least, that you can always customise your own implementation further down the line!
October 09, 2009 07:38 AM
Aardvajk
Quote:Original post by benryves
The sync tool sounds very useful, but I'm not sure how much it does that isn't already covered by the built-in robocopy tool. I suppose, at least, that you can always customise your own implementation further down the line!


Damnit - I knew that there would be a tool like that I'd never heard of. Oh well, it kept me occupied for an evening [smile].

First time sync craps out on me, instead of debugging it I'll investigate robocopy. Presumably copying is a disease and this is the cure?
October 09, 2009 10:38 AM
Demosthenes
You may also want to try Windows Live Sync.
October 13, 2009 08:55 AM
spliter
That idea about making the program automatically copy the folders is excellent!
Thanks to this journal post I have now a semi automatized backup and conversion of my assets!
Thank you so much for the Idea!
October 24, 2009 09:43 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement