Commits

Cory Li committed 3112a42

Commit from Seta00 that adds dirty/modified bits to mercurial

  • Participants
  • Parent commits 83d1e0a

Comments (0)

Files changed (1)

     result_t* result = init_result();
     char buf[1024];
 
+
+    FILE *stream;
+
+    if (!(stream = popen("hg status", "r"))) {
+          debug("Unable to read output of 'hg status'");
+          return NULL;
+    }
+
+    size_t rlen = fread(buf, sizeof(char), 2047, stream);
+    buf[rlen] = '\0';
+    pclose(stream);
+
+    if (context->options->show_modified) {
+          if (buf[0] == 'M' || strstr(buf, "\nM")) {
+              result->modified = 1;
+          }
+    }
+
+    if (context->options->show_unknown) {
+          if (buf[0] == '?' || strstr(buf, "\n?")) {
+                result->unknown = 1;
+          }
+    }
+
     // prefers bookmark because it tends to be more informative
     if (read_first_line(".hg/bookmarks.current", buf, 1024) && buf[0]) {
         debug("read first line from .hg/bookmarks.current: '%s'", buf);