diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-18 21:57:21 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-18 21:57:21 -0400 |
commit | a84f738053b0e5c05919296a59856b24f262d75c (patch) | |
tree | 75f7505c7d38343ef15f0c10822778148c572c8c /Command | |
parent | b20cb8393f503ea6b12d6155f80c5be12157af49 (diff) |
vpop N
Diffstat (limited to 'Command')
-rw-r--r-- | Command/VPop.hs | 19 | ||||
-rw-r--r-- | Command/View.hs | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/Command/VPop.hs b/Command/VPop.hs index e62c2414a..fe6d35a32 100644 --- a/Command/VPop.hs +++ b/Command/VPop.hs @@ -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 diff --git a/Command/View.hs b/Command/View.hs index 9e1b981a7..5c1742855 100644 --- a/Command/View.hs +++ b/Command/View.hs @@ -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) |