Functions/Test-HgDirState.ps1


function Test-HgDirState
{
    <#
    .SYNOPSIS
    Tests if a repository's dirstate is OK.
 
    .DESCRIPTION
    Sometimes, when a repository's dirstate gets corrupted, Mercurial will think it is tracking files that it really isn't. This function compares what Mercurial expects to be tracking with what Mercurial is actually tracking, and returns any files it thinks it is tracking but it really isn't.
    #>

    [CmdletBinding()]
    param(
    )

    Set-StrictMode -Version 'Latest'

    hg debugcheckstate

    <#
    # This code does an actual comparison of the manifest and output of hg st to determine the state of the dirstate.
    # If debugcheckstate doesn't work, try this.
    $manifest = New-Object 'Collections.Generic.HashSet[string]'
 
    $status = New-Object 'Collections.Generic.Hashset[string]'
 
    hg manifest |
        ForEach-Object { $_.ToLowerInvariant() } |
        ForEach-Object { [void]$manifest.Add( $_ ) }
 
    hg status -n -m -c |
        ForEach-Object { [void]$status.Add( ($_ -replace '\\','/') ) }
 
    $status |
        Where-Object { -not $manifest.Contains( $_.ToLowerInvariant() ) }
    #>


}