Dinah
Dinah

Reputation: 54017

Find files not added to subversion

The following issue is becoming increasing common:

Note: The image paths are both in code and in databases so it's not easy to get a full list of all used images.

My hope is to write a small C# program for everyone to run before deployment. I want to find out which files in the project directory (or one of it's subdir.s, recursively) have not been added to subversion. Ideally, I'd also like to exclude items which were actively added to the ignore list.

We're using TortoiseSVN with Windows host and clients.

How can I programmatically discover non-added files?

The closest thing I've been able to find so far is this saying to use svn status | grep -e ^? but this looks like a Unix command.

Upvotes: 20

Views: 25758

Answers (6)

Shirish Herwade
Shirish Herwade

Reputation: 11701

Also you can change one settings which will show folders having new added files as modified.

Settings->Icon Overlays->Show overlay for unversioned item

Right-click in folder, then navigate TortoiseSVN - Settings. Click on 'Icon Overlays'. On right-side check - 'Unversioned files mark parent folder as modified'

This works on windows7, not tried with other OS

Upvotes: 2

Jaime Soto
Jaime Soto

Reputation: 3228

This question is tagged as tortoisesvn so I assume your team is using TortoiseSVN as a client. As @Joe Enos suggested, TortoiseSVN displays the unversioned files that do not match the entries in svn:ignore. I wonder if adding another tool may help since the team should already be checking for unversioned files with TortoiseSVN.

Otherwise, a C# program seems like overkill for finding unversioned files in an SVN working directory. As @Josh Kelley suggested, you can just use a command-line SVN client (CollabNet or Slik SVN, for example) and grep.

You can also use the findstr command available in the Windows command line:

svn status | findstr "^?"

Upvotes: 11

Jeremy Friesner
Jeremy Friesner

Reputation: 73051

The code is compiled and deployed (sorry, no QA team)

Isn't this the real problem here? If you're shipping untested code to a client, then of course the first person to discover any problems will be the client. Perhaps (in addition to fixing this particular problem) what you need to do is add at least some basic automated (or manual) functionality testing into your build process, sometime between when the code is compiled and when it is handed over to the client.

Upvotes: 7

Josh Kelley
Josh Kelley

Reputation: 58352

You could install the CollabNet Subversion Command-Line Client, then run its svn command as a subprocess, pipe its input into your program, and search for lines that have ? as their first character (indicating unknown / not checked into Subversion and not ignored). You can use CollabNet's command-line client along with TortoiseSVN.

That's the same thing that svn status | grep -e ^? does, but it doesn't depend on Unix tools.

Alternatively, you could just install Cygwin and have the full range of Unix tools at your disposal.

Upvotes: 1

Sander Rijken
Sander Rijken

Reputation: 21615

You could use SharpSvn for this, and write something like:

SvnClient client = GetClient();

client.Status(workingCopyPath, (o, e) =>
{
    if(e.LocalContentStatus == SvnStatus.NotVersioned)
    {
        Console.WriteLine("Not versioned: " + e.FullPath);
    }
});

Edit: this will also respect your ignore file and svn:ignore properties.

Upvotes: 6

Ency
Ency

Reputation: 633

svn status | grep -e ^?

It's unix command, but I'm pretty sure, than if you execute commit from Tortoise, you are able to see new files with question mark, that are files which are not under svn control

Upvotes: 16

Related Questions