From 5a3900ad344157aeb8d1cbdb645c66d4b8ab3f47 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Mon, 3 Jun 2024 20:16:19 +0300 Subject: [PATCH] wip, merge driver --- .fixme-new/log | Bin 538 -> 961 bytes .gitattributes | 1 + fixme-new/fixme.cabal | 2 +- fixme-new/lib/Fixme/Run.hs | 22 ++++++++++++++++++++++ fixme-new/lib/Fixme/Scan.hs | 1 - hbs2-core/lib/HBS2/System/Dir.hs | 6 ++++++ 6 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .gitattributes diff --git a/.fixme-new/log b/.fixme-new/log index 05f1b08028e11aed08f1eee73f7f2a6cc33c2293..d48b3191b25e622cca385e7ce07f102b6afc1067 100644 GIT binary patch delta 434 zcmbQma*%z46jMC|7%;UrGf1Vyeok*~BKfe~t<6ojs4@&_`Yf{ec)g3Kad z*L=}{n0i8c>W1bXzb)2Iy{79IGd3HUv0V*S==(PN#H7foo%eshT(cg{HH7qmTm$p} za;UTJAY8-L4t32!kZa=Flp(IU>XooTd&Z7Sk8;XgCPZ(`^7QeD(zM^6bbNgiQbd delta 7 OcmX@eK8t086cYdn&;m06 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..0b4845a9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.fixme-new/log merge=fixme-log-merge diff --git a/fixme-new/fixme.cabal b/fixme-new/fixme.cabal index 53d1a3a9..534da05e 100644 --- a/fixme-new/fixme.cabal +++ b/fixme-new/fixme.cabal @@ -84,10 +84,10 @@ common shared-properties , streaming , stm , text + , temporary , time , timeit , transformers - , typed-process , unordered-containers , unliftio diff --git a/fixme-new/lib/Fixme/Run.hs b/fixme-new/lib/Fixme/Run.hs index 5aa1bcb5..33902703 100644 --- a/fixme-new/lib/Fixme/Run.hs +++ b/fixme-new/lib/Fixme/Run.hs @@ -39,6 +39,8 @@ import Lens.Micro.Platform import System.Process.Typed import Control.Monad.Trans.Cont import Control.Monad.Trans.Maybe +import System.IO.Temp as Temp + import Streaming.Prelude qualified as S @@ -558,6 +560,26 @@ run what = do compactStorageClose sto + ListVal [SymbolVal "git:merge",StringLike o, StringLike target, StringLike b] -> do + debug $ red "git:merge" <+> pretty o <+> pretty target <+> pretty b + + temp <- liftIO $ emptyTempFile "." "merge-result" + sa <- compactStorageOpen @HbSync readonly o + sb <- compactStorageOpen @HbSync readonly b + r <- compactStorageOpen @HbSync mempty temp + + for_ [sa,sb] $ \sto -> do + ks <- keys sto + for_ ks $ \k -> runMaybeT do + v <- get sto k & MaybeT + put r k v + + compactStorageClose r + compactStorageClose sa + compactStorageClose sb + + mv temp target + ListVal [SymbolVal "no-debug"] -> do setLoggingOff @DEBUG diff --git a/fixme-new/lib/Fixme/Scan.hs b/fixme-new/lib/Fixme/Scan.hs index 03a65412..7c021044 100644 --- a/fixme-new/lib/Fixme/Scan.hs +++ b/fixme-new/lib/Fixme/Scan.hs @@ -117,7 +117,6 @@ scanBlob fpath lbs = do next (S (Sf (succEln env bs)) xs) S _ [] -> pure () - -- debug $ vcat (fmap viaShow parts) S.toList_ do diff --git a/hbs2-core/lib/HBS2/System/Dir.hs b/hbs2-core/lib/HBS2/System/Dir.hs index ca7a83c0..643490bb 100644 --- a/hbs2-core/lib/HBS2/System/Dir.hs +++ b/hbs2-core/lib/HBS2/System/Dir.hs @@ -69,6 +69,12 @@ expandPath = liftIO . D.canonicalizePath doesDirectoryExist :: MonadIO m => FilePath -> m Bool doesDirectoryExist = liftIO . D.doesDirectoryExist +fileSize :: MonadIO m => FilePath -> m Integer +fileSize = liftIO . D.getFileSize + +mv :: MonadIO m => FilePath -> FilePath -> m () +mv a b = liftIO $ D.renamePath a b + home :: MonadIO m => m FilePath home = liftIO D.getHomeDirectory