From 2fb1cfc4ae0cfb3f012e074f2f855c592f866b05 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Feb 2014 17:38:23 -0400 Subject: add git annex view command (And a vpop command, which is still a bit buggy.) Still need to do vadd and vrm, though this also adds their documentation. Currently not very happy with the view log data serialization. I had to lose the TDFA regexps temporarily, so I can have Read/Show instances of View. I expect the view log format will change in some incompatable way later, probably adding last known refs for the parent branch to View or something like that. Anyway, it basically works, although it's a bit slow looking up the metadata. The actual git branch construction is about as fast as it can be using the current git plumbing. This commit was sponsored by Peter Hogg. --- Command/VPop.hs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Command/VPop.hs (limited to 'Command/VPop.hs') diff --git a/Command/VPop.hs b/Command/VPop.hs new file mode 100644 index 000000000..03905b751 --- /dev/null +++ b/Command/VPop.hs @@ -0,0 +1,42 @@ +{- git-annex command + - + - Copyright 2014 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.VPop where + +import Common.Annex +import Command +import qualified Git.Command +import qualified Git.Ref +import Types.View +import Logs.View +import Command.View (checkoutViewBranch) + +def :: [Command] +def = [notBareRepo $ notDirect $ + command "vpop" paramNothing seek SectionUtility + "switch back to previous view"] + +seek :: CommandSeek +seek = withNothing start + +start ::CommandStart +start = go =<< currentView + where + go Nothing = error "Not in a view." + go (Just v) = do + vs <- dropWhile (/= v) . filter (sameparentbranch v) + <$> recentViews + case vs of + (_v:oldv:_) -> next $ next $ + checkoutViewBranch oldv (branchView oldv) + _ -> next $ next $ + inRepo $ Git.Command.runBool + [ Param "checkout" + , Param $ show $ Git.Ref.base $ + viewParentBranch v + ] + sameparentbranch a b = viewParentBranch a == viewParentBranch b -- cgit v1.2.3