Find files not added to subversion
Solution 1
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.
Solution 2
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
Solution 3
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 "^?"
Solution 4
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.
Solution 5
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.
Related videos on Youtube
Comments
-
Dinah almost 4 years
The following issue is becoming increasing common:
- There are several developers working on a project which includes new files (usually images)
- Everyone says that everything is checked in and we freeze development. Unbeknownst to us, there are images which were not checked in. The user doesn't notice the missing files because they're new, not check-outs, so svn looks fine
- The code is compiled and deployed (sorry, no QA team)
- The next day the client tells us about the missing images
- The CTO reads us the riot act
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.-
Joe Enos over 13 yearsNot an answer, but when I commit via Tortoise, I always have the "Show unversioned files" box checked. This shows every file in the directory that hasn't been added yet, and reminds me to check them in. Stuff that you want to ignore (.suo, .user, ReSharper files, etc.) can be ignored one time, and it will prevent this from uglying up the diff data, leaving only true non-checked-in files.
-
Nikola Smiljanić over 13 yearsIt sounds like a people problem to me. "Everyone says that everything is checked in" is not enough, next person to break the build should pay 10$ (piggy bank for the team). Creating a tool to check if another tool is used correctly sounds very wrong.
-
doug65536 over 11 yearsNo matter how hard we try, we are going to break the build at least sometimes. (Trying so hard that we NEVER break it is a waste of time). This is good question because in my experience, the #1 checkin mistake is missing new files.
-
Shirish Herwade over 8 years@JoeEnos in our case, '"Show unversioned files" box checked' never showed new files that are not added. We used 'TortoiseSVN 1.8.0, Build 24401 - 64 Bit , 2013/06/17 18:15:59 Subversion 1.8.0, -release on windows7' with UI
-
Joe Enos over 8 years@ShirishHerwade It's been awhile since I've used SVN, but I wouldn't expect that behavior to have changed. My best guess would be those missing files are already in your ignore list.
-
Sander Rijken over 13 yearssearching for files with question mark in Tortoise isn't a programmatic solution to the problem.
-
Dinah over 13 yearsI certainly can't argue with you here but my power in this matter is extremely limited.
-
Dinah over 13 yearsThanks for the tip. This library looks it could be exactly what I need. Because of its terrible lack of documentation or examples I can't figure out how to use it but I'll keep playing around with it.
-
Danny Parker almost 12 yearsThe findstr trick is excellent! Thanks to you I now have a batch file that can tell me every file that has been added or deleted between certain revisions.
svn diff -r REVNO:HEAD --summarize | findstr "^A" > AddedFiles.txt
svn diff -r REVNO:HEAD --summarize | findstr "^D" > DeletedFiles.txt
Just change REVNO and HEAD to whatever range you like. Thanks to this page too: muffinresearch.co.uk/archives/2008/09/15/… -
doug65536 over 11 yearsYour developers are suffering when they don't have tests. Tests give you freedom from fear of touching things.
-
Rob about 11 yearsFound this helpful regardless!
-
HaBo about 8 yearsI ran this command nothing shows up svn status | findstr "^?"