diff options
author | Joey Hess <joey@kitenet.net> | 2014-04-05 16:04:37 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-04-05 16:10:39 -0400 |
commit | 73050592050239490beb656f2b7e3cde567df237 (patch) | |
tree | c1e900fc388af75052fd078fce2feddf75343433 /RemoteDaemon | |
parent | 13fe079e1a7c1ce4269c1ceb8113c3603d8abe9a (diff) |
git-annex-shell: Added notifychanges command.
This will be used by the remote-daemon to quickly tell when changes have
been pushed from some other repository into a ssh remote.
Adjusted the remote-daemon protocol to communicate changed shas, rather
than git branch refs. This way, it can easily check if a sha is new.
This commit was sponsored by Carlos Trijueque Albarran.
Diffstat (limited to 'RemoteDaemon')
-rw-r--r-- | RemoteDaemon/EndPoint/GitAnnexShell/Types.hs | 32 | ||||
-rw-r--r-- | RemoteDaemon/Endpoint/GitAnnexShell/Types.hs | 29 | ||||
-rw-r--r-- | RemoteDaemon/Types.hs | 19 |
3 files changed, 45 insertions, 35 deletions
diff --git a/RemoteDaemon/EndPoint/GitAnnexShell/Types.hs b/RemoteDaemon/EndPoint/GitAnnexShell/Types.hs new file mode 100644 index 000000000..996c4237c --- /dev/null +++ b/RemoteDaemon/EndPoint/GitAnnexShell/Types.hs @@ -0,0 +1,32 @@ +{- git-remote-daemon, git-annex-shell endpoint, datatypes + - + - Copyright 2014 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} + +module RemoteDaemon.EndPoint.GitAnnexShell.Types ( + Notification(..), + Proto.serialize, + Proto.deserialize, + Proto.formatMessage, +) where + +import qualified Utility.SimpleProtocol as Proto +import RemoteDaemon.Types (ShaList) + +data Notification + = READY + | CHANGED ShaList + +instance Proto.Sendable Notification where + formatMessage READY = ["READY"] + formatMessage (CHANGED shas) = ["CHANGED", Proto.serialize shas] + +instance Proto.Receivable Notification where + parseCommand "READY" = Proto.parse0 READY + parseCommand "CHANGED" = Proto.parse1 CHANGED + parseCommand _ = Proto.parseFail diff --git a/RemoteDaemon/Endpoint/GitAnnexShell/Types.hs b/RemoteDaemon/Endpoint/GitAnnexShell/Types.hs deleted file mode 100644 index dd8b59d1d..000000000 --- a/RemoteDaemon/Endpoint/GitAnnexShell/Types.hs +++ /dev/null @@ -1,29 +0,0 @@ -{- git-remote-daemon, git-annex-shell endpoint, datatypes - - - - Copyright 2014 Joey Hess <joey@kitenet.net> - - - - Licensed under the GNU GPL version 3 or higher. - -} - -{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} - -module RemoteDaemon.EndPoint.GitAnnexShell.Types where - -import Common.Annex -import qualified Git.Types as Git -import qualified Utility.SimpleProtocol as Proto -import RemoteDaemon.Types (RemoteName, RefList) - -data Notifications - = CHANGED RemoteName RefList - -instance Proto.Sendable Notifications where - formatMessage (CHANGED remote refs) = - ["CHANGED" - , Proto.serialize remote - , Proto.serialize refs - ] - -instance Proto.Receivable Notifications where - parseCommand "CHANGED" = Proto.parse2 CHANGED diff --git a/RemoteDaemon/Types.hs b/RemoteDaemon/Types.hs index 746b895f6..b4b8ba066 100644 --- a/RemoteDaemon/Types.hs +++ b/RemoteDaemon/Types.hs @@ -10,13 +10,14 @@ module RemoteDaemon.Types where -import Common.Annex import qualified Git.Types as Git import qualified Utility.SimpleProtocol as Proto -- Messages that the daemon emits. data Emitted - = CHANGED RemoteName RefList + = CONNECTED RemoteName + | DISCONNECTED RemoteName + | CHANGED RemoteName ShaList | STATUS RemoteName UserMessage | ERROR RemoteName UserMessage @@ -29,13 +30,17 @@ data Consumed type RemoteName = String type UserMessage = String -type RefList = [Git.Ref] +type ShaList = [Git.Sha] instance Proto.Sendable Emitted where - formatMessage (CHANGED remote refs) = + formatMessage (CONNECTED remote) = + ["CONNECTED", Proto.serialize remote] + formatMessage (DISCONNECTED remote) = + ["DISCONNECTED", Proto.serialize remote] + formatMessage (CHANGED remote shas) = ["CHANGED" , Proto.serialize remote - , Proto.serialize refs + , Proto.serialize shas ] formatMessage (STATUS remote msg) = ["STATUS" @@ -55,6 +60,8 @@ instance Proto.Sendable Consumed where formatMessage RELOAD = ["RELOAD"] instance Proto.Receivable Emitted where + parseCommand "CONNECTED" = Proto.parse1 CONNECTED + parseCommand "DISCONNECTED" = Proto.parse1 DISCONNECTED parseCommand "CHANGED" = Proto.parse2 CHANGED parseCommand "STATUS" = Proto.parse2 STATUS parseCommand "ERROR" = Proto.parse2 ERROR @@ -71,6 +78,6 @@ instance Proto.Serializable [Char] where serialize = id deserialize = Just -instance Proto.Serializable RefList where +instance Proto.Serializable ShaList where serialize = unwords . map Git.fromRef deserialize = Just . map Git.Ref . words |