Merge branch 'master' into ghc7.0
Conflicts: debian/changelog
This commit is contained in:
commit
a3249ec912
7 changed files with 49 additions and 25 deletions
|
@ -17,26 +17,40 @@ import qualified Annex
|
|||
import qualified Backend.URL
|
||||
import Annex.Content
|
||||
import Logs.Web
|
||||
import qualified Option
|
||||
|
||||
def :: [Command]
|
||||
def = [command "addurl" (paramRepeating paramUrl) seek "add urls to annex"]
|
||||
def = [withOptions [fileOption] $
|
||||
command "addurl" (paramRepeating paramUrl) seek "add urls to annex"]
|
||||
|
||||
fileOption :: Option
|
||||
fileOption = Option.field [] "file" paramFile "specify what file the url is added to"
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withStrings start]
|
||||
seek = [withField fileOption return $ \f ->
|
||||
withStrings $ start f]
|
||||
|
||||
start :: String -> CommandStart
|
||||
start s = notBareRepo $ go $ parseURI s
|
||||
start :: Maybe FilePath -> String -> CommandStart
|
||||
start optfile s = notBareRepo $ go $ fromMaybe bad $ parseURI s
|
||||
where
|
||||
go Nothing = error $ "bad url " ++ s
|
||||
go (Just url) = do
|
||||
file <- liftIO $ url2file url
|
||||
bad = fromMaybe (error $ "bad url " ++ s) $
|
||||
parseURI $ escapeURIString isUnescapedInURI s
|
||||
go url = do
|
||||
let file = fromMaybe (url2file url) optfile
|
||||
showStart "addurl" file
|
||||
next $ perform s file
|
||||
|
||||
perform :: String -> FilePath -> CommandPerform
|
||||
perform url file = do
|
||||
fast <- Annex.getState Annex.fast
|
||||
if fast then nodownload url file else download url file
|
||||
perform url file = ifAnnexed file addurl geturl
|
||||
where
|
||||
geturl = do
|
||||
whenM (liftIO $ doesFileExist file) $
|
||||
error $ "not overwriting existing " ++ file
|
||||
fast <- Annex.getState Annex.fast
|
||||
if fast then nodownload url file else download url file
|
||||
addurl (key, _backend) = do
|
||||
setUrlPresent key url
|
||||
next $ return True
|
||||
|
||||
download :: String -> FilePath -> CommandPerform
|
||||
download url file = do
|
||||
|
@ -60,12 +74,8 @@ nodownload url file = do
|
|||
setUrlPresent key url
|
||||
next $ Command.Add.cleanup file key False
|
||||
|
||||
url2file :: URI -> IO FilePath
|
||||
url2file url = do
|
||||
whenM (doesFileExist file) $
|
||||
error $ "already have this url in " ++ file
|
||||
return file
|
||||
url2file :: URI -> FilePath
|
||||
url2file url = escape $ uriRegName auth ++ uriPath url ++ uriQuery url
|
||||
where
|
||||
file = escape $ uriRegName auth ++ uriPath url ++ uriQuery url
|
||||
escape = replace "/" "_" . replace "?" "_"
|
||||
auth = fromMaybe (error $ "bad url " ++ show url) $ uriAuthority url
|
||||
|
|
|
@ -83,13 +83,14 @@ merge_trees (Ref x) (Ref y) h = calc_merge h $ "diff-tree":diff_opts ++ [x, y]
|
|||
|
||||
{- For merging a single tree into the index. -}
|
||||
merge_tree_index :: Ref -> CatFileHandle -> Repo -> Streamer
|
||||
merge_tree_index (Ref x) h = calc_merge h $ "diff-index":diff_opts ++ ["--cached", x]
|
||||
merge_tree_index (Ref x) h = calc_merge h $
|
||||
"diff-index" : diff_opts ++ ["--cached", x]
|
||||
|
||||
diff_opts :: [String]
|
||||
diff_opts = ["--raw", "-z", "-r", "--no-renames", "-l0"]
|
||||
|
||||
{- Calculates how to perform a merge, using git to get a raw diff,
|
||||
- and returning a list suitable for update_index. -}
|
||||
- and generating update-index input. -}
|
||||
calc_merge :: CatFileHandle -> [String] -> Repo -> Streamer
|
||||
calc_merge ch differ repo streamer = gendiff >>= go
|
||||
where
|
||||
|
@ -100,7 +101,7 @@ calc_merge ch differ repo streamer = gendiff >>= go
|
|||
go (_:[]) = error "calc_merge parse error"
|
||||
|
||||
{- Given an info line from a git raw diff, and the filename, generates
|
||||
- a line suitable for update_index that union merges the two sides of the
|
||||
- a line suitable for update-index that union merges the two sides of the
|
||||
- diff. -}
|
||||
mergeFile :: String -> FilePath -> CatFileHandle -> Repo -> IO (Maybe String)
|
||||
mergeFile info file h repo = case filter (/= nullSha) [Ref asha, Ref bsha] of
|
||||
|
|
2
Usage.hs
2
Usage.hs
|
@ -76,6 +76,8 @@ paramDate :: String
|
|||
paramDate = "DATE"
|
||||
paramFormat :: String
|
||||
paramFormat = "FORMAT"
|
||||
paramFile :: String
|
||||
paramFile = "FILE"
|
||||
paramKeyValue :: String
|
||||
paramKeyValue = "K=V"
|
||||
paramNothing :: String
|
||||
|
|
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -9,6 +9,12 @@ git-annex (3.20120124) UNRELEASED; urgency=low
|
|||
a remote's location log.
|
||||
* S3: Fix irrefutable pattern failure when accessing encrypted S3
|
||||
credentials.
|
||||
* addurl: Added a --file option, which can be used to specify what
|
||||
file the url is added to. This can be used to override the default
|
||||
filename that is used when adding an url, which is based on the url.
|
||||
Or, when the file already exists, the url is recorded as another
|
||||
location of the file.
|
||||
* addurl: Normalize badly encoded urls.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Tue, 24 Jan 2012 16:21:55 -0400
|
||||
|
||||
|
|
|
@ -3,10 +3,9 @@ This bug is reopened to track some new UTF-8 filename issues caused by GHC
|
|||
encoding no longer works. Even unicode filenames fail to work when
|
||||
git-annex is built with 7.4. --[[Joey]]
|
||||
|
||||
I now have a `ghc7.4` branch in git that seems to solve this,
|
||||
This bug is now fixed in current master. Once again, git-annex will work
|
||||
for all filename encodings, and all system encodings. It will
|
||||
only build with the new GHC. If you have this problem, give it a try!
|
||||
--[[Joey]]
|
||||
only build with the new GHC. [[done]] --[[Joey]]
|
||||
|
||||
----
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ The git repository has some branches:
|
|||
library.
|
||||
* `tweak-fetch` adds support for the git tweak-fetch hook, which has
|
||||
been proposed and implemented but not yet accepted into git.
|
||||
* `ghc7.4` is for use this that version of ghc.
|
||||
* `ghc7.0` supports versions of ghc older than 7.4, which
|
||||
had a major change to filename encoding.
|
||||
* `setup` contains configuration for this website
|
||||
* `pristine-tar` contains [pristine-tar](http://kitenet.net/~joey/code/pristine-tar)
|
||||
data to create tarballs of any past git-annex release.
|
||||
|
|
|
@ -145,9 +145,14 @@ subdirectories).
|
|||
|
||||
* addurl [url ...]
|
||||
|
||||
Downloads each url to a file, which is added to the annex.
|
||||
Downloads each url to its own file, which is added to the annex.
|
||||
|
||||
To avoid immediately downloading the url, specify --fast
|
||||
To avoid immediately downloading the url, specify --fast.
|
||||
|
||||
To specify what file the url is added to, specify --file. This changes
|
||||
the behavior; now all the specified urls are recorded as alternate
|
||||
locations from which the file can be downloaded. In this mode, addurl
|
||||
can be used both to add new files, or to add urls to existing files.
|
||||
|
||||
# REPOSITORY SETUP COMMANDS
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue