aboutsummaryrefslogtreecommitdiff
path: root/Command/VPop.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-18 21:57:21 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-18 21:57:21 -0400
commita84f738053b0e5c05919296a59856b24f262d75c (patch)
tree75f7505c7d38343ef15f0c10822778148c572c8c /Command/VPop.hs
parentb20cb8393f503ea6b12d6155f80c5be12157af49 (diff)
vpop N
Diffstat (limited to 'Command/VPop.hs')
-rw-r--r--Command/VPop.hs19
1 files changed, 12 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