# # rename_file "database.ml" # to "database-mt.ml" # # patch "Makefile" # from [468184ae6dd5fb915d9d1a1b6a64854cb829c38e] # to [1006477d6c9773635c9f8f85893b323fd0237db5] # # patch "configure.ac" # from [43c8ff541d8d9b3c7a01992b0f3678649dcf001e] # to [ec7e74911afd17b2816ada7c0a0ad5349b95340d] # # patch "git.ml" # from [a920f37d4b4f0c9e83407224bdfe47e2317ff920] # to [70d3e1cbbf278f880d0aa022142bf241adb0f8f9] # # patch "ocaml.m4" # from [ec43df3f629049753f8f617e3b2702a9161ae48b] # to [253bd36251f268f569417ac120658673a332e1e8] # # patch "viz_misc.mli" # from [998703433822eb6ea3f7c74e30b3403d288cbe0b] # to [f98871b0abb3298c963a0961f30c113219b6626e] # --- Makefile +++ Makefile @@ -1,18 +1,17 @@ include config.make OCAMLNET := ocamlnet-0.97.1 EXTLIB := extlib-1.3 -VPATH = mlsqlite $(OCAMLNET) $(EXTLIB) glib crypto +VPATH = glib crypto -MLINCDIRS = -I $(OCAMLNET) -I mlsqlite -I $(EXTLIB) -I $(LABLGTK_DIR) -I glib -I crypto -CINCDIRS = -I $(MONOTONE_DIR)/sqlite -I $(LABLGTK_DIR) -ccopt "$(GTK_CFLAGS) $(CRYPTO_CFLAGS)" +MLINCDIRS = -I $(LABLGTK_DIR) -I glib -I crypto +CINCDIRS = -I $(LABLGTK_DIR) -ccopt "$(GTK_CFLAGS) $(CRYPTO_CFLAGS)" GTK_CFLAGS := $(shell pkg-config gtk+-2.0 --cflags) -SRC = base64.ml base64.mli sqlite3.ml sqlite3.mli IO.mli IO.ml unzip.ml unzip.mli \ - gspawn.ml gspawn.mli giochannel.ml giochannel.mli \ +SRC = gspawn.ml gspawn.mli giochannel.ml giochannel.mli \ crypto.ml crypto.mli \ viz_misc.ml viz_misc.mli viz_types.ml viz_types.mli \ q.ml q.mli heap.ml heap.mli \ @@ -37,11 +36,8 @@ dot_types.mli dot_lexer.mll dot_parser.mly \ subprocess.ml subprocess.mli icon.ml status.ml ui.ml \ revision_types.mli revision_lexer.mll revision_parser.mly \ - database.ml database.mli agraph.ml agraph.mli \ + git.ml database-mt.ml database.mli agraph.ml agraph.mli \ unidiff.ml unidiff.mli view.ml view.mli main.ml \ - mlsqlite/sqlite3.ml mlsqlite/sqlite3.mli mlsqlite/ocaml-sqlite3.c \ - ocamlnet-0.97.1/base64.ml ocamlnet-0.97.1/base64.mli ocamlnet-0.97.1/LICENSE \ - extlib-1.3/IO.ml extlib-1.3/IO.mli extlib-1.3/unzip.ml extlib-1.3/unzip.mli \ glib/gspawn.ml glib/gspawn.mli glib/giochannel.ml glib/giochannel.mli \ glib/ocaml-gspawn.c glib/ocaml-giochannel.c \ glib/gspawn_tags.var glib/giochannel_tags.var \ @@ -49,22 +45,21 @@ ifeq ($(OCAMLBEST), opt) -monotone-viz : $(OBJX) lib3rdparty.a +git-viz: $(OBJX) lib3rdparty.a $(OCAMLOPT) -o $@ -I . -I $(LABLGTK_DIR) $(MLLIBS) $^ $(CRYPTO_LIB) -monotone-viz : MLLIBS = str.cmxa lablgtk.cmxa gtkInit.cmx lablgnomecanvas.cmxa +git-viz : MLLIBS = str.cmxa lablgtk.cmxa gtkInit.cmx lablgnomecanvas.cmxa else -monotone-viz : $(OBJ) lib3rdparty.a +git-viz: + ln -sf git.ml database.ml $(OCAMLC) -custom -o $@ -I . -I $(LABLGTK_DIR) $(MLLIBS) $^ $(CRYPTO_LIB) -monotone-viz : MLLIBS = str.cma lablgtk.cma gtkInit.cmo lablgnomecanvas.cma +git-viz : MLLIBS = str.cma lablgtk.cma gtkInit.cmo lablgnomecanvas.cma endif -git-viz: - mv database.ml database-mt.ml ; mv git.ml database.ml - $(MAKE) monotone-viz - mv database.ml git.ml ; mv database-mt.ml database.ml +database.ml : + ln -s git.ml $@ -lib3rdparty.a : mlsqlite/ocaml-sqlite3.o glib/ocaml-gspawn.o glib/ocaml-giochannel.o crypto/ocaml-openssl.o - ar crs lib3rdparty.a $(MONOTONE_DIR)/sqlite/lib3rdparty_a-*.o $^ +lib3rdparty.a : glib/ocaml-gspawn.o glib/ocaml-giochannel.o crypto/ocaml-openssl.o + ar crs lib3rdparty.a $^ glib/ocaml-gspawn.o : gspawn_tags.c gspawn_tags.h glib/ocaml-giochannel.o : giochannel_tags.c giochannel_tags.h @@ -96,9 +91,6 @@ rm -f *.a *.so *.o *.cm* monotone-viz rm -f dot_lexer.ml dot_parser.ml dot_parser.mli rm -f revision_lexer.ml revision_parser.ml revision_parser.mli - cd mlsqlite && rm -f *.a *.so *.o *.cm* - cd $(OCAMLNET) && rm -f *.o *.cm* - cd $(EXTLIB) && rm -f *.o *.cm* cd glib && rm -f *.o *.cm* cd crypto && rm -f *.o *.cm* --- configure.ac +++ configure.ac @@ -37,27 +37,4 @@ OCAMLBEST=byte fi - -# Check the sqlite3 sources -AC_ARG_WITH([monotone-dir], - AS_HELP_STRING([--with-monotone-dir], - [specify location of monotone build tree]), - MONOTONE_DIR=$withval, - MONOTONE_DIR=monotone) -AC_MSG_CHECKING(sqlite sources) -if test -d "$MONOTONE_DIR" -a -r "$MONOTONE_DIR/sqlite/lib3rdparty_a-main.o" ; then - AC_MSG_RESULT(found in $MONOTONE_DIR/sqlite) -else - AC_MSG_ERROR([ - -Could not find compiled sqlite sources. Monotone-viz needs a compiled -monotone tree for the sqlite library. Create a link named `monotone' -or specify the location to configure using the `--with-monotone-dir' -option.]) -fi -if test "${MONOTONE_DIR:0:1}" != "/" ; then - MONOTONE_DIR=$PWD/$MONOTONE_DIR -fi -AC_SUBST(MONOTONE_DIR) - AC_OUTPUT(config.make) --- git.ml +++ git.ml @@ -24,8 +24,7 @@ let fetch_commit_object base id = - if Viz_misc.debug "exec" - then Printf.eprintf "### exec: Running 'cat-file commit %s'\n%!" id ; + log "exec" "### exec: Running 'cat-file commit %s'" id ; match Gspawn.sync ~working_directory:base ~flags:[`SEARCH_PATH] @@ -34,28 +33,33 @@ | _, _, stderr -> Viz_types.errorf "cat-file invocation failed: '%s'" stderr -exception Done of commit let scan_commit_object co = - let lines = string_split ~collapse:false '\n' co in - let c = { tree = "" ; parents = [] ; author = "" ; committer = "" ; log = "" } in - try - ignore ( - List.fold_left (fun (c, p) l -> - let new_c = - if string_is_prefix "tree " l - then Scanf.sscanf l "tree %40[0-9a-f]" (fun s -> { c with tree = s }) - else if string_is_prefix "parent" l - then Scanf.sscanf l "parent %40[0-9a-f]" (fun s -> { c with parents = s :: c.parents }) - else if string_is_prefix "author" l - then { c with author = string_slice ~s:7 l } - else if string_is_prefix "committer" l - then { c with committer = string_slice ~s:10 l } - else if l = "" - then raise (Done ({ c with log = string_slice ~s:(p+1) co })) - else c in - new_c, p + String.length l + 1) - (c, 0) lines) ; assert false - with Done c -> c + let tree = ref "" in + let parents = ref [] in + let author = ref "" in + let committer = ref "" in + let log = ref "" in + begin + let lines = string_split ~collapse:false '\n' co in + let p = ref 0 in + try List.iter (function + | "" -> raise Exit + | l -> + p := !p + String.length l + 1 ; + match string_split ~max_elem:2 ' ' l with + | ["tree"; id] -> tree := id + | ["parent"; id] -> parents := id :: !parents + | ["author"; v] -> author := v + | ["committer"; v] -> committer := v + | _ -> ()) lines + with Exit -> + log := string_slice ~s:(!p + 1) co + end ; + { tree = !tree ; + parents = List.rev !parents ; + author = !author ; + committer = !committer ; + log = !log } let get_commit_object base id = scan_commit_object (fetch_commit_object base id) @@ -64,34 +68,36 @@ let fetch_changeset base old_id new_id = - if Viz_misc.debug "exec" - then Printf.eprintf "### exec: Running 'diff-tree %s %s'\n%!" old_id new_id ; + log "exec" "### exec: Running 'diff-tree %s %s'" old_id new_id ; let tmp_file = Filename.temp_file "git-viz_" ".diff-tree" in - match Gspawn.sync + match + Gspawn.sync ~working_directory:base ~flags:[] - [ "/bin/sh"; "-c" ; - Printf.sprintf "diff-tree '%s' '%s' > %s" old_id new_id (Filename.quote tmp_file)] with + ["/bin/sh"; "-c"; + Printf.sprintf "diff-tree '%s' '%s' > %s" old_id new_id (Filename.quote tmp_file) ] + with | Gspawn.EXITSTATUS 0, _, _ -> let stdout = with_file_in input_channel tmp_file in Sys.remove tmp_file ; stdout | _, _, stderr -> - Viz_types.errorf "diff-tree invocation failed: '%s'" stderr + Sys.remove tmp_file ; + Viz_types.errorf "diff-tree invocation failed:\n'%s'" stderr let scan_change_linus l = let b = Scanf.Scanning.from_string l in match l.[0] with | '+' | '-' -> Scanf.bscanf b - "%c%_o %[0-9a-f] %n" + "%c%_o %40[0-9a-f] %n" (fun c id s -> if c = '+' then Revision_types.ADD_FILE (string_slice ~s:(s-1) l) else Revision_types.DELETE_FILE (string_slice ~s:(s-1) l)) | '*' -> Scanf.bscanf b - "*%_o->%_o %[0-9a-f]->%[0-9a-f] %n" + "*%_o->%_o %40[0-9a-f]->%40[0-9a-f] %n" (fun id1 id2 s -> Revision_types.PATCH (string_slice ~s:(s-1) l, id1, id2)) | _ -> failwith "Could not parse changeset" @@ -201,6 +207,9 @@ (* find by tag *) let get_matching_tags d p = [] +(* find by date *) +let get_matching_dates d s = [] + (* autocolor by keyid *) let get_key_rowid d k = 0 @@ -213,8 +222,7 @@ false)) | `PASKY -> let cmd = [ "git"; "diff"; parent; child] in - if Viz_misc.debug "### exec" - then Printf.eprintf "### exec: Running '%s'\n%!" (String.concat " " cmd) ; + log "exec" "### exec: Running '%s'" (String.concat " " cmd) ; try status#push "Running git diff ..." ; ignore ( --- ocaml.m4 +++ ocaml.m4 @@ -1,6 +1,6 @@ dnl -*- autoconf -*- macros for OCaml dnl by Olivier Andrieu -dnl from a configure.in by Jean-Christophe Filliâtre, +dnl from a configure.in by Jean-Christophe Filliâtre, dnl from a first script by Georges Mariano dnl dnl defines AC_PROG_OCAML that will check the OCaml compiler --- viz_misc.mli +++ viz_misc.mli @@ -25,6 +25,7 @@ val get_home_dir : unit -> string val debug : string -> bool +val log : string -> ('a, unit, string, unit) format4 -> 'a module Signal : sig