[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: RE: Seeking a way to do a full text search in a repository

From: Reedick, Andrew <jr9445_at_ATT.COM>
Date: Wed, 6 Feb 2008 12:08:54 -0600

> -----Original Message-----
> From: Reedick, Andrew
> Sent: Wednesday, February 06, 2008 12:22 PM
> To: Bicking, David (HHoldings, IT); users_at_subversion.tigris.org
> Cc: Kohlhepp, Justin (HHoldings, IT)
> Subject: RE: Seeking a way to do a full text search in a repository
>
>
>
> Some script based on running 'svn cat -r' on each file listed by 'svn
> log -v -r' followed by grep/findstr would be my guess.
>

Meh, since I've had to do this in the past, I might as well automate it.
Here's a crude python script (python is available from
www.activestate.com):

It simply generates a batch file containing one 'svn cat' per file
listed by 'svn log --xml -v'. It's not smart enough to distinguish dirs
from files, so you'll see 'svn cat' complain about directories.

1. svn log --xml -v -r 1:999 svn://server/repos/some/where | python
svn_search_hack.py > search.bat
2. Open search.bat in your favorite text editor
2.1 search & replace {REPOS} with 'svn://server/repos'
2.2 search & replace {REGEX} with your findstr search pattern and
switches.
3. search.bat > results.txt
4. ???
5. Profit!

svn_search_hack.py
==================
import sys
import xml.etree.ElementTree as ET

log = ET.parse(sys.stdin)
#log = ET.parse('log.xml')

for logentry in log.findall('logentry'):

    for path in log.findall('logentry/paths/path'):
        # we only want to cat added or modified files. No point cat'ing
deleted ones
        if path.attrib['action'] == 'M' or path.attrib['action'] == 'A':
            print 'svn cat -r %s "{REPOS}%s" | findstr {REGEX}' %
(logentry.attrib['revision'], path.text)

*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-02-06 19:09:24 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.