Commits

Anton Afanasyev committed a1eaf62

get all info needed for vvStatus by using just one call to vscript

  • Participants
  • Parent commits ef7149a

Comments (0)

Files changed (1)

     $tags = @()
     $commit = ""
     $behind = $false
-   
-  
-    $status = vscript -e "print(sg.to_json(sg.pending_tree.status()));" | ConvertFrom-Json
+
+
+    $branch = vv branch
+    $statusScript = Get-Status-Script $branch
+    $allStatus = vscript -e ($statusScript) | ConvertFrom-Json
+
+
+    $status = $allStatus.status
     $status | Get-Member | Select-Object -ExpandProperty Name | foreach {
       switch ($_) {
         'Found' { $untracked = $status.Found.length }
       }
     }
 
-    $branch = vv branch
     # get info about newest changeset in current branch
-    $lastChset = vscript -e ("print(sg.to_json(sg.pending_tree.history(['branch=" + $branch + "','max=1'])));") | ConvertFrom-Json
+    $lastChset = $allStatus.lastChset
     $lastChset = $lastChset[0]
     # get info about workingdir changeset
-    $curChset = vscript -e "print(sg.to_json(sg.pending_tree.history(['rev='+sg.pending_tree.parents()]))); " | ConvertFrom-Json
+    $curChset = $allStatus.curChset
     $curChset = $curChset[0]
 
     $tags = $curChset.tags
               "Branch" = $branch}
    }
 }
+
+function Get-Status-Script( $branch ) {
+  $status    = "sg.to_json(sg.pending_tree.status())"
+  $lastChset = "sg.to_json(sg.pending_tree.history(['branch=" + $branch + "','max=1']))"
+  $curChset  = "sg.to_json(sg.pending_tree.history(['rev='+sg.pending_tree.parents()]))"
+
+  return "print('{ status: ' + $status + ', lastChset: ' + $lastChset + ', curChset: ' + $curChset + ' }');"
+}