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

RE: identify deleted file

From: Rob Hubbard <rob.hubbard_at_softel.co.uk>
Date: Thu, 30 Oct 2008 09:43:56 -0000

Hello Vinay,

> >>> On Wed, Oct 22, 2008 at 1:58 PM, vinay i wrote:
> >>>
> >>> > Is there any command to identify whether a file actually
> >>> existed and has now
> >>> > been removed from subversion.

The question was sent quite a few days ago,
so it might be too late for the reply to be useful to you.

I'm afraid this isn't a full solution,
but some ideas that I hope might help.

[BTW, I do my work in a Windoze environment,
but use "Cygwin" for easy access to a decent shell (e.g. bash),
and command-line tools.
The grep and other programs used below are available
in Linux and Cygwin.]

All I can suggest is to run
        svn log --verbose [--xml] [URL] -r[REV]:[REV] > [my_file]
On the required URL and revisions (or dates), e.g.
        svn log --verbose http://repos/ -r1:HEAD > my_log.stdout.txt

It's probably best to redirect the output to a file like this,
so that you can experiment with the next bit...

Then "grep" the result; do something like this:
        grep --line-number "^...D \(/.*\)\?/del_fname[.]ext$" my_log.stdout.xml
or just
        grep --line-number "^...D .*del_fname[.]ext" my_log.stdout.xml
assuming you're searching for a deleted file named "del_fname.ext".

(You might need to execute
        dos2unix my_log.stdout.xml
first, to make grep happier with the line ending characters.
If fact, you might prefer to run that command on a *copy* of that file.
Alternatively, use the weaker "\>" rather than "$" in the regex.)

The outputted line number(s) will allow you
to find the entry in the (probably huge) log file.

Possibly, it's better to use the --xml switch, e.g.
        svn log --verbose --xml http://repos/ -r1:HEAD > my_log.stdout.xml
if you're going to analyse the result with e.g. a Python script.
Then you'll want to look for the 'action="D"' string
perhaps using (importing) e.g. Python's regex module "re" or,
much better, "action" attribute with value "D" on a "path" element
using (importing) e.g. Python's "xml.dom" module.

(It so happens that the filename and action can be on the same line.
I don't know if they always are, but that might not be guaranteed.
It would be better to use DOM than do na´ve string searches;
that way, you also get easy access to the other log information
associated with the file deletion, such as the revision number,
commit comment, username, and so on.)

You may also/instead wish to use the Python bindings "pysvn".

In this way, you can find the URL and revision number of all
deleted files with a certain filename (which might not be known exactly)
below a given directory in the repository (possibly its root),
and between given revisions (possibly all) or dates.

(Given the revision number at which a file is deleted,
you can "peg" that file using that revision minus one.)

I hope this helps.


Rob Hubbard.

This message has been independently scanned for the Softel Group and cleared of containing viruses and other malicious data.

Powering Television Beyond the Video (TM)

To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-10-30 10:44:20 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.