support git-annex view in an adjusted branch
Rather than entering a view of the adjusted branch, enter an adjusted view branch. This way, it's the same as first using git-amnnex view followed by git-annex adjust, and everything already implemented to support that works. Sponsored-by: Nicholas Golder-Manning on Patreon
This commit is contained in:
parent
bb54c8a633
commit
80478cc145
1 changed files with 16 additions and 11 deletions
|
@ -20,6 +20,7 @@ import Types.View
|
||||||
import Annex.View
|
import Annex.View
|
||||||
import Logs.View
|
import Logs.View
|
||||||
import Types.AdjustedBranch
|
import Types.AdjustedBranch
|
||||||
|
import Annex.AdjustedBranch.Name
|
||||||
|
|
||||||
import qualified System.FilePath.ByteString as P
|
import qualified System.FilePath.ByteString as P
|
||||||
|
|
||||||
|
@ -35,16 +36,16 @@ start :: [String] -> CommandStart
|
||||||
start [] = giveup "Specify metadata to include in view"
|
start [] = giveup "Specify metadata to include in view"
|
||||||
start ps = ifM safeToEnterView
|
start ps = ifM safeToEnterView
|
||||||
( do
|
( do
|
||||||
view <- mkView ps
|
(view, madj) <- mkView ps
|
||||||
go view =<< currentView
|
go view madj =<< currentView
|
||||||
, giveup "Not safe to enter view."
|
, giveup "Not safe to enter view."
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
ai = ActionItemOther Nothing
|
ai = ActionItemOther Nothing
|
||||||
si = SeekInput ps
|
si = SeekInput ps
|
||||||
go view Nothing = starting "view" ai si $
|
go view madj Nothing = starting "view" ai si $
|
||||||
perform view
|
perform view madj
|
||||||
go view (Just (v, _madj))
|
go view _ (Just (v, _madj))
|
||||||
| v == view = stop
|
| v == view = stop
|
||||||
| otherwise = giveup "Already in a view. Use the vfilter and vadd commands to further refine this view."
|
| otherwise = giveup "Already in a view. Use the vfilter and vadd commands to further refine this view."
|
||||||
|
|
||||||
|
@ -73,22 +74,26 @@ safeToEnterView = do
|
||||||
-- view.
|
-- view.
|
||||||
dangerous (StagedUnstaged { unstaged = Just _ }) = True
|
dangerous (StagedUnstaged { unstaged = Just _ }) = True
|
||||||
|
|
||||||
perform :: View -> CommandPerform
|
perform :: View -> Maybe Adjustment -> CommandPerform
|
||||||
perform view = do
|
perform view madj = do
|
||||||
showAction "searching"
|
showAction "searching"
|
||||||
next $ checkoutViewBranch view Nothing applyView
|
next $ checkoutViewBranch view madj applyView
|
||||||
|
|
||||||
paramView :: String
|
paramView :: String
|
||||||
paramView = paramRepeating "TAG FIELD=GLOB ?TAG FIELD?=GLOB FIELD!=VALUE"
|
paramView = paramRepeating "TAG FIELD=GLOB ?TAG FIELD?=GLOB FIELD!=VALUE"
|
||||||
|
|
||||||
mkView :: [String] -> Annex View
|
mkView :: [String] -> Annex (View, Maybe Adjustment)
|
||||||
mkView ps = go =<< inRepo Git.Branch.current
|
mkView ps = go =<< inRepo Git.Branch.current
|
||||||
where
|
where
|
||||||
go Nothing = giveup "not on any branch!"
|
go Nothing = giveup "not on any branch!"
|
||||||
go (Just b) = do
|
go (Just b) = case adjustedToOriginal b of
|
||||||
|
Nothing -> go' b Nothing
|
||||||
|
Just (adj, b') -> go' b' (Just adj)
|
||||||
|
go' b madj = do
|
||||||
vu <- annexViewUnsetDirectory <$> Annex.getGitConfig
|
vu <- annexViewUnsetDirectory <$> Annex.getGitConfig
|
||||||
return $ fst $ refineView (View b []) $
|
let v = fst $ refineView (View b []) $
|
||||||
map (parseViewParam vu) (reverse ps)
|
map (parseViewParam vu) (reverse ps)
|
||||||
|
return (v, madj)
|
||||||
|
|
||||||
checkoutViewBranch :: View -> Maybe Adjustment -> (View -> Maybe Adjustment -> Annex Git.Branch) -> CommandCleanup
|
checkoutViewBranch :: View -> Maybe Adjustment -> (View -> Maybe Adjustment -> Annex Git.Branch) -> CommandCleanup
|
||||||
checkoutViewBranch view madj mkbranch = do
|
checkoutViewBranch view madj mkbranch = do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue