Anton Afanasyev avatar Anton Afanasyev committed 13dd9f6

Changed all references to hg to vv. Lots of hg-specific (and all of thg0specific) functions obviously dont exist in vv, so im sure half of this wont work just yet

Comments (0)

Files changed (12)

HgPrompt.ps1

-# For backwards compatibility
-$global:HgPromptSettings = $global:PoshHgSettings
-
-function Write-HgStatus($status = (get-hgStatus)) {
-    if ($status) {
-        $s = $global:PoshHgSettings
-       
-        $branchFg = $s.BranchForegroundColor
-        $branchBg = $s.BranchBackgroundColor
-        
-        if($status.Behind) {
-          $branchFg = $s.Branch2ForegroundColor
-          $branchBg = $s.Branch2BackgroundColor
-        }
-       
-        Write-Host $s.BeforeText -NoNewline -BackgroundColor $s.BeforeBackgroundColor -ForegroundColor $s.BeforeForegroundColor
-        Write-Host $status.Branch -NoNewline -BackgroundColor $branchBg -ForegroundColor $branchFg
-        
-        if($status.Added) {
-          Write-Host " +$($status.Added)" -NoNewline -BackgroundColor $s.AddedBackgroundColor -ForegroundColor $s.AddedForegroundColor
-        }
-        if($status.Modified) {
-          Write-Host " ~$($status.Modified)" -NoNewline -BackgroundColor $s.ModifiedBackgroundColor -ForegroundColor $s.ModifiedForegroundColor
-        }
-        if($status.Deleted) {
-          Write-Host " -$($status.Deleted)" -NoNewline -BackgroundColor $s.DeletedBackgroundColor -ForegroundColor $s.DeletedForegroundColor
-        }
-        
-        if ($status.Untracked) {
-          Write-Host " ?$($status.Untracked)" -NoNewline -BackgroundColor $s.UntrackedBackgroundColor -ForegroundColor $s.UntrackedForegroundColor
-        }
-        
-        if($status.Missing) {
-           Write-Host " !$($status.Missing)" -NoNewline -BackgroundColor $s.MissingBackgroundColor -ForegroundColor $s.MissingForegroundColor
-        }
-
-        if($status.Renamed) {
-           Write-Host " ^$($status.Renamed)" -NoNewline -BackgroundColor $s.RenamedBackgroundColor -ForegroundColor $s.RenamedForegroundColor
-        }
-
-        if($s.ShowTags -and ($status.Tags.Length -or $status.ActiveBookmark.Length)) {
-          write-host $s.BeforeTagText -NoNewLine
-            
-          if($status.ActiveBookmark.Length) {
-              write-host $status.ActiveBookmark -NoNewLine -ForegroundColor $s.BranchForegroundColor -BackgroundColor $s.TagBackgroundColor 
-              if($status.Tags.Length) {
-                write-host " " -NoNewLine -ForegroundColor $s.TagSeparatorColor -BackgroundColor $s.TagBackgroundColor
-              }
-          }
-         
-          $tagCounter=0
-          $status.Tags | % {
-            $color = $s.TagForegroundColor
-                
-              write-host $_ -NoNewLine -ForegroundColor $color -BackgroundColor $s.TagBackgroundColor 
-          
-              if($tagCounter -lt ($status.Tags.Length -1)) {
-                write-host ", " -NoNewLine -ForegroundColor $s.TagSeparatorColor -BackgroundColor $s.TagBackgroundColor
-              }
-              $tagCounter++;
-          }        
-        }
-        
-        if($s.ShowPatches) {
-          $patches = Get-MqPatches
-          if($patches.All.Length) {
-            write-host $s.BeforePatchText -NoNewLine
-  
-            $patchCounter = 0
-            
-            $patches.Applied | % {
-              write-host $_ -NoNewLine -ForegroundColor $s.AppliedPatchForegroundColor -BackgroundColor $s.AppliedPatchBackgroundColor
-              if($patchCounter -lt ($patches.All.Length -1)) {
-                write-host $s.PatchSeparator -NoNewLine -ForegroundColor $s.PatchSeparatorColor
-              }
-              $patchCounter++;
-            }
-            
-            $patches.Unapplied | % {
-               write-host $_ -NoNewLine -ForegroundColor $s.UnappliedPatchForegroundColor -BackgroundColor $s.UnappliedPatchBackgroundColor
-               if($patchCounter -lt ($patches.All.Length -1)) {
-                  write-host $s.PatchSeparator -NoNewLine -ForegroundColor $s.PatchSeparatorColor
-               }
-               $patchCounter++;
-            }
-          }
-        }
-        
-       Write-Host $s.AfterText -NoNewline -BackgroundColor $s.AfterBackgroundColor -ForegroundColor $s.AfterForegroundColor
-    }
-}
-
-# Should match https://github.com/dahlbyk/posh-git/blob/master/GitPrompt.ps1
-if (!$Global:VcsPromptStatuses) { $Global:VcsPromptStatuses = @() }
-function Global:Write-VcsStatus { $Global:VcsPromptStatuses | foreach { & $_ } }
-
-# Add scriptblock that will execute for Write-VcsStatus
-$Global:VcsPromptStatuses += {
-    $Global:HgStatus = Get-HgStatus
-    Write-HgStatus $HgStatus
-}

HgTabExpansion.ps1

-$script:hgCommands = @()
-
-function HgTabExpansion($lastBlock) {
-  switch -regex ($lastBlock) { 
-    
-   #handles hgtk help <cmd>
-   #handles hgtk <cmd>
-   'thg (help )?(\S*)$' {
-     thgCommands($matches[2]);
-   }
-    
-   #handles hg update <branch name>
-   #handles hg merge <branch name>
-   'hg (up|update|merge|co|checkout) (\S*)$' {
-      findBranchOrBookmark($matches[2])
-   }
-       
-   #Handles hg pull -B <bookmark>   
-   'hg pull (-\S* )*-(B) (\S*)$' {
-     hgRemoteBookmarks($matches[3])
-     hgLocalBookmarks($matches[3])
-   }
-    
-   #Handles hg push -B <bookmark>   
-   'hg push (-\S* )*-(B) (\S*)$' {
-     hgLocalBookmarks($matches[3])
-   }
-   
-   #Handles hg bookmark <bookmark>
-   'hg (book|bookmark) (\S*)$' {
-      hgLocalBookmarks($matches[2])
-   }
-    
-    #Handles hg push <path>
-    #Handles hg pull <path>
-    'hg (push|pull) (-\S* )*(\S*)$' {
-      hgRemotes($matches[3])
-    }
-    
-    #handles hg help <cmd>
-    #handles hg <cmd>
-    'hg (help )?(\S*)$' {
-      hgCommands($matches[2]);
-    }
-
-    #handles hg <cmd> --<option>
-    'hg (\S+) (-\S* )*--(\S*)$' {
-      hgOptions $matches[1] $matches[3];
-    }
-    
-    #handles hg revert <path>
-    'hg revert (\S*)$' {
-      hgFiles $matches[1] 'M|A|R|!'
-    }
-    
-    #handles hg add <path>
-    'hg add (\S*)$' {
-      hgFiles $matches[1] '\?'
-    }
-    
-    # handles hg diff <path>
-    'hg diff (\S*)$' {
-      hgFiles $matches[1] 'M'
-    }
-    
-    # handles hg commit -(I|X) <path>
-    'hg commit (\S* )*-(I|X) (\S*)$' {
-      hgFiles $matches[3] 'M|A|R|!'
-    }    
-  }
-}
-
-function hgFiles($filter, $pattern) {
-   hg status | 
-    foreach { 
-      if($_ -match "($pattern){1} (.*)") { 
-        $matches[2] 
-      } 
-    } |
-    where { $_ -like "*$filter*" } |
-    foreach { if($_ -like '* *') {  "'$_'"  } else { $_ } }
-}
-
-function hgRemotes($filter) {
-  hg paths | foreach {
-    $path = $_.Split("=")[0].Trim();
-    if($filter -and $path.StartsWith($filter)) {
-      $path
-    } elseif(-not $filter) {
-      $path
-    }
-  }
-}
-
-# By default the hg command list is populated the first time hgCommands is invoked. 
-# Invoke PopulateHgCommands in your profile if you don't want the initial hit. 
-function hgCommands($filter) {
-  if($script:hgCommands.Length -eq 0) {
-    populateHgCommands
-  }
-
-  if($filter) {
-     $hgCommands | ? { $_.StartsWith($filter) } | % { $_.Trim() } | sort  
-  }
-  else {
-    $hgCommands | % { $_.Trim() } | sort
-  }
-}
-
-# By default the hg command list is populated the first time hgCommands is invoked. 
-# Invoke PopulateHgCommands in your profile if you don't want the initial hit. 
-function PopulateHgCommands() {
-   $hgCommands = foreach($cmd in (hg help)) {
-    # Stop once we reach the "Enabled Extensions" section of help. 
-    # Not sure if there's a better way to do this...
-    if($cmd -eq "enabled extensions:") {
-      break
-    }
-    
-    if($cmd -match '^ (\S+) (.*)') {
-        $matches[1]
-     }
-  }
-
-  if($global:PoshHgSettings.ShowPatches) {
-    # MQ integration must be explicitly enabled as the user may not have the extension
-    $hgCommands += (hg help mq) | % {
-      if($_ -match '^ (\S+) (.*)') {
-          $matches[1]
-       }
-    }
-  }
-  
-  $script:hgCommands = $hgCommands
-}
-
-function findBranchOrBookmark($filter){
-    hgLocalBranches($filter)
-    hgLocalBookmarks($filter)
-}
-
-function hgLocalBranches($filter) {
-  hg branches -a | foreach {
-    if($_ -match "(\S+) .*") {
-      if($filter -and $matches[1].StartsWith($filter)) {
-        $matches[1]
-      }
-      elseif(-not $filter) {
-        $matches[1]
-      }
-    }
-  }
-}
-
-function bookmarkName($bookmark) {
-    $split = $bookmark.Split(" ");
-        
-    if($bookmark.StartsWith("*")) {
-        $split[1]
-    }
-    else{
-        $split[0]
-    }
-}
-
-function hgLocalBookmarks($filter) {
-  hg bookmarks | foreach {
-    if($_ -match "(\S+) .*") {
-      $bookmark = bookmarkName($matches[0])  
-      if($filter -and $bookmark.StartsWith($filter)) {
-        $bookmark
-      }
-      elseif(-not $filter) {
-        $bookmark
-      }
-    }
-  }
-}
-
-function hgRemoteBookmarks($filter) {
-  hg incoming -B | foreach {
-    if($_ -match "(\S+) .*") {
-      if($filter -and $matches[1].StartsWith($filter)) {
-        $matches[1]
-      }
-      elseif(-not $filter) {
-        $matches[1]
-      }
-    }
-  }
-}
-
-function hgOptions($cmd, $filter) {
-	$optList = @()
-	$output = hg help $cmd
-	foreach($line in $output) {
-		if($line -match '^ ((-\S)|  ) --(\S+) .*$') {
-			$opt = $matches[3]
-			if($filter -and $opt.StartsWith($filter)) {
-				$optList += '--' + $opt.Trim()
-			}
-			elseif(-not $filter) {
-				$optList += '--' + $opt.Trim()
-			}
-		}
-	}
-
-	$optList | sort
-}
-
-function thgCommands($filter) {
-  $cmdList = @()
-  $output = thg help
-  foreach($line in $output) {
-    if($line -match '^ (\S+) (.*)') {
-      $cmd = $matches[1]
-      if($filter -and $cmd.StartsWith($filter)) {
-        $cmdList += $cmd.Trim()
-      }
-      elseif(-not $filter) {
-        $cmdList += $cmd.Trim()
-      }
-    }
-  }
-  
-  $cmdList | sort 
-}
-
-if(-not (Test-Path Function:\DefaultTabExpansion)) {
-   Rename-Item Function:\TabExpansion DefaultTabExpansion
-}
-
-# Set up tab expansion and include hg expansion
-function TabExpansion($line, $lastWord) {
-   $lastBlock = [regex]::Split($line, '[|;]')[-1]
-
-   switch -regex ($lastBlock) {
-       # mercurial and tortoisehg tab expansion
-       '(hg|thg) (.*)' { HgTabExpansion($lastBlock) }
-       # Fall back on existing tab expansion
-       default { DefaultTabExpansion $line $lastWord }
-   }
-}

HgUtils.ps1

-function isHgDirectory() {
-  if(test-path ".git") {
-    return $false; #short circuit if git repo
-  }
-  
-  if(test-path ".hg") {
-    return $true;
-  }
-  
-  
-  
-  # Test within parent dirs
-  $checkIn = (Get-Item .).parent
-  while ($checkIn -ne $NULL) {
-      $pathToTest = $checkIn.fullname + '/.hg'
-      if ((Test-Path $pathToTest) -eq $TRUE) {
-          return $true
-      } else {
-          $checkIn = $checkIn.parent
-      }
-    }
-    
-    return $false
-}
-
-function Get-HgStatus {
-  if(isHgDirectory) {
-    $untracked = 0
-    $added = 0
-    $modified = 0
-    $deleted = 0
-    $missing = 0
-	$renamed = 0
-    $tags = @()
-    $commit = ""
-    $behind = $false
-   
-  
-       hg summary | foreach {   
-      switch -regex ($_) {
-        'parent: (\S*) ?(.*)' { $commit = $matches[1]; $tags = $matches[2].Replace("(empty repository)", "").Split(" ", [StringSplitOptions]::RemoveEmptyEntries) } 
-        'branch: ([\S ]*)' { $branch = $matches[1] }
-        'update: (\d+)' { $behind = $true }
-        'pmerge: (\d+) pending' { $behind = $true }
-        'commit: (.*)' {
-          $matches[1].Split(",") | foreach {
-            switch -regex ($_.Trim()) {
-              '(\d+) modified' { $modified = $matches[1] }
-              '(\d+) added' { $added = $matches[1] }
-              '(\d+) removed' { $deleted = $matches[1] }
-              '(\d+) deleted' { $missing = $matches[1] }
-              '(\d+) unknown' { $untracked = $matches[1] }
-              '(\d+) renamed' { $renamed = $matches[1] }
-            }
-          } 
-        } 
-      } 
-    }
-    
-    $active = ""
-    hg bookmarks | ?{$_}  | foreach {
-        if($_.Trim().StartsWith("*")) {
-           $split = $_.Split(" ");
-           $active= $split[2]
-        }
-    }
-   
-    return @{"Untracked" = $untracked;
-               "Added" = $added;
-               "Modified" = $modified;
-               "Deleted" = $deleted;
-               "Missing" = $missing;
-			   "Renamed" = $renamed;
-               "Tags" = $tags;
-               "Commit" = $commit;
-               "Behind" = $behind;
-               "ActiveBookmark" = $active;
-               "Branch" = $branch}
-   }
-}
-
-function Get-MqPatches($filter) {
-  $applied = @()
-  $unapplied = @()
-  
-  hg qseries -v | % {
-    $bits = $_.Split(" ")
-    $status = $bits[1]
-    $name = $bits[2]
-    
-    if($status -eq "A") {
-      $applied += $name
-    } else {
-      $unapplied += $name
-    }
-  }
-  
-  $all = $unapplied + $applied
-  
-  if($filter) {
-    $all = $all | ? { $_.StartsWith($filter) }
-  }
-  
-  return @{
-    "All" = $all;
-    "Unapplied" = $unapplied;
-    "Applied" = $applied
-  }
-}
 
 ...and add the following code to your Powershell profile (usually C:\Users\Username\Documents\WindowsPowershell\Profile.ps1)
 
-. path\to\posh-hg\profile.example.ps1
+. path\to\posh-vv\profile.example.ps1
 
 Alternatiely, you can copy the contents of the profile.example.ps1 file in to your profile.ps1
-$global:PoshHgSettings = New-Object PSObject -Property @{
+$global:PoshVvSettings = New-Object PSObject -Property @{
     #Before prompt
     BeforeText                = ' ['
     BeforeForegroundColor     = [ConsoleColor]::Yellow
+# For backwards compatibility
+$global:VvPromptSettings = $global:PoshVvSettings
+
+function Write-VvStatus($status = (get-vvStatus)) {
+    if ($status) {
+        $s = $global:PoshVvSettings
+       
+        $branchFg = $s.BranchForegroundColor
+        $branchBg = $s.BranchBackgroundColor
+        
+        if($status.Behind) {
+          $branchFg = $s.Branch2ForegroundColor
+          $branchBg = $s.Branch2BackgroundColor
+        }
+       
+        Write-Host $s.BeforeText -NoNewline -BackgroundColor $s.BeforeBackgroundColor -ForegroundColor $s.BeforeForegroundColor
+        Write-Host $status.Branch -NoNewline -BackgroundColor $branchBg -ForegroundColor $branchFg
+        
+        if($status.Added) {
+          Write-Host " +$($status.Added)" -NoNewline -BackgroundColor $s.AddedBackgroundColor -ForegroundColor $s.AddedForegroundColor
+        }
+        if($status.Modified) {
+          Write-Host " ~$($status.Modified)" -NoNewline -BackgroundColor $s.ModifiedBackgroundColor -ForegroundColor $s.ModifiedForegroundColor
+        }
+        if($status.Deleted) {
+          Write-Host " -$($status.Deleted)" -NoNewline -BackgroundColor $s.DeletedBackgroundColor -ForegroundColor $s.DeletedForegroundColor
+        }
+        
+        if ($status.Untracked) {
+          Write-Host " ?$($status.Untracked)" -NoNewline -BackgroundColor $s.UntrackedBackgroundColor -ForegroundColor $s.UntrackedForegroundColor
+        }
+        
+        if($status.Missing) {
+           Write-Host " !$($status.Missing)" -NoNewline -BackgroundColor $s.MissingBackgroundColor -ForegroundColor $s.MissingForegroundColor
+        }
+
+        if($status.Renamed) {
+           Write-Host " ^$($status.Renamed)" -NoNewline -BackgroundColor $s.RenamedBackgroundColor -ForegroundColor $s.RenamedForegroundColor
+        }
+
+        if($s.ShowTags -and ($status.Tags.Length -or $status.ActiveBookmark.Length)) {
+          write-host $s.BeforeTagText -NoNewLine
+            
+          if($status.ActiveBookmark.Length) {
+              write-host $status.ActiveBookmark -NoNewLine -ForegroundColor $s.BranchForegroundColor -BackgroundColor $s.TagBackgroundColor 
+              if($status.Tags.Length) {
+                write-host " " -NoNewLine -ForegroundColor $s.TagSeparatorColor -BackgroundColor $s.TagBackgroundColor
+              }
+          }
+         
+          $tagCounter=0
+          $status.Tags | % {
+            $color = $s.TagForegroundColor
+                
+              write-host $_ -NoNewLine -ForegroundColor $color -BackgroundColor $s.TagBackgroundColor 
+          
+              if($tagCounter -lt ($status.Tags.Length -1)) {
+                write-host ", " -NoNewLine -ForegroundColor $s.TagSeparatorColor -BackgroundColor $s.TagBackgroundColor
+              }
+              $tagCounter++;
+          }        
+        }
+        
+        if($s.ShowPatches) {
+          $patches = Get-MqPatches
+          if($patches.All.Length) {
+            write-host $s.BeforePatchText -NoNewLine
+  
+            $patchCounter = 0
+            
+            $patches.Applied | % {
+              write-host $_ -NoNewLine -ForegroundColor $s.AppliedPatchForegroundColor -BackgroundColor $s.AppliedPatchBackgroundColor
+              if($patchCounter -lt ($patches.All.Length -1)) {
+                write-host $s.PatchSeparator -NoNewLine -ForegroundColor $s.PatchSeparatorColor
+              }
+              $patchCounter++;
+            }
+            
+            $patches.Unapplied | % {
+               write-host $_ -NoNewLine -ForegroundColor $s.UnappliedPatchForegroundColor -BackgroundColor $s.UnappliedPatchBackgroundColor
+               if($patchCounter -lt ($patches.All.Length -1)) {
+                  write-host $s.PatchSeparator -NoNewLine -ForegroundColor $s.PatchSeparatorColor
+               }
+               $patchCounter++;
+            }
+          }
+        }
+        
+       Write-Host $s.AfterText -NoNewline -BackgroundColor $s.AfterBackgroundColor -ForegroundColor $s.AfterForegroundColor
+    }
+}
+
+# Should match https://github.com/dahlbyk/posh-git/blob/master/GitPrompt.ps1
+if (!$Global:VcsPromptStatuses) { $Global:VcsPromptStatuses = @() }
+function Global:Write-VcsStatus { $Global:VcsPromptStatuses | foreach { & $_ } }
+
+# Add scriptblock that will execute for Write-VcsStatus
+$Global:VcsPromptStatuses += {
+    $Global:VvStatus = Get-VvStatus
+    Write-VvStatus $VvStatus
+}

VvTabExpansion.ps1

+$script:vvCommands = @()
+
+function VvTabExpansion($lastBlock) {
+  switch -regex ($lastBlock) { 
+    
+   #handles hgtk help <cmd>
+   #handles hgtk <cmd>
+   'thg (help )?(\S*)$' {
+     thgCommands($matches[2]);
+   }
+    
+   #handles vv update <branch name>
+   #handles vv merge <branch name>
+   'vv (up|update|merge|co|checkout) (\S*)$' {
+      findBranchOrBookmark($matches[2])
+   }
+       
+   #Handles vv pull -B <bookmark>   
+   'vv pull (-\S* )*-(B) (\S*)$' {
+     vvRemoteBookmarks($matches[3])
+     vvLocalBookmarks($matches[3])
+   }
+    
+   #Handles vv push -B <bookmark>   
+   'vv push (-\S* )*-(B) (\S*)$' {
+     vvLocalBookmarks($matches[3])
+   }
+   
+   #Handles vv bookmark <bookmark>
+   'vv (book|bookmark) (\S*)$' {
+      vvLocalBookmarks($matches[2])
+   }
+    
+    #Handles vv push <path>
+    #Handles vv pull <path>
+    'vv (push|pull) (-\S* )*(\S*)$' {
+      vvRemotes($matches[3])
+    }
+    
+    #handles vv help <cmd>
+    #handles vv <cmd>
+    'vv (help )?(\S*)$' {
+      vvCommands($matches[2]);
+    }
+
+    #handles vv <cmd> --<option>
+    'vv (\S+) (-\S* )*--(\S*)$' {
+      vvOptions $matches[1] $matches[3];
+    }
+    
+    #handles vv revert <path>
+    'vv revert (\S*)$' {
+      vvFiles $matches[1] 'M|A|R|!'
+    }
+    
+    #handles vv add <path>
+    'vv add (\S*)$' {
+      vvFiles $matches[1] '\?'
+    }
+    
+    # handles vv diff <path>
+    'vv diff (\S*)$' {
+      vvFiles $matches[1] 'M'
+    }
+    
+    # handles vv commit -(I|X) <path>
+    'vv commit (\S* )*-(I|X) (\S*)$' {
+      vvFiles $matches[3] 'M|A|R|!'
+    }    
+  }
+}
+
+function vvFiles($filter, $pattern) {
+   vv status | 
+    foreach { 
+      if($_ -match "($pattern){1} (.*)") { 
+        $matches[2] 
+      } 
+    } |
+    where { $_ -like "*$filter*" } |
+    foreach { if($_ -like '* *') {  "'$_'"  } else { $_ } }
+}
+
+function vvRemotes($filter) {
+  vv paths | foreach {
+    $path = $_.Split("=")[0].Trim();
+    if($filter -and $path.StartsWith($filter)) {
+      $path
+    } elseif(-not $filter) {
+      $path
+    }
+  }
+}
+
+# By default the vv command list is populated the first time vvCommands is invoked. 
+# Invoke PopulateVvCommands in your profile if you don't want the initial hit. 
+function vvCommands($filter) {
+  if($script:vvCommands.Length -eq 0) {
+    populateVvCommands
+  }
+
+  if($filter) {
+     $vvCommands | ? { $_.StartsWith($filter) } | % { $_.Trim() } | sort  
+  }
+  else {
+    $vvCommands | % { $_.Trim() } | sort
+  }
+}
+
+# By default the vv command list is populated the first time vvCommands is invoked. 
+# Invoke PopulateVvCommands in your profile if you don't want the initial hit. 
+function PopulateVvCommands() {
+   $vvCommands = foreach($cmd in (vv help)) {
+    # Stop once we reach the "input vv help command" section of help. 
+    # Not sure if there's a better way to do this...
+    if($cmd -eq 'input "vv help command"') {
+      break
+    }
+    
+    if($cmd -match '^ (\S+) (.*)') {
+        $matches[1]
+     }
+  }
+
+  if($global:PoshVvSettings.ShowPatches) {
+    # MQ integration must be explicitly enabled as the user may not have the extension
+    $vvCommands += (vv help mq) | % {
+      if($_ -match '^ (\S+) (.*)') {
+          $matches[1]
+       }
+    }
+  }
+  
+  $script:vvCommands = $vvCommands
+}
+
+function findBranchOrBookmark($filter){
+    vvLocalBranches($filter)
+    vvLocalBookmarks($filter)
+}
+
+function vvLocalBranches($filter) {
+  vv branches -a | foreach {
+    if($_ -match "(\S+) .*") {
+      if($filter -and $matches[1].StartsWith($filter)) {
+        $matches[1]
+      }
+      elseif(-not $filter) {
+        $matches[1]
+      }
+    }
+  }
+}
+
+function bookmarkName($bookmark) {
+    $split = $bookmark.Split(" ");
+        
+    if($bookmark.StartsWith("*")) {
+        $split[1]
+    }
+    else{
+        $split[0]
+    }
+}
+
+function vvLocalBookmarks($filter) {
+  vv bookmarks | foreach {
+    if($_ -match "(\S+) .*") {
+      $bookmark = bookmarkName($matches[0])  
+      if($filter -and $bookmark.StartsWith($filter)) {
+        $bookmark
+      }
+      elseif(-not $filter) {
+        $bookmark
+      }
+    }
+  }
+}
+
+function vvRemoteBookmarks($filter) {
+  vv incoming -B | foreach {
+    if($_ -match "(\S+) .*") {
+      if($filter -and $matches[1].StartsWith($filter)) {
+        $matches[1]
+      }
+      elseif(-not $filter) {
+        $matches[1]
+      }
+    }
+  }
+}
+
+function vvOptions($cmd, $filter) {
+	$optList = @()
+	$output = vv help $cmd
+	foreach($line in $output) {
+		if($line -match '^ ((-\S)|  ) --(\S+) .*$') {
+			$opt = $matches[3]
+			if($filter -and $opt.StartsWith($filter)) {
+				$optList += '--' + $opt.Trim()
+			}
+			elseif(-not $filter) {
+				$optList += '--' + $opt.Trim()
+			}
+		}
+	}
+
+	$optList | sort
+}
+
+function thgCommands($filter) {
+  $cmdList = @()
+  $output = thg help
+  foreach($line in $output) {
+    if($line -match '^ (\S+) (.*)') {
+      $cmd = $matches[1]
+      if($filter -and $cmd.StartsWith($filter)) {
+        $cmdList += $cmd.Trim()
+      }
+      elseif(-not $filter) {
+        $cmdList += $cmd.Trim()
+      }
+    }
+  }
+  
+  $cmdList | sort 
+}
+
+if(-not (Test-Path Function:\DefaultTabExpansion)) {
+   Rename-Item Function:\TabExpansion DefaultTabExpansion
+}
+
+# Set up tab expansion and include vv expansion
+function TabExpansion($line, $lastWord) {
+   $lastBlock = [regex]::Split($line, '[|;]')[-1]
+
+   switch -regex ($lastBlock) {
+       # veracity tab expansion
+       '(vv) (.*)' { VvTabExpansion($lastBlock) }
+       # Fall back on existing tab expansion
+       default { DefaultTabExpansion $line $lastWord }
+   }
+}
+function isVvDirectory() {
+  if(test-path ".git") {
+    return $false; #short circuit if git repo
+  }
+  
+  if(test-path ".hg") {
+    return $false; #short circuit if hg repo
+  }
+  
+  if(test-path ".sgdrawer") {
+    return $true;
+  }
+  
+  
+  
+  # Test within parent dirs
+  $checkIn = (Get-Item .).parent
+  while ($checkIn -ne $NULL) {
+      $pathToTest = $checkIn.fullname + '/.sgdrawer'
+      if ((Test-Path $pathToTest) -eq $TRUE) {
+          return $true
+      } else {
+          $checkIn = $checkIn.parent
+      }
+    }
+    
+    return $false
+}
+
+function Get-VvStatus {
+  if(isVvDirectory) {
+    $untracked = 0
+    $added = 0
+    $modified = 0
+    $deleted = 0
+    $missing = 0
+	$renamed = 0
+    $tags = @()
+    $commit = ""
+    $behind = $false
+   
+  
+       vv summary | foreach {   
+      switch -regex ($_) {
+        'parent: (\S*) ?(.*)' { $commit = $matches[1]; $tags = $matches[2].Replace("(empty repository)", "").Split(" ", [StringSplitOptions]::RemoveEmptyEntries) } 
+        'branch: ([\S ]*)' { $branch = $matches[1] }
+        'update: (\d+)' { $behind = $true }
+        'pmerge: (\d+) pending' { $behind = $true }
+        'commit: (.*)' {
+          $matches[1].Split(",") | foreach {
+            switch -regex ($_.Trim()) {
+              '(\d+) modified' { $modified = $matches[1] }
+              '(\d+) added' { $added = $matches[1] }
+              '(\d+) removed' { $deleted = $matches[1] }
+              '(\d+) deleted' { $missing = $matches[1] }
+              '(\d+) unknown' { $untracked = $matches[1] }
+              '(\d+) renamed' { $renamed = $matches[1] }
+            }
+          } 
+        } 
+      } 
+    }
+    
+    $active = ""
+    vv bookmarks | ?{$_}  | foreach {
+        if($_.Trim().StartsWith("*")) {
+           $split = $_.Split(" ");
+           $active= $split[2]
+        }
+    }
+   
+    return @{"Untracked" = $untracked;
+               "Added" = $added;
+               "Modified" = $modified;
+               "Deleted" = $deleted;
+               "Missing" = $missing;
+			   "Renamed" = $renamed;
+               "Tags" = $tags;
+               "Commit" = $commit;
+               "Behind" = $behind;
+               "ActiveBookmark" = $active;
+               "Branch" = $branch}
+   }
+}
+
+function Get-MqPatches($filter) {
+  $applied = @()
+  $unapplied = @()
+  
+  vv qseries -v | % {
+    $bits = $_.Split(" ")
+    $status = $bits[1]
+    $name = $bits[2]
+    
+    if($status -eq "A") {
+      $applied += $name
+    } else {
+      $unapplied += $name
+    }
+  }
+  
+  $all = $unapplied + $applied
+  
+  if($filter) {
+    $all = $all | ? { $_.StartsWith($filter) }
+  }
+  
+  return @{
+    "All" = $all;
+    "Unapplied" = $unapplied;
+    "Applied" = $applied
+  }
+}
 param([switch]$WhatIf = $false)
 
 if($PSVersionTable.PSVersion.Major -lt 2) {
-    Write-Warning "posh-hg requires PowerShell 2.0 or better; you have version $($Host.Version)."
+    Write-Warning "posh-vv requires PowerShell 2.0 or better; you have version $($Host.Version)."
     return
 }
 
-if(!(Get-Command hg -ErrorAction SilentlyContinue)) {
-    Write-Warning 'Could not find hg command. Please create an hg alias or add its location to PATH.'
+if(!(Get-Command vv -ErrorAction SilentlyContinue)) {
+    Write-Warning 'Could not find vv command. Please create an vv alias or add its location to PATH.'
     return
 }
 
 
 $profileLine = ". '$installDir\profile.example.ps1'"
 if(Select-String -Path $PROFILE -Pattern $profileLine -Quiet -SimpleMatch) {
-    Write-Host "It seems posh-hg is already installed..."
+    Write-Host "It seems posh-vv is already installed..."
     return
 }
 
-Write-Host "Adding posh-hg to profile..."
+Write-Host "Adding posh-vv to profile..."
 @"
 
-# Load posh-hg example profile
+# Load posh-vv example profile
 $profileLine
 
 "@ | Out-File $PROFILE -Append -WhatIf:$WhatIf -Encoding (Get-FileEncoding $PROFILE)
 
-Write-Host 'posh-hg sucessfully installed!'
+Write-Host 'posh-vv sucessfully installed!'
 Write-Host 'Please reload your profile for the changes to take effect:'
 Write-Host '    . $PROFILE'

posh-hg.psm1

-Push-Location $psScriptRoot
-. ./Settings.ps1
-. ./HgUtils.ps1
-. ./HgPrompt.ps1
-. ./HgTabExpansion.ps1
-Pop-Location
-
-Export-ModuleMember -Function @(
-  'Get-HgStatus',
-  'TabExpansion',
-  'Get-MqPatches',
-  'PopulateHgCommands'
- )
+Push-Location $psScriptRoot
+. ./Settings.ps1
+. ./VvUtils.ps1
+. ./VvPrompt.ps1
+. ./VvTabExpansion.ps1
+Pop-Location
+
+Export-ModuleMember -Function @(
+  'Get-VvStatus',
+  'TabExpansion',
+  'Get-MqPatches',
+  'PopulateVvCommands'
+ )

profile.example.ps1

 Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
 
-# Load posh-hg module from current directory
-Import-Module .\posh-hg
+# Load posh-vv module from current directory
+Import-Module .\posh-vv
 
 # If module is installed in a default location ($env:PSModulePath),
 # use this instead (see about_Modules for more information):
-# Import-Module posh-hg
+# Import-Module posh-vv
 
 
-# Set up a simple prompt, adding the hg prompt parts inside hg repos
+# Set up a simple prompt, adding the vv prompt parts inside vv repos
 function prompt {
     Write-Host($pwd) -nonewline
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.