This implements a minimal check to help future repositories avoid issue53
trouble.
Note that this uses the System.FilePath package, but /only/ to do the
Windows filepath validity check... which is as far as I think we should
take it for darcs 2.0.3.
I can admit openly that I have somewhat nefarious albeit slow and *cautious*
plans for extending our use of System.FilePath in darcs. For example, I agree
that it is a bad idea to use System.FilePath in our representation of patch
filepaths. But I also think that we could start with some code that 'merely'
interacts with the real world (for example, creating temporary files) and
gradually move on to intergrating this with our path-fixing code.
In any case, now we're just worrying about Windows validity, and this I
think is the way to go about it.
P.S. I think I could re-send this without the refactor as well.
Mon Sep 22 15:05:20 BST 2008 Eric Kow <[EMAIL PROTECTED]>
* Check for filepath package in configure.
Mon Sep 22 15:15:32 BST 2008 Eric Kow <[EMAIL PROTECTED]>
* Add --reserved-ok flag for darcs add and mv.
This is just the flag, not the actual effect.
Mon Sep 22 15:43:04 BST 2008 Eric Kow <[EMAIL PROTECTED]>
* Refactor file checking in add command.
Mon Sep 22 16:22:38 BST 2008 Eric Kow <[EMAIL PROTECTED]>
* Resolve issue53: check for Windows filename validity in darcs add/mv.
Mon Sep 22 16:22:56 BST 2008 Eric Kow <[EMAIL PROTECTED]>
* Add test for issue53.
New patches:
[Check for filepath package in configure.
Eric Kow <[EMAIL PROTECTED]>**20080922140520] hunk ./configure.ac 158
AC_SUBST(HAVE_HTTP)
+dnl Look for System.FilePath
+
+GHC_CHECK_MODULE(System.FilePath, filepath, isValid,,
+ AC_MSG_ERROR(Cannot find System.FilePath; try installing the Haskell package filepath?))
+
dnl See if we need a package for QuickCheck
GHC_CHECK_MODULE(Test.QuickCheck( quickCheck ), QuickCheck, quickCheck True,,
[Add --reserved-ok flag for darcs add and mv.
Eric Kow <[EMAIL PROTECTED]>**20080922141532
This is just the flag, not the actual effect.
] hunk ./src/Darcs/Arguments.lhs 208
getContent NoAllowConflicts = NoContent
getContent Boring = NoContent
getContent AllowCaseOnly = NoContent
+getContent AllowWindowsReserved = NoContent
getContent DontGrabDeps = NoContent
getContent Compress = NoContent
getContent NoCompress = NoContent
hunk ./src/Darcs/Arguments.lhs 1058
\begin{code}
noskip_boring = DarcsNoArgOption [] ["boring"]
Boring "don't skip boring files"
-allow_caseonly = DarcsNoArgOption [] ["case-ok"]
- AllowCaseOnly "don't refuse to add files differing only in case"
+allow_caseonly = DarcsMultipleChoiceOption
+ [DarcsNoArgOption [] ["case-ok"] AllowCaseOnly
+ "don't refuse to add files differing only in case"
+ ,DarcsNoArgOption [] ["reserved-ok"] AllowWindowsReserved
+ "don't refuse to add files with Windows-reserved names"
+ ]
diffflags = DarcsArgOption [] ["diff-opts"]
DiffFlags "OPTIONS" "options to pass to diff"
\end{code}
replace ./src/Darcs/Arguments.lhs [A-Za-z_0-9] allow_caseonly allow_problematic_filenames
replace ./src/Darcs/Commands/Add.lhs [A-Za-z_0-9] allow_caseonly allow_problematic_filenames
replace ./src/Darcs/Commands/Mv.lhs [A-Za-z_0-9] allow_caseonly allow_problematic_filenames
hunk ./src/Darcs/Flags.lhs 57
| Toks String
| EditLongComment | NoEditLongComment | PromptLongComment
| AllowConflicts | MarkConflicts | NoAllowConflicts
- | Boring | AllowCaseOnly
+ | Boring | AllowCaseOnly | AllowWindowsReserved
| DontGrabDeps | Compress | NoCompress | UnCompress
| WorkDir String | RepoDir String | RemoteRepo String
| Reply String | ApplyAs String
[Refactor file checking in add command.
Eric Kow <[EMAIL PROTECTED]>**20080922144304] hunk ./src/Darcs/Commands/Add.lhs 176
where
addp' :: Slurpy -> FilePath -> IO (Slurpy, Maybe (FL Prim), Maybe FilePath)
addp' cur f =
- if (if gotAllowCaseOnly
- then slurp_has f cur
- else slurp_has_anycase f cur)
- then do return (cur, Nothing, Just f)
- else do
- isdir <- doesDirectoryReallyExist f
- if isdir
- then trypatch $ myadddir f
- else do isfile <- doesFileReallyExist f
- if isfile
- then trypatch $ myaddfile f
- else do islink <- isFileReallySymlink f
- if islink then
- putInfo $ "Sorry, file " ++ f ++ " is a symbolic link, which is unsupported by darcs."
- else putInfo $ "File "++ f ++" does not exist!"
- return (cur, Nothing, Nothing)
- where trypatch p =
+ do ftype <- getFileType f
+ case ftype of
+ _ | already_has -> return (cur, Nothing, Just f)
+ Directory -> trypatch $ myadddir f
+ File -> trypatch $ myaddfile f
+ SymLink -> do putInfo $ "Sorry, file " ++ f ++ " is a symbolic link, which is unsupported by darcs."
+ return add_failure
+ NonExistent -> do putInfo $ "File "++ f ++" does not exist!"
+ return add_failure
+ where already_has = if gotAllowCaseOnly
+ then slurp_has f cur
+ else slurp_has_anycase f cur
+ add_failure = (cur, Nothing, Nothing)
+ trypatch p =
case apply_to_slurpy p cur of
Nothing -> do putInfo $ msg_skipping msgs ++ " '" ++ f ++ "' ... " ++ parent_error
return (cur, Nothing, Nothing)
hunk ./src/Darcs/Commands/Add.lhs 209
then addfile (d++"-"++date) :>:
move (d++"-"++date) d :>: NilFL
else addfile d :>: NilFL
-
putVerbose = if Verbose `elem` opts || DryRun `elem` opts
then putStrLn
else \_ -> return ()
hunk ./src/Darcs/Commands/Add.lhs 216
gotFancyMoveAdd = FancyMoveAdd `elem` opts
gotAllowCaseOnly = AllowCaseOnly `elem` opts
+data FileType = Directory | File | SymLink | NonExistent
+
+getFileType :: FilePath -> IO FileType
+getFileType f =
+ do isDir <- doesDirectoryReallyExist f
+ if isDir
+ then return Directory else do
+ isFile <- doesFileReallyExist f
+ if isFile
+ then return File else do
+ isLink <- isFileReallySymlink f
+ if isLink
+ then return SymLink
+ else return NonExistent
+
data AddMessages =
AddMessages
{ msg_skipping :: String
[Resolve issue53: check for Windows filename validity in darcs add/mv.
Eric Kow <[EMAIL PROTECTED]>**20080922152238] hunk ./src/Darcs/Commands/Add.lhs 29
fancy_move_add,
recursive, working_repo_dir, dry_run_noxml, umask_option,
list_files, list_unregistered_files,
- DarcsFlag (AllowCaseOnly, Boring, Recursive,
- Verbose, Quiet, FancyMoveAdd, DryRun),
+ DarcsFlag (AllowCaseOnly, AllowWindowsReserved, Boring, Recursive,
+ Verbose, Quiet, FancyMoveAdd, DryRun),
fixSubPaths,
)
import Darcs.Utils ( withCurrentDirectory, nubsort )
hunk ./src/Darcs/Commands/Add.lhs 50
import Darcs.Repository.Prefs ( darcsdir_filter, boring_file_filter )
import Data.Maybe ( maybeToList )
import System.IO ( hPutStrLn, stderr )
+import qualified System.FilePath.Windows as WindowsFilePath
\end{code}
\begin{code}
hunk ./src/Darcs/Commands/Add.lhs 180
do ftype <- getFileType f
case ftype of
_ | already_has -> return (cur, Nothing, Just f)
+ | is_badfilename -> do putInfo $ "The filename " ++ f ++ " is invalid under Windows.\nUse --reserved-ok to allow it."
+ return add_failure
Directory -> trypatch $ myadddir f
File -> trypatch $ myaddfile f
SymLink -> do putInfo $ "Sorry, file " ++ f ++ " is a symbolic link, which is unsupported by darcs."
hunk ./src/Darcs/Commands/Add.lhs 191
where already_has = if gotAllowCaseOnly
then slurp_has f cur
else slurp_has_anycase f cur
+ is_badfilename = not (gotAllowWindowsReserved || WindowsFilePath.isValid f)
add_failure = (cur, Nothing, Nothing)
trypatch p =
case apply_to_slurpy p cur of
hunk ./src/Darcs/Commands/Add.lhs 219
putInfo = if Quiet `elem` opts then \_ -> return () else hPutStrLn stderr
gotFancyMoveAdd = FancyMoveAdd `elem` opts
gotAllowCaseOnly = AllowCaseOnly `elem` opts
+ gotAllowWindowsReserved = AllowWindowsReserved `elem` opts
data FileType = Directory | File | SymLink | NonExistent
hunk ./src/Darcs/Commands/Mv.lhs 27
import Darcs.SignalHandler ( withSignalsBlocked )
import Darcs.Commands ( DarcsCommand(..), nodefaults )
-import Darcs.Arguments ( DarcsFlag( AllowCaseOnly ),
+import Darcs.Arguments ( DarcsFlag( AllowCaseOnly, AllowWindowsReserved ),
fixSubPaths, working_repo_dir,
list_files, allow_problematic_filenames, umask_option,
)
hunk ./src/Darcs/Commands/Mv.lhs 44
import Darcs.SlurpDirectory ( Slurpy, slurp, slurp_has, slurp_has_anycase,
slurp_remove, slurp_hasdir, slurp_hasfile )
import FileName ( fp2fn, fn2fp, super_name )
+import qualified System.FilePath.Windows as WindowsFilePath
#include "impossible.h"
\end{code}
hunk ./src/Darcs/Commands/Mv.lhs 141
check_new_and_old_filenames
:: [DarcsFlag] -> Slurpy -> Slurpy -> (FilePath, FilePath) -> IO (Maybe Prim)
check_new_and_old_filenames opts cur work (old,new) = do
+ unless (AllowWindowsReserved `elem` opts || WindowsFilePath.isValid new) $
+ fail $ "The filename " ++ new ++ " is not valid under Windows.\n" ++
+ "Use --reserved-ok to allow such filenames."
maybe_add_file_thats_been_moved <-
if slurp_has old work -- We need to move the object
then do unless (slurp_hasdir (super_name $ fp2fn new) work) $
[Add test for issue53.
Eric Kow <[EMAIL PROTECTED]>**20080922152256] addfile ./tests/issue53.sh
hunk ./tests/issue53.sh 1
+#!/usr/bin/env bash
+
+set -ev
+
+# The builtin ! has the wrong semantics for not.
+not () { "$@" && exit 1 || :; }
+
+if echo $OS | grep -i windows; then
+ echo This test does not work under Windows
+ exit 0
+fi
+
+# pull from not empty repo to empty repo
+rm -rf temp1
+mkdir temp1
+
+cd temp1
+darcs init
+echo a > Aux.hs
+not darcs add Aux.hs
+darcs add --reserved-ok Aux.hs
+echo b > foo
+darcs add foo
+darcs record -am 'two files'
+not darcs mv foo com1
+darcs mv --reserved-ok foo com1
+cd ..
+
+rm -rf temp1
Context:
[fix bug I introduced into issue1039 test.
David Roundy <[EMAIL PROTECTED]>**20080921213043
Ignore-this: 5b3c6476abae6bb050be014555d05bbe
]
[Fix hang after a user input error (for example, EOF).
Judah Jacobson <[EMAIL PROTECTED]>**20080918163017]
[replace consRLSealed with a more general mapFlipped.
David Roundy <[EMAIL PROTECTED]>**20080921185241
Ignore-this: c28f73f165254582cba6a14ba6ce93
]
[make issue1039 fix allow small dissimilar repositories.
David Roundy <[EMAIL PROTECTED]>**20080921184515
Ignore-this: 918a09df18ef48c649c1bfaa866d6176
]
[revert refactor that breaks type witnesses.
David Roundy <[EMAIL PROTECTED]>**20080921182331
Ignore-this: dd692cffc1a238d6726448bacfe9cacc
]
[Add '--ignore-unrelated-repos' option to disable unrelated repositories check.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919152631]
[Resolve issue1039: detect seemingly unrelated repositories when doing push, pull and send.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919144553]
[Refactor in pull_cmd.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919135349
Ignore-this: e26a489a7a53aeaba544ae5ad0006700
]
[Test for issue1039.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919153011]
[manual: add an example of record --pipe prompts similar to tag --pipe docs
Simon Michael <[EMAIL PROTECTED]>**20080918205353]
[user manual corrections regarding what record and tag --pipe prompt for
Simon Michael <[EMAIL PROTECTED]>**20080918204500]
[clarify the short help for --pipe
Simon Michael <[EMAIL PROTECTED]>**20080918193717]
[Use gmakeisms for prettier output.
Trent W. Buck <[EMAIL PROTECTED]>**20080919071358]
[Spaces in Darcs.Arguments.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919150440]
[Spaces in Darcs.Commands.Send.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919150139]
[Spaces in Darcs.Commands.Pull.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919145812]
[Spaces in Darcs.Commands.Push.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919145553]
[Print "We have the following patches to send:" only when we really have somthing to send.
Dmitry Kurochkin <[EMAIL PROTECTED]>**20080919114229]
[fix changes.pl test (translating to bash)
David Roundy <[EMAIL PROTECTED]>**20080917182432
Ignore-this: 5f8bc7e1f9eadc073402a935142281c4
This test made assumptions such as that darcs wouldn't ever add a long
comment to its internal representation of changes, which are now
broken.
]
[hokey fix to allow unit tests to generate random input.
David Roundy <[EMAIL PROTECTED]>**20080917170913
Ignore-this: 31e847e82eef741f4c6cc857fd79a245
A nicer fix would be to move namepatch and patchinfo into some sort of
random-number monad rather than leaving them in IO and using
unsafePerformIO in the example-generation scripts.
]
[resolve issue27: add junk to patch identifiers.
David Roundy <[EMAIL PROTECTED]>**20080917154657
Ignore-this: b91ab6f6e05e0fda25488fa51653b741
]
[TAG 2.0.3pre1
Eric Kow <[EMAIL PROTECTED]>**20080918023645]
Patch bundle hash:
faed4d6ca6f3a1a2d6b3909cd2fd1a09b073cee5
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users