Commits

Greg Ward committed ab1c6ee Merge

merge with hg-unknown-modified; fix bug in test-hg script
The tests I just added are better, but still failing because of bugs
in the implementation. Will fix shortly.

  • Participants
  • Parent commits e5552f0, 680f598

Comments (0)

Files changed (2)

 #include <arpa/inet.h>
 #endif
 
+#include "capture.h"
 #include "common.h"
 #include "hg.h"
 
     free(last_line);
 }
 
+static void
+read_modified_unknown(vccontext_t *context, result_t *result)
+{
+    // No easy way that we know to get the modified or unknown status
+    // without forking an hg process. Replace this with a more efficient version
+    // if you ever figure it out.
+    if (!context->options->show_modified && !context->options->show_unknown)
+        return;
+
+    char *argv[] = { "hg", "status", "--modified", "--unknown", "--quiet", NULL};
+    capture_t *capture = capture_child("hg", argv);
+    if (capture == NULL) {
+        debug("unable to execute 'hg status'");
+        return;
+    }
+    char *cstdout = capture->childout.buf;
+    if (context->options->show_unknown) {
+        result->unknown = (strstr(cstdout, "? ") != NULL);
+    }
+
+    if (context->options->show_modified) {
+	result->modified = (strstr(cstdout, "M ") != NULL ||
+			    strstr(cstdout, "A ") != NULL||
+			    strstr(cstdout, "! ") != NULL||
+			    strstr(cstdout, "R ") != NULL);
+    }
+
+    cstdout = NULL;
+    free_capture(capture);
+}
+
 static result_t*
 hg_get_info(vccontext_t *context)
 {
 
     read_parents(context, result);
     read_patch_name(context, result);
+    read_modified_unknown(context, result);
 
     return result;
 }

File tests/test-hg

 
 posttest()
 {
-    :
+    cd $tmpdir
+    rm -rf hg-repo
 }
 
 # default prompt format in test repo
     assert_vcprompt "unknown only 2" "?" "%u"
     assert_vcprompt "unknown only 3" "?" "%m%u"
 
-    rm -f junk
+    posttest
 }
 
 test_status_goofy_filenames()
     assert_vcprompt "1 modified" "+" "%m"
     assert_vcprompt "no unknown files" "" "%u"
     assert_vcprompt "1 modified, no unknown" "+" "%m%u"
+    posttest
 }
 
 check_hg