VC API: CheckIn() may return 0

Back in March, I wrote a post called How to check in changes on behalf of other users.  Among other things, you'll find the documentation comments for the Workspace.CheckIn() method, which you'll notice is now on MSDN.  While that and How to validate check-in policies, evaluate check-in notes, and check for conflicts are probably the best documentation on how to use CheckIn(), I didn't mention that CheckIn(), which returns the changeset created by checking in, may return 0.

The version control server automatically undoes the pending changes in the case where you attempt to check in files that haven't changed rather than create new versions of them.  In the extreme case, CheckIn() will return 0 when all of the changes being checked in are edits without content changes or locks.  Nothing bad happened, but the server did not create a changeset.  If something bad happened, such as having one or more conflicts, CheckIn() will throw an exception.

The CommitCheckinEventArgs object, available by listening to the VersionControlServer object's CommitCheckin event, contains the list of files that were actually checked in (Changes) and the files that were undone (UndoneChanges).

tags: , , ,

Comments (8)

  1. Grant Holliday on Launched.

    Buck Hodges on VC API: CheckIn() may return 0.

    Martin Woodward…

  2. On the Microsoft forums , that is…no, I didn’t suddenly eclipse Raymond . As you probably haven’t noticed,

  3. Buck Hodges says:

    Periodically, the topic of keyword expansion comes up, which TFS (at least through 2008) does not support.

  4. Periodically, the topic of keyword expansion comes up, which TFS (at least through 2008) does not support

  5. Jacob says:

    Is there a way to FORCE an unmodified file to be checked in? This way you know whomever gets the changeset will also get this "unmodified" file.

  6. buckh says:

    Jacob, no there is not.  You must make some change, even if it is only adding a space.


  7. burton says:

    i’m trying to handle the CommitCheckin event in a VSPackage, but Visual Studio crashes after running my event code.  i’ve posted in the forums but noone is responding.  can you point me in the right direction?

  8. buckh says:

    Burton, I’d suggest connecting a debugger to VS and getting a stack trace.  You may be accessing a field that is null.


Skip to main content