contentlocationn: New plumbing command.
This commit is contained in:
		
					parent
					
						
							
								b22aacab44
							
						
					
				
			
			
				commit
				
					
						ce0a82f493
					
				
			
		
					 8 changed files with 84 additions and 0 deletions
				
			
		| 
						 | 
					@ -9,6 +9,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module Annex.Content (
 | 
					module Annex.Content (
 | 
				
			||||||
	inAnnex,
 | 
						inAnnex,
 | 
				
			||||||
 | 
						inAnnex',
 | 
				
			||||||
	inAnnexSafe,
 | 
						inAnnexSafe,
 | 
				
			||||||
	inAnnexCheck,
 | 
						inAnnexCheck,
 | 
				
			||||||
	lockContent,
 | 
						lockContent,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ import qualified Command.Move
 | 
				
			||||||
import qualified Command.Copy
 | 
					import qualified Command.Copy
 | 
				
			||||||
import qualified Command.Get
 | 
					import qualified Command.Get
 | 
				
			||||||
import qualified Command.LookupKey
 | 
					import qualified Command.LookupKey
 | 
				
			||||||
 | 
					import qualified Command.ContentLocation
 | 
				
			||||||
import qualified Command.ExamineKey
 | 
					import qualified Command.ExamineKey
 | 
				
			||||||
import qualified Command.FromKey
 | 
					import qualified Command.FromKey
 | 
				
			||||||
import qualified Command.RegisterUrl
 | 
					import qualified Command.RegisterUrl
 | 
				
			||||||
| 
						 | 
					@ -152,6 +153,7 @@ cmds = concat
 | 
				
			||||||
	, Command.Ungroup.cmd
 | 
						, Command.Ungroup.cmd
 | 
				
			||||||
	, Command.Vicfg.cmd
 | 
						, Command.Vicfg.cmd
 | 
				
			||||||
	, Command.LookupKey.cmd
 | 
						, Command.LookupKey.cmd
 | 
				
			||||||
 | 
						, Command.ContentLocation.cmd
 | 
				
			||||||
	, Command.ExamineKey.cmd
 | 
						, Command.ExamineKey.cmd
 | 
				
			||||||
	, Command.FromKey.cmd
 | 
						, Command.FromKey.cmd
 | 
				
			||||||
	, Command.RegisterUrl.cmd
 | 
						, Command.RegisterUrl.cmd
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										32
									
								
								Command/ContentLocation.hs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								Command/ContentLocation.hs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,32 @@
 | 
				
			||||||
 | 
					{- git-annex command
 | 
				
			||||||
 | 
					 -
 | 
				
			||||||
 | 
					 - Copyright 2015 Joey Hess <id@joeyh.name>
 | 
				
			||||||
 | 
					 -
 | 
				
			||||||
 | 
					 - Licensed under the GNU GPL version 3 or higher.
 | 
				
			||||||
 | 
					 -}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module Command.ContentLocation where
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import Common.Annex
 | 
				
			||||||
 | 
					import Command
 | 
				
			||||||
 | 
					import Annex.Content
 | 
				
			||||||
 | 
					import Types.Key
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cmd :: [Command]
 | 
				
			||||||
 | 
					cmd = [noCommit $ noMessages $
 | 
				
			||||||
 | 
						command "contentlocation" (paramRepeating paramKey) seek
 | 
				
			||||||
 | 
							SectionPlumbing "looks up content for a key"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					seek :: CommandSeek
 | 
				
			||||||
 | 
					seek = withKeys start
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					start :: Key -> CommandStart
 | 
				
			||||||
 | 
					start k = do
 | 
				
			||||||
 | 
						liftIO . maybe exitFailure putStrLn
 | 
				
			||||||
 | 
							=<< inAnnex' (pure True) Nothing check k
 | 
				
			||||||
 | 
						stop
 | 
				
			||||||
 | 
					  where
 | 
				
			||||||
 | 
						check f = ifM (liftIO (doesFileExist f))
 | 
				
			||||||
 | 
							( return (Just f)
 | 
				
			||||||
 | 
							, return Nothing
 | 
				
			||||||
 | 
							)
 | 
				
			||||||
							
								
								
									
										1
									
								
								debian/changelog
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								debian/changelog
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -20,6 +20,7 @@ git-annex (5.20150409) unstable; urgency=medium
 | 
				
			||||||
    with the current repository, the new repository's remote path
 | 
					    with the current repository, the new repository's remote path
 | 
				
			||||||
    was set to "." rather than the path to the current repository.
 | 
					    was set to "." rather than the path to the current repository.
 | 
				
			||||||
    This was a reversion caused by the relative path changes in 5.20150113.
 | 
					    This was a reversion caused by the relative path changes in 5.20150113.
 | 
				
			||||||
 | 
					  * contentlocationn: New plumbing command.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 -- Joey Hess <id@joeyh.name>  Thu, 09 Apr 2015 15:06:38 -0400
 | 
					 -- Joey Hess <id@joeyh.name>  Thu, 09 Apr 2015 15:06:38 -0400
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,3 +2,4 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Current layout is DIRHASH (of two levels) /KEY/KEY, so I would need to hardcode having that KEY directory.  It might be nice to either make DIRHASH to return full hash directory (but it might break existing special remotes), or supplement with e.g. DIRHASHFULL which would return all the levels necessary to reach the KEY file
 | 
					Current layout is DIRHASH (of two levels) /KEY/KEY, so I would need to hardcode having that KEY directory.  It might be nice to either make DIRHASH to return full hash directory (but it might break existing special remotes), or supplement with e.g. DIRHASHFULL which would return all the levels necessary to reach the KEY file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> [[done]] --[[Joey]]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,14 @@
 | 
				
			||||||
 | 
					[[!comment format=mdwn
 | 
				
			||||||
 | 
					 username="joey"
 | 
				
			||||||
 | 
					 subject="""comment 3"""
 | 
				
			||||||
 | 
					 date="2015-04-09T19:08:40Z"
 | 
				
			||||||
 | 
					 content="""
 | 
				
			||||||
 | 
					I've added a contentlocation command
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					I'd expect an external command to not be much slower than using the pipe
 | 
				
			||||||
 | 
					for this. It does not need to spin up any git commands etc to get the
 | 
				
			||||||
 | 
					content location. Also, you can pass it multiple keys to query at one time
 | 
				
			||||||
 | 
					if necessary.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					I guess we'll see if this is too slow and can revisit it if so..
 | 
				
			||||||
 | 
					"""]]
 | 
				
			||||||
							
								
								
									
										27
									
								
								doc/git-annex-contentlocation.mdwn
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								doc/git-annex-contentlocation.mdwn
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					# NAME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					git-annex contentlocation - looks up content for a key
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# SYNOPSIS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					git annex contentlocation `[key ...]`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# DESCRIPTION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This plumbing-level command looks up filename used to store the content 
 | 
				
			||||||
 | 
					of a key. The filename is output to stdout. If the key's content is not
 | 
				
			||||||
 | 
					present in the local repository, nothing is output, and it exits nonzero.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Note that in direct mode, the file will typically be in the git work
 | 
				
			||||||
 | 
					tree, and while its content should correspond to the key, the file
 | 
				
			||||||
 | 
					could become modified at any time after git-annex checks it.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# SEE ALSO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[git-annex]](1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# AUTHOR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Joey Hess <id@joeyh.name>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Warning: Automatically converted into a man page by mdwn2man. Edit with care.
 | 
				
			||||||
| 
						 | 
					@ -513,6 +513,12 @@ subdirectories).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  See [[git-annex-lookupkey]](1) for details.
 | 
					  See [[git-annex-lookupkey]](1) for details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `contentlocation [key ..]`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Looks up location of annexed content for a key.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  See [[git-annex-contentlocation]](1) for details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* `examinekey [key ...]`
 | 
					* `examinekey [key ...]`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Print information that can be determined purely by looking at the key.
 | 
					  Print information that can be determined purely by looking at the key.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue