This commit is contained in:
Joey Hess 2014-02-18 21:57:21 -04:00
parent 8ff05cf55b
commit 1a53c87057
3 changed files with 16 additions and 8 deletions

View file

@ -17,27 +17,32 @@ import Command.View (checkoutViewBranch)
def :: [Command]
def = [notBareRepo $ notDirect $
command "vpop" paramNothing seek SectionUtility
command "vpop" (paramOptional paramNumber) seek SectionUtility
"switch back to previous view"]
seek :: CommandSeek
seek = withNothing start
seek = withWords start
start ::CommandStart
start = go =<< currentView
start :: [String] -> CommandStart
start ps = go =<< currentView
where
go Nothing = error "Not in a view."
go (Just v) = do
showStart "vpop" ""
showStart "vpop" (show num)
removeView v
vs <- filter (sameparentbranch v) <$> recentViews
vs <- drop (num - 1) . filter (sameparentbranch v)
<$> recentViews
case vs of
(oldv:_) -> next $ next $ do
showOutput
checkoutViewBranch oldv (return . branchView)
_ -> next $ next $
_ -> next $ next $ do
showOutput
inRepo $ Git.Command.runBool
[ Param "checkout"
, Param $ show $ Git.Ref.base $
viewParentBranch v
]
sameparentbranch a b = viewParentBranch a == viewParentBranch b
num = fromMaybe 1 $ readish =<< headMaybe ps

View file

@ -70,6 +70,7 @@ checkoutViewBranch view mkbranch = do
liftIO . setCurrentDirectory =<< fromRepo Git.repoPath
branch <- mkbranch view
showOutput
ok <- inRepo $ Git.Command.runBool
[ Param "checkout"
, Param (show $ Git.Ref.base branch)

View file

@ -326,11 +326,13 @@ subdirectories).
When multiple field values match, the view branch will have a
subdirectory for each value.
* `vpop`
* `vpop [N]`
Switches from the currently active view back to the previous view.
Or, from the first view back to original branch.
The optional number tells how many views to pop.
* `vadd [field=value ...] [tag ...]`
Refines the currently checked out view branch, adding additional fields