GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Synchronize filter help


#1

I've been using the synchronize function quite often of late, comparing directories that have been checked out of a Subversion repository. There are a number of subdirectories and other files that follow a well defined pattern that I'd like to exclude from the comparison.

Using a filter I've been able to exclude most of them, but the .svn subdirectories always seem to work their way back into the comparison no matter what I do with the filter. I've tried countless variations. Sometimes they work for a while, then I make a small change that shouldn't affect the .svn clause, and there come the .svn directories back into the comparison.

The closest I've come to what I want to accomplish is with using regex in the filter. Here's my latest attempt:

<?xml version="1.0" encoding="UTF-8"?> <filter desc="" name="xxx source"> <clause match="no" regexp="yes" type="name">.+\.(o|d|a|tar)$</clause> <clause link="and" match="no" regexp="yes" type="name">.+_proto.h$</clause> <clause link="and" match="no" regexp="yes" type="name">.+~$</clause> <clause link="and" match="no" regexp="yes" type="path">.*(\\?|/?)(1394|dalsa|bin|debug|\.svn)(\\|/).*</clause> </filter>

The last clause is the big one. It's supposed to exclude from comparison any path that has 1394, dalsa, bin, debug, or .svn as a directory element of the path. I used "(\?|/?)" because I sometimes do syncs via FTP with a unix box and I wasn't sure how it would report directory separators in the path. This should catch either slash character.

Any suggestions on how to make this work would be greatly appreciated.


Using Filter when synchronizing
#2

I think it's not working because the location won't match *.svn* unless the item in question is in a sub-folder below the .svn folder. Turn on the Location field in a lister to see what I mean:

C:\moo.svn\unwanted_file has location C:\moo.svn which does not match *.svn* because there's no \ on the end of it.

Try this regular expression instead:

.*(\\?|/?)(1394|dalsa|bin|debug|\.svn)(\\.*|/.*|)$

#3

That seems to work except for the case where the .svn directory structure does not exist in the target. In that case it wants to create/update the .svn structure regardless of being told to ignore it.

This seems to imply that it compares the structures/files first and then applies the filter rather than only doing the comparison if the file passes the filter. This fits with what I see flitting past on the screen while it's comparing files. I catch glimpses of "...base" every so often. I know the only "...base" files/directories involved are those under .svn folder.

It would seem a more efficient approach to apply the filter first, particularly if a byte comparison is being done. Though I suppose this view of "more efficient" might apply only to synchronize and not to other applications of the filters.

At any rate, thanks for the correction to my filter. This is a definite improvement over what I had before.


#4

If you don't need to delete old items from the destination, and don't need the operation to be interactive, you might find that the Copy UPDATEALL FILTER=youfiltername command works better.

With that command you should be able to use sub-folder clauses in the filter which will prevent the unwanted folders from even being looked in. (Unfortunately sub-folder clauses don't work with the Synchronize tool, but they do work with the Copy command.)

Having said that, I set up a quick test and seemed to get the Synchronize tool to ignore .svn folders using a simple filter. Below are the settings I used and results I got.

I added the first line of the filter (to exclude things named ".svn") just-in-case but it doesn't seem to be needed. (That's because the Synchronize tool only considered files and should ignore folders unless they contain a file that it's interested in.)




#5

Thanks, Leo.

It would sure be nice if the filter could be applied on the initial directory scan in addition to when files are compared. I just watched the message traffic of a sync with a FTP target and there was a TON of time effectively wasted on .svn directories which will eventually get filtered out. I realize some of the filter options (like 'contains') don't fit with a pre-comparison filter concept, but having the option to apply the filter up front would speed this up tremendously.

I've noticed others trying to accomplish effectively this same thing with SVN. Perhaps a special option on sync to ignore SVN files wouldn't be completely out of line.


#6

If you want improvements drop GPSoft a message.


#7

Hello,

What does *(.svn)(*|) mean?

I understand that the * are wildcardsand .svn is the name to be excluded.

What is ?
What is |?
What is ()?
How do I get into Regex in Filter?


#8

In the appendix at the back of the manual there's a page titled Pattern Matching Syntax which explains what ( ) | mean.

\ is just a normal file-path separator, when using pattern matching.

(When using regular expressions instead of pattern matching, \ is the escape character and you have to use \ to get a literal '')

Filter clauses that take wildcards have checkboxes which make them use regular expressions instead.


#9

Thanks Leo!