[darcs-devel] [PR#99]: patch for review.
Karel Gardas
kgardas at objectsecurity.com
Tue Dec 14 05:17:29 PST 2004
Hello,
I would like to give PR#99 a try, but I'm not sure if I've chosen
acceptable way of doing things, i.e. hacking slurp_write directly to set
file mode. The patch which adds --set-shebang-scripts-executable option to
get command is below for your review. If you are ok with it I will try
to continue with other commands. FYI: currently I set exec for both user
and group, do you think we should use some kind of configuration mechainsm
(prefs) for this?
Thanks for review!
Karel
--
Karel Gardas kgardas at objectsecurity.com
ObjectSecurity Ltd. http://www.objectsecurity.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
New patches:
[add infrastructure for --set-shebang-scripts-executable command option
Karel Gardas <kgardas at objectsecurity.com>**20041213212029
This patch adds basic argument infrastructure for
--set-shebang-scripts-executable command option
] {
hunk ./DarcsArguments.lhs 56
+ set_shebang_scripts_executable,
hunk ./DarcsArguments.lhs 866
+
+set_shebang_scripts_executable :: DarcsOption
+set_shebang_scripts_executable = DarcsNoArgOption [] ["set-shebang-scripts-executable"] SetShebangScriptsExecutable
+ "mark shell script as executable"
+
hunk ./DarcsFlags.lhs 61
- - | Disable
+ | Disable | SetShebangScriptsExecutable
}
[add slurp_write_exec and slurp_write_dirty_exec functions
Karel Gardas <kgardas at objectsecurity.com>**20041213231314
This patch adds slurp_write_exec and slurp_write_dirty_exec functions
and modifies slurp_write and slurp_write_dirty to use those
functions. The main idea is to use slurp_*_exec functions for future
commands enhancements to support --set-shebang-scripts-executable
option.
] {
hunk ./SlurpDirectory.lhs 32
+ slurp_write_exec, slurp_write_dirty_exec,
hunk ./SlurpDirectory.lhs 61
+ setFileMode, unionFileModes, ownerExecuteMode, groupExecuteMode, fileMode
hunk ./SlurpDirectory.lhs 511
- -slurp_write :: Slurpy -> IO ()
- -slurp_write (SlurpDir d p ss) = block $
+slurp_write_exec :: Bool -> Slurpy -> IO ()
+slurp_write_exec exec (SlurpDir d p ss) = block $
hunk ./SlurpDirectory.lhs 517
- - sequence_ $ map slurp_write ss
- -slurp_write (SlurpFile f dirt (mt,_) ls) =
+ sequence_ $ map (slurp_write_exec exec) ss
+slurp_write_exec exec (SlurpFile f dirt (mt,_) ls) =
hunk ./SlurpDirectory.lhs 521
+ if exec
+ then mark_exec f ls
+ else return ()
+
+mark_exec :: FileName -> FileContents -> IO ()
+mark_exec f ls =
+ do let fl = unpackPS (head (readAntiMemo (fst ls)))
+ fp = fn2fp f
+ in
+ if length fl > 2 && ((head fl) == '#') && ((head (tail fl)) == '!')
+ then do
+ stat <- getFileStatus fp
+ setFileMode fp (unionFileModes (unionFileModes (fileMode stat) ownerExecuteMode) groupExecuteMode)
+ else return ()
+
+slurp_write :: Slurpy -> IO ()
+slurp_write x = slurp_write_exec False x
hunk ./SlurpDirectory.lhs 564
- -slurp_write_dirty :: Slurpy -> IO ()
- -slurp_write_dirty (SlurpDir d p ss) = block $
+slurp_write_dirty_exec :: Bool -> Slurpy -> IO ()
+slurp_write_dirty_exec exec (SlurpDir d p ss) = block $
hunk ./SlurpDirectory.lhs 568
- - sequence_ $ map slurp_write_dirty ss
+ sequence_ $ map (slurp_write_dirty_exec exec) ss
hunk ./SlurpDirectory.lhs 570
- -slurp_write_dirty (SlurpFile f dirt _ ls)
+slurp_write_dirty_exec exec (SlurpFile f dirt _ ls)
hunk ./SlurpDirectory.lhs 572
- - | otherwise = writeContents f ls
+ | otherwise = do
+ writeContents f ls
+ if exec
+ then mark_exec f ls
+ else return ()
+
+slurp_write_dirty :: Slurpy -> IO ()
+slurp_write_dirty x = slurp_write_dirty_exec False x
}
[enhance `get' command to support --set-shebang-scripts-executable option
Karel Gardas <kgardas at objectsecurity.com>**20041214123906] {
hunk ./Get.lhs 29
- - Verbose, Quiet, Context ),
+ Verbose, Quiet, Context, SetShebangScriptsExecutable ),
hunk ./Get.lhs 31
- - match_one_context, set_default,
+ match_one_context, set_default, set_shebang_scripts_executable
hunk ./Get.lhs 40
- -import SlurpDirectory ( slurp_write, slurp_write_dirty, empty_slurpy )
+import SlurpDirectory ( slurp_write_exec, slurp_write_dirty_exec, empty_slurpy )
hunk ./Get.lhs 98
- - set_default]}
+ set_default,
+ set_shebang_scripts_executable]}
hunk ./Get.lhs 138
- - slurp_write s
+ slurp_write_exec (SetShebangScriptsExecutable `elem` opts) s
hunk ./Get.lhs 151
- - Just s -> slurp_write_dirty s
+ Just s -> slurp_write_dirty_exec (SetShebangScriptsExecutable `elem` opts) s
}
Context:
[make darcs changes --context work on an empty repo.
David Roundy <droundy at abridgegame.org>**20041212140800]
[TAG 1.0.1rc3
David Roundy <droundy at abridgegame.org>**20041211192656]
Patch bundle hash:
2715e4e7e6d1a983f8ca7f7df677dfaebf1ea121
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: http://www.mico.org/~karel/kgardas_at_objectsecurity_dot_com.gpg
iD8DBQFBvuaYqREvenJ7UIYRAuFAAKCEdqW6dQrKGl3acWMyCOYW1ENfLQCgllqE
6fRqZHDyM2c+hNVHKF/xxis=
=lI6b
-----END PGP SIGNATURE-----
More information about the darcs-devel
mailing list