@@ 8,15 8,12 @@
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
#include <arpa/inet.h>
#include <time.h>
-#include <limits.h>
+
+#include "fast-hg-common.h"
#ifndef DEBUG
#define PRINT(format, ...) /* arg */
@@ 30,20 27,6 @@ void dirty(const char* reason) {
printf("*");
}
-void go_up_one_dir(char* dir_path) {
- size_t k = 0;
-
- /* if we get here then the file doesn't exist, so try the next directory up */
- for (k = strlen(dir_path)-1; k+1; k--) {
- if (dir_path[k] == '/') { /* obviously won't work on windows ... but what does? */
- dir_path[k] = 0; /* cheap hack in c: set an element of the
- character array to the null-terminator '\0'
- to mark the end of a new string */
- break;
- }
- }
-}
-
int parse_dirstate(const char* pwd) {
FILE *f = NULL;
char filename[PATH_MAX+1];
@@ 133,20 116,6 @@ int parse_dirstate(const char* pwd) {
}
int main() {
- char pwd[PATH_MAX+1], hg_path[PATH_MAX+1];
- size_t l=0;
- int denied=0;
-
- getcwd(pwd, PATH_MAX+1);
+ return map(parse_dirstate);
+}
- while ((l = strlen(pwd)) > 0) {
- sprintf(hg_path, "%s/.hg", pwd);
- denied = access(hg_path, R_OK);
-
- if (!denied) return parse_dirstate(pwd);
-
- go_up_one_dir(pwd);
- }
-
- return 0;
-}