changelog shortlog graph tags branches files raw help

Mercurial > core / changeset: vc ignore stuff

changeset 379: 45889d307d7f
parent 378: 2ef83f2178f1
child 380: 16bb4464adcb
author: Richard Westhaver <ellis@rwest.io>
date: Tue, 28 May 2024 16:44:54 -0400
files: .hgignore lisp/bin/skel.lisp lisp/lib/skel/core/obj.lisp lisp/lib/skel/pkg.lisp lisp/lib/vc/git.lisp lisp/lib/vc/hg.lisp lisp/lib/vc/ignore.lisp lisp/lib/vc/pkg.lisp lisp/lib/vc/proto.lisp lisp/lib/vc/util.lisp lisp/lib/vc/vc.asd lisp/lisp.sk lisp/skelfile lisp/std/path.lisp lisp/std/pkg.lisp rust/rust.sk rust/skelfile
description: vc ignore stuff
     1.1--- a/.hgignore	Mon May 27 23:15:33 2024 -0400
     1.2+++ b/.hgignore	Tue May 28 16:44:54 2024 -0400
     1.3@@ -1,3 +1,5 @@
     1.4+# test
     1.5+
     1.6 ^x$
     1.7 .*Cargo.lock$
     1.8 .*target/.*
     2.1--- a/lisp/bin/skel.lisp	Mon May 27 23:15:33 2024 -0400
     2.2+++ b/lisp/bin/skel.lisp	Tue May 28 16:44:54 2024 -0400
     2.3@@ -111,7 +111,7 @@
     2.4 (defcmd skc-pull
     2.5   (case (sk-vc-meta-kind (sk-vc (find-skelfile #P"." :load t)))
     2.6     (:git (run-git-command "pull" $args t))
     2.7-    (:hg (run-hg-command "pull" (push "-u" $args) t))
     2.8+    (:hg (run-hg-command "pull" (append "-u" $args) t))
     2.9     (t (skel-error "unknown VC type"))))
    2.10 
    2.11 (defun hg-status ()
     3.1--- a/lisp/lib/skel/core/obj.lisp	Mon May 27 23:15:33 2024 -0400
     3.2+++ b/lisp/lib/skel/core/obj.lisp	Tue May 28 16:44:54 2024 -0400
     3.3@@ -243,7 +243,6 @@
     3.4                    :kind (when-let ((ext (pathname-type script)))
     3.5                            (keywordicate ext))))))
     3.6 
     3.7-
     3.8 (defmethod sk-run ((self sk-script))
     3.9   (sb-ext:run-program (sk-path self) nil :output t))
    3.10 
    3.11@@ -420,16 +419,8 @@
    3.12             :initform (make-array 0 :element-type 'sk-script :adjustable t)
    3.13             :accessor sk-scripts
    3.14             :type (vector sk-script))
    3.15-   (snippets :initarg :snippets
    3.16-             :initform (make-array 0 :element-type 'sk-snippet :adjustable t)
    3.17-             :accessor sk-snippets
    3.18-             :type (vector sk-snippet))
    3.19    (stash :initarg :stash :accessor sk-stash :type pathname)
    3.20    (store :initarg :store :accessor sk-store :type pathname)
    3.21-   (abbrevs :initarg :abbrevs
    3.22-            :initform (make-array 0 :element-type 'sk-abbrev :adjustable t)
    3.23-            :accessor sk-abbrevs
    3.24-            :type (vector sk-abbrevs))
    3.25    (imports :initarg :imports
    3.26             :initform (make-array 0 :element-type 'pathname :adjustable t)
    3.27             :accessor sk-imports
    3.28@@ -550,11 +541,11 @@
    3.29 
    3.30 (defmethod sk-install-user-config ((self sk-project) (cfg sk-user-config))
    3.31   (with-slots (vc store stash license author) (debug! cfg) ;; log-level, custom, fmt
    3.32-    (cas (sk-vc self) nil vc)
    3.33-    (cas (sk-stash self) nil stash)
    3.34-    (cas (sk-store self) nil store)
    3.35-    (cas (sk-license self) nil license)
    3.36-    (cas (sk-author self) nil author)))
    3.37+    (setf (sk-vc self) vc)
    3.38+    (setf (sk-stash self) stash)
    3.39+    (setf (sk-store self) store)
    3.40+    (setf (sk-license self) license)
    3.41+    (setf (sk-author self) author)))
    3.42 
    3.43 (defmethod sk-find-rule (name self)
    3.44   (find (string-upcase name) (sk-rules self) :test 'equalp :key #'sk-rule-target))
     4.1--- a/lisp/lib/skel/pkg.lisp	Mon May 27 23:15:33 2024 -0400
     4.2+++ b/lisp/lib/skel/pkg.lisp	Tue May 28 16:44:54 2024 -0400
     4.3@@ -67,11 +67,9 @@
     4.4    :*default-containerfile*
     4.5    ;; obj
     4.6    :*user-skelrc* :*system-skelrc* :*keep-ast*
     4.7-   :*skel-project* :*skel-user-config* :*default-skelrc* :*skel-registry* :*skel-cache*
     4.8-   :*default-skelfile* :*default-skel-user* :*default-skel-cache* :*default-user-skel-config* 
     4.9-   :*default-user-skelrc* :*default-system-skel-config* :*skelfile-extension* :*skelfile-boundary*
    4.10-   :*default-skel-stash*
    4.11-   :*default-system-skelrc*
    4.12+   :*skel-project* :*skel-user-config* :*skel-system-config* :*default-skelrc* :*skel-registry* :*skel-cache*
    4.13+   :*default-skelfile* :*default-skel-user* :*default-skel-cache*
    4.14+   :*skelfile-extension* :*skelfile-boundary*
    4.15    :load-ast :sk-license
    4.16    :sk-author :sk-path :sk-stash :sk-cache :sk-registry :sk-user :sk-store
    4.17    :sk-push :sk-pull
     5.1--- a/lisp/lib/vc/git.lisp	Mon May 27 23:15:33 2024 -0400
     5.2+++ b/lisp/lib/vc/git.lisp	Tue May 28 16:44:54 2024 -0400
     5.3@@ -19,6 +19,9 @@
     5.4             (:regex "^git@"))
     5.5           url-str)))
     5.6 
     5.7+(defun gitignore (&optional (path ".gitignore"))
     5.8+  (make-vc-ignore :path path :patterns (map-lines #'glob-path-match path)))
     5.9+
    5.10 (defclass git-repo (vc-repo)
    5.11   ((index))) ;; working-directory
    5.12 
     6.1--- a/lisp/lib/vc/hg.lisp	Mon May 27 23:15:33 2024 -0400
     6.2+++ b/lisp/lib/vc/hg.lisp	Tue May 28 16:44:54 2024 -0400
     6.3@@ -55,6 +55,9 @@
     6.4             (:regex "^hg@"))
     6.5           url-str)))
     6.6 
     6.7+(defun hgignore (&optional (path ".hgignore"))
     6.8+  (make-vc-ignore :path path :patterns (map-lines #'ppcre:create-scanner path)))
     6.9+
    6.10 ;; (describe (make-instance 'hg-repo))
    6.11 ;; https://repo.mercurial-scm.org/hg/file/tip/mercurial/interfaces/repository.py
    6.12 (defclass hg-repo (vc-repo)
     7.1--- a/lisp/lib/vc/ignore.lisp	Mon May 27 23:15:33 2024 -0400
     7.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3@@ -1,1 +0,0 @@
     7.4-(in-package :vc)
     8.1--- a/lisp/lib/vc/pkg.lisp	Mon May 27 23:15:33 2024 -0400
     8.2+++ b/lisp/lib/vc/pkg.lisp	Tue May 28 16:44:54 2024 -0400
     8.3@@ -1,5 +1,5 @@
     8.4 (defpackage :vc
     8.5-  (:use :cl :std :cli :log :obj :sb-bsd-sockets :cl-ppcre)
     8.6+  (:use :cl :std :cli :log :obj :sb-bsd-sockets :cl-ppcre :parse/lex)
     8.7   (:import-from :uiop :with-current-directory)
     8.8   (:export :*default-vc*
     8.9    :vc-error :git-error :hg-error :vc-status
    8.10@@ -10,8 +10,9 @@
    8.11    :run-hg-command :repo :hg-repo :git-repo
    8.12    :vc-meta :hg-meta :git-meta :make-hg-client
    8.13    :hg-client :*repo-roots* :*repo-registry* :find-repo
    8.14-   :make-repo :register-repo))
    8.15+   :make-repo :register-repo
    8.16+   :vc-ignore :hgignore :gitignore))
    8.17 
    8.18 (in-package :vc)
    8.19 
    8.20-(defvar *default-vc* :hg)
    8.21+(defparameter *default-vc* :hg)
     9.1--- a/lisp/lib/vc/proto.lisp	Mon May 27 23:15:33 2024 -0400
     9.2+++ b/lisp/lib/vc/proto.lisp	Tue May 28 16:44:54 2024 -0400
     9.3@@ -41,8 +41,33 @@
     9.4 
     9.5 ;;; Objects
     9.6 
     9.7+;;;; Config
     9.8 ;; should be parsed from .hgrc and .gitconfig
     9.9-(defclass vc-config (sxp) ())
    9.10+(defclass vc-config (sxp cfg) ())
    9.11+
    9.12+;;;; Ignorefile
    9.13+
    9.14+;; Basically we treat HG and GIT ignore files the same - just lines of string
    9.15+;; patterns. HG uses regexp and GIT is globs - an IGNOREFILE has a line parser
    9.16+;; slot for selecting the appropriate function.
    9.17+
    9.18+(defun map-lines (fn path)
    9.19+  "Call FN on each line of file PATH and collect the result."
    9.20+  (with-open-file (file path)
    9.21+    (loop for line = (read-line file nil)
    9.22+          while line
    9.23+          unless (or (= (length line) 0) (char= (aref line 0) #\#))
    9.24+          collect (funcall fn line))))
    9.25+
    9.26+(defstruct vc-ignore path patterns)
    9.27+
    9.28+(defgeneric vc-path-ignored-p (obj path)
    9.29+  (:documentation "Check PATH against the patterns in OBJ. If there is a match, return non-nil.")
    9.30+  (:method ((obj vc-ignore) (path t))
    9.31+    (let ((len (length path)))
    9.32+      (loop for pat in (vc-ignore-patterns obj)
    9.33+            when (funcall pat path 0 len)
    9.34+            return (values path pat)))))
    9.35 
    9.36 (defstruct vc-branch name rev)
    9.37 
    10.1--- a/lisp/lib/vc/util.lisp	Mon May 27 23:15:33 2024 -0400
    10.2+++ b/lisp/lib/vc/util.lisp	Tue May 28 16:44:54 2024 -0400
    10.3@@ -4,3 +4,10 @@
    10.4   (if (pathnamep obj)
    10.5       (namestring obj)
    10.6       obj))
    10.7+
    10.8+(defun rel-pathname (path)
    10.9+  (pathname (string-left-trim '(#\/) path)))
   10.10+
   10.11+(defun glob-path-match (glob)
   10.12+  (lambda (p start end)
   10.13+    (member (subseq p start end) (directory (rel-pathname glob)) :test 'equal)))
    11.1--- a/lisp/lib/vc/vc.asd	Mon May 27 23:15:33 2024 -0400
    11.2+++ b/lisp/lib/vc/vc.asd	Tue May 28 16:44:54 2024 -0400
    11.3@@ -1,9 +1,8 @@
    11.4 (defsystem :vc
    11.5-  :depends-on (:std :cli :obj :net :log)
    11.6+  :depends-on (:std :cli :obj :net :log :parse)
    11.7   :components ((:file "pkg")
    11.8                (:file "util")
    11.9                (:file "err")
   11.10-               (:file "ignore")
   11.11                (:file "proto")
   11.12                (:file "hg")
   11.13                (:file "git"))
    12.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2+++ b/lisp/lisp.sk	Tue May 28 16:44:54 2024 -0400
    12.3@@ -0,0 +1,4 @@
    12.4+;;; lisp.sk --- lisp skelfile -*- mode: skel; -*-
    12.5+:name "core/lisp"
    12.6+:description "The CC Lisp Core"
    12.7+:components ((:asd "prelude.asd"))
    13.1--- a/lisp/skelfile	Mon May 27 23:15:33 2024 -0400
    13.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3@@ -1,5 +0,0 @@
    13.4-;;; lisp.sk --- lisp skelfile -*- mode: skel; -*-
    13.5-:name "core/lisp"
    13.6-:description "The CC Lisp Core"
    13.7-:components ((:file "prelude.asd"))
    13.8-
    14.1--- a/lisp/std/path.lisp	Mon May 27 23:15:33 2024 -0400
    14.2+++ b/lisp/std/path.lisp	Tue May 28 16:44:54 2024 -0400
    14.3@@ -34,3 +34,5 @@
    14.4 (defconstant +pathsep+
    14.5   #+windows #\; #+unix #\:
    14.6   "Path separator for this OS.")
    14.7+
    14.8+(defconstant +wildfile+ (make-pathname :name :wild :type :wild :version :wild))
    15.1--- a/lisp/std/pkg.lisp	Mon May 27 23:15:33 2024 -0400
    15.2+++ b/lisp/std/pkg.lisp	Tue May 28 16:44:54 2024 -0400
    15.3@@ -332,7 +332,8 @@
    15.4    :absolute-pathname
    15.5    :relative-pathname
    15.6    :directory-pathname
    15.7-   :absolute-directory-pathname))
    15.8+   :absolute-directory-pathname
    15.9+   :+wildfile+ :+pathsep+))
   15.10 
   15.11 (defpkg :std/os
   15.12   (:use :cl)
   15.13@@ -354,7 +355,6 @@
   15.14    :file=
   15.15    :file-size
   15.16    :file-size-in-octets
   15.17-   :+pathsep+
   15.18    :octet-vector=
   15.19    :file-date
   15.20    :file-timestamp
    16.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2+++ b/rust/rust.sk	Tue May 28 16:44:54 2024 -0400
    16.3@@ -0,0 +1,8 @@
    16.4+;;; rust.sk --- core/rust skelfile -*- mode: skel; -*-
    16.5+:name "core/rust"
    16.6+:version "0.1.0"
    16.7+:description "Rust Core"
    16.8+:tags ("rust")
    16.9+:components ((:toml "Cargo"))
   16.10+:rules 
   16.11+(("clean" () #$cargo clean$#))
    17.1--- a/rust/skelfile	Mon May 27 23:15:33 2024 -0400
    17.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3@@ -1,7 +0,0 @@
    17.4-;;; rust.sk --- core/rust skelfile -*- mode: skel; -*-
    17.5-:name "core/rust"
    17.6-:version "0.1.0"
    17.7-:description "Rust Core"
    17.8-:tags ("rust")
    17.9-:rules 
   17.10-(("clean" () #$cargo clean$#))