Perhaps 'darcs send' should allow the user to add notes about the patch bundle they are sending? I find my self wanting to do that...

I think this code is ready for 'the big time', but perhaps people should comment on it. I have implemented it in the most conservative way I could think of. By default, if there is a 'postget' command defined, the user is prompted with the command displayed and asked if they would like to run it (yes or no). The command runs inside the newly created repository. I've also added command line switches for controlling this, and I've added some documentation for those switches. Here is a summary:
--no-postget   user is not prompted, and the command is not run
--run-postget  user is not prompted, and the command is run
--ask-postget  user is prompted, this is the default.

Using the word "postget" may be sort of confusing, but it has given me a nice handle for referring to this script hook.

I would like to write a few test cases, but that will have to wait till tomorrow. Also, since I don't know any perl and I'm terrible with bash I may need some help writing test cases. In the worst case, I can describe the expected behavior and maybe someone else can create the test cases (but I want to try it myself first).

Finally, the rationale for this feature is that now I can have a "central" repository with a special test defined (one that sends out email notification for successful patches), and I can use postget to set a different test for the copies of the repository. So, when someone gets a copy of the repo, the postget command will be run and it will modify test so that it no longer sends out email notification.

Comments?

Thanks,
Jason

On Aug 1, 2005, at 12:46 AM, Jason Dagit wrote:

Sun Jul 31 13:12:05 PDT 2005  Jason Dagit <[EMAIL PROTECTED]>
  * added postget to prefs
postget hold a command to be run on the local copy of a repository after running 'darcs get'. The goal is to help support central repositories. The "central" repository. The postget command can tweak the settings of the new copy as
  needed.

Mon Aug  1 00:39:28 PDT 2005  Jason Dagit <[EMAIL PROTECTED]>
  * added --no-postget, --run-postget, --ask-postget
Command line switches for controlling the new hook for get scripts. See the
  manual for details.

Mon Aug  1 00:41:36 PDT 2005  Jason Dagit <[EMAIL PROTECTED]>
  * implemented hook for get command/script
adds a pref 'postget' for a command that will be executed in the newly created
  copy of the repo after running get.

New patches:

[added postget to prefs
Jason Dagit <[EMAIL PROTECTED]>**20050731201205
postget hold a command to be run on the local copy of a repository after running 'darcs get'. The goal is to help support central repositories. The "central" repository. The postget command can tweak the settings of the new copy as
 needed.
] {
hunk ./SetPref.lhs 58
-valid_pref_data = ["test", "predist", "boringfile", "binariesfile"]
+valid_pref_data = ["test", "predist", "postget", "boringfile", "binariesfile"]
hunk ./SetPref.lhs 66
+\item ``postget'' --- a command to run locally after get.
}

[added --no-postget, --run-postget, --ask-postget
Jason Dagit <[EMAIL PROTECTED]>**20050801073928
Command line switches for controlling the new hook for get scripts. See the
 manual for details.
] {
hunk ./DarcsArguments.lhs 57
-                        set_scripts_executable,
+                        set_scripts_executable, ask_postget,
hunk ./DarcsArguments.lhs 922
+
+\begin{code}
+ask_postget :: DarcsOption
+ask_postget =
+    DarcsMultipleChoiceOption
+    [DarcsNoArgOption [] ["no-postget"] NoPostGet
+     "Do not run postget command",
+     DarcsNoArgOption [] ["run-postget"] RunPostGet
+     "Run postget command without asking",
+     DarcsNoArgOption [] ["ask-postget"] AskPostGet
+     "Prompt for whether to run postget command [DEFAULT]"]
+\end{code}
hunk ./DarcsFlags.lhs 66
+               | NoPostGet | RunPostGet | AskPostGet
hunk ./Get.lhs 29
-                                   Verbose, Quiet, Context ),
+                                   Verbose, Quiet, Context,
+ NoPostGet, RunPostGet, AskPostGet ),
hunk ./Get.lhs 33
-                        pristine_tree )
+                        pristine_tree,
+                        ask_postget )
hunk ./Get.lhs 98
-                                            pristine_tree]}
+                                            pristine_tree,
+                                            ask_postget]}
hunk ./Get.lhs 275
+\begin{options}
+--no-postget, --run-postget, --ask-postget
+\begin{options}
}

[implemented hook for get command/script
Jason Dagit <[EMAIL PROTECTED]>**20050801074136
adds a pref 'postget' for a command that will be executed in the newly created
 copy of the repo after running get.
] {
hunk ./Get.lhs 50
-import DarcsUtils ( catchall, formatPath, withCurrentDirectory )
+import DarcsUtils ( catchall, formatPath, withCurrentDirectory, askUser )
hunk ./Get.lhs 52
+import System ( ExitCode(..), system )
+import RepoPrefs ( get_prefval )
hunk ./Get.lhs 172
+  run_postget opts myname
hunk ./Get.lhs 282
+If there there is a postget command defined for the repository and you +do not want to run it, use the \verb!--no-postget! flag to disable the
+postget command.  Using \verb!--run-postget! will cause the postget
+command to be executed without prompting.  The default is
+\verb!--ask-postget! which will prompt before running the postget
+command.
hunk ./Get.lhs 289
+\begin{code}
+run_postget :: [DarcsFlag] -> FilePath -> IO ()
+run_postget opts localdir
+            | NoPostGet `elem` opts = return ()
+ | otherwise = do postget <- get_postget (fixFlagsToPostget opts)
+                             withCurrentDirectory localdir postget
+                             return ()
+
+get_postget :: [DarcsFlag] -> IO (IO ExitCode)
+get_postget opts =
+ let putInfo s = when (not $ Quiet `elem` opts) $ putStr s
+ in do
+ postgetline <- get_prefval "postget"
+ return $
+   case postgetline of
+   Nothing -> return ExitSuccess
+   Just code -> do
+ yorn <- maybeAskUser ("\nThe following command is set to execute after "++ + "successful get. Execute the following command "++
+                           "now (yes or no)?  "++code++"\n")
+     case yorn of ('y':_) -> do putInfo "Running postget...\n"
+                                ec <- system code
+                                if ec == ExitSuccess
+ then putInfo "Postget ran successfully.\n"
+                                   else putInfo "Postget failed!\n"
+                                return ec
+                  _ -> return ExitSuccess
+ where
+ maybeAskUser
+     | RunPostGet `elem` opts = \_ -> return "yes"
+     | AskPostGet `elem` opts = askUser
+     | otherwise = impossible
+
+fixFlagsToPostget :: [DarcsFlag] -> [DarcsFlag]
+fixFlagsToPostget xs
+                  | RunPostGet `elem` xs = xs
+                  | AskPostGet `elem` xs = xs
+                  | otherwise = AskPostGet:xs
+\end{code}
}

Context:

[remove TODO annotation for two tests that now pass.
David Roundy <[EMAIL PROTECTED]>**20050728115034]
[fix bug introduced in 208 fix which messed up --list-options output.
David Roundy <[EMAIL PROTECTED]>**20050729121804
We need to make sure that drop_paths doesn't do anything to an absolute
 path or URL.
]
[Merge changes
Ian Lynagh <[EMAIL PROTECTED]>**20050728230858]
[Don't die on sigALRM (linking with -threaded means we see loads of them)
Ian Lynagh <[EMAIL PROTECTED]>**20050728131023]
[Give help for 'c' in selectchanges
Ian Lynagh <[EMAIL PROTECTED]>**20050728125910]
[Update QueryManifest with the Repository changes
Ian Lynagh <[EMAIL PROTECTED]>**20050728185646]
[Merge changes
Florian Weimer <[EMAIL PROTECTED]>**20050607203225]
[Fix typo
Florian Weimer <[EMAIL PROTECTED]>**20050510113824]
[Test case for "query manifest"
Florian Weimer <[EMAIL PROTECTED]>**20050510113803]
[Remove the "query changes" and "query annotate" subcommands
Florian Weimer <[EMAIL PROTECTED]>**20050510060221]
[Do not mention file name in error message for disabled commands
Florian Weimer <[EMAIL PROTECTED]>**20050510054931

We have multiple configuration files, and we do not know tat this point which
 file contains the "disable" option.
]
[Remove --disable on supercommands
Florian Weimer <[EMAIL PROTECTED]>**20050510054744]
[Resolve conflict
Florian Weimer <[EMAIL PROTECTED]>**20050510054405]
[Add --help in command_options, like --disable
Florian Weimer <[EMAIL PROTECTED]>**20050510053348

 --list-options is still separate, to keep it undocumented.
]
[Resolve conflict
Florian Weimer <[EMAIL PROTECTED]>**20050510052119]
[Move --disable to the end of the option list
Florian Weimer <[EMAIL PROTECTED]>**20050510051905]
[Include the query subcommand documentation in Query.lhs
Florian Weimer <[EMAIL PROTECTED]>**20050510051533]
[Print usage information if the subcommand is missing
Florian Weimer <[EMAIL PROTECTED]>**20050509101427

 Add a separating line to the invalid subcommand error message.
]
[Fix empty lines in "darcs query --help" output
Florian Weimer <[EMAIL PROTECTED]>**20050509100509]
[Resolve conflicts
Florian Weimer <[EMAIL PROTECTED]>**20050509094729]
[Add the --disable option in command_options, not in run_the_command
Florian Weimer <[EMAIL PROTECTED]>**20050509093929

This change makes it possible to specialize the list of default commands
 (such as --disable) on different DarcsCommand constructors.
]
[Add --pending option to "query manifest"
Florian Weimer <[EMAIL PROTECTED]>**20050508080502]
[Add the --files and --directories options to "query manifest"
Florian Weimer <[EMAIL PROTECTED]>**20050507223327]
[Implement list_slurpy_dirs
Florian Weimer <[EMAIL PROTECTED]>**20050507223257]
[Add --null flag to the "query manifest" command
Florian Weimer <[EMAIL PROTECTED]>**20050507213547]
[Add "query manifest" command
Florian Weimer <[EMAIL PROTECTED]>**20050507163125]
[Implement the \haskell command for subcommands
Florian Weimer <[EMAIL PROTECTED]>**20050507160607]
[Mention the structure of subcommands in the documentation
Florian Weimer <[EMAIL PROTECTED]>**20050507151003]
[Handle subcommands in the preprocessor
Florian Weimer <[EMAIL PROTECTED]>**20050507150829

 You can use "\options{SUPER SUB}" to document the options of a
 subcommand.
]
[Do not include the "query" command in the manual
Florian Weimer <[EMAIL PROTECTED]>**20050507150707

The commands will be documented individually, in the relevant section.
]
[Mention "query" subcommands in the man page
Florian Weimer <[EMAIL PROTECTED]>**20050507135756

 "changes" is now documented as "query changes".  "query annotate" is
 mentioned, too.
]
[add subcommand infrastructure and (currently useless) query command.
David Roundy <[EMAIL PROTECTED]>**20050507115457
The idea of course is that this can be readily extended to add nice new
 simple subcommands under query.
]
[Include autoconf-detected libs in LDFLAGS
Joshua J. Berry <[EMAIL PROTECTED]>**20050728031609
Autoconf uses @LIBS@ -- not @LDFLAGS@ -- for libraries it detects (e.g. using
 AC_SEARCH_LIBS).
]
[resolve conflict with myself...
David Roundy <[EMAIL PROTECTED]>**20050727100745]
[fix pulling from a relative defaultrepo from within a subdirectory.
David Roundy <[EMAIL PROTECTED]>**20050722105708
 This is a fix for bug #208.  It is perhaps a tad more invasive than
 necesary, and introduces a FilePathUtils module that is perhaps
 overkill... especially since it doesn't do much.
]
[Small tweaks to the with_new_pending patch
Ian Lynagh <[EMAIL PROTECTED]>**20050727025308]
[replace write_pending with "with_new_pending".
David Roundy <[EMAIL PROTECTED]>**20050722125725
This patch is basically an extension of Ian's earlier patch that created a
 "write_pending_then" function.  This one creates two functions,
 with_new_pending and add_to_pending.

The idea is that we can't check if a new pending is valid until after we've
 updated the pristine cache.  But it's possible that the pending patch
itself was lazily generated with get_unrecorded, in which case it's not safe to modify the pristine cache until after we've written pending. This new interface makes it much harder to make this kind of mistake. I also
 think it's pretty intuitive.
]
[Removed an unused reference to Slurpy
Ian Lynagh <[EMAIL PROTECTED]>**20050709114603]
[new changelog entries.
David Roundy <[EMAIL PROTECTED]>**20050726123329]
[clean up formatting in Depends.
David Roundy <[EMAIL PROTECTED]>**20050723130807]
[changelog entry for fix to RT#208.
David Roundy <[EMAIL PROTECTED]>**20050722113803]
[make make_changelog a bit more flexible in its parsing.
David Roundy <[EMAIL PROTECTED]>**20050722113701
 One can now have blank lines between the match: lines and the actual
 comments.
]
[give better error message when dealing with a non-repository.
David Roundy <[EMAIL PROTECTED]>**20050722105908]
[make make_changelog ignore boring files (emacs backups) in changelog.in/entries/.
David Roundy <[EMAIL PROTECTED]>**20050726121455]
[add changelog entry for get --partial fix.
David Roundy <[EMAIL PROTECTED]>**20050723130715]
[scrunch up the tla/cvs tables a bit in the manual.
David Roundy <[EMAIL PROTECTED]>**20050724181011]
[another alternative formatting for cvs/tla tables.
Erik Schnetter <[EMAIL PROTECTED]>**20050724134656]
[fix bug in get_patches_beyond_tag that broke get --partial.
David Roundy <[EMAIL PROTECTED]>**20050723125507
 The bug was that we sometimes looked at patches that weren't strictly
necesary. This was because of the concat in get_patches_beyond_tag, which loses information about tag dependencies. A clean implementation of a get_extra that accepts a true PatchSet would be a nicer fix (since it might
 fix other similar problems), but this fix is also correct and simple.
]
[alternative formatting for cvs/tla tables.
Erik Schnetter <[EMAIL PROTECTED]>**20050724113905]
[make add/remove --list-options not output preceding ./
David Roundy <[EMAIL PROTECTED]>**20050723134758
 We were treating the repository root differently from subdirectories
because the file paths didn't need to get "fixed". Addresses bug #158.
]
[fix unit test that prompts for input
Will <[EMAIL PROTECTED]>**20050722181028]
[put configure.ac back in the public domain.
David Roundy <[EMAIL PROTECTED]>**20050720115702]
[advance DARCS_VERSION to 1.0.4pre2.
David Roundy <[EMAIL PROTECTED]>**20050720115536
In the new tradition of changing the version after a release rather than before a release (although when the release type changes to rc or actual
 release it'll have to be done before the release).
]
[drop $srcdir use; build-directories aren't supported anyway
Peter Simons <[EMAIL PROTECTED]>**20050719140044]
[clean generated manual files at realclean
Peter Simons <[EMAIL PROTECTED]>**20050719135935]
[cosmetic changes
Peter Simons <[EMAIL PROTECTED]>**20050719135834]
[move comment to the right place
Peter Simons <[EMAIL PROTECTED]>**20050719135818]
[let config.status generate config.command
Peter Simons <[EMAIL PROTECTED]>**20050719135733]
[make use of autoconf 2.5x's AC_INIT macro
Peter Simons <[EMAIL PROTECTED]>**20050719135611]
[use ./config.status to re-configure build after autoconf changes
Peter Simons <[EMAIL PROTECTED]>**20050719135435]
[update distclean and realclean targets
Peter Simons <[EMAIL PROTECTED]>**20050719135415]
[canonize [EMAIL PROTECTED]
Peter Simons <[EMAIL PROTECTED]>**20050719134834]
[cosmetic change
Peter Simons <[EMAIL PROTECTED]>**20050719134816]
[update test suite to work with Peter's makefile changes.
David Roundy <[EMAIL PROTECTED]>**20050721102319]
[fix error in name of --reorder-patches flag.
David Roundy <[EMAIL PROTECTED]>**20050722110752]
[Make DarcsRepo.add_to_inventory take a list.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20050720174029
This avoids opening the inventory multiple times. Thanks to Ian for the hint.
]
[Use mapM_ instead of the comprehensible alternative.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20050720164258
Mentioning mapM_ always impresses people at dinner parties. Thanks to
 Ian for the hint.
]
[Move iterateGitTree out of the IO monad.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20050720162841
 We're reading immutable on-disk data, it's safe to do it unsafely.
]
[Clean up usage of interleaveIO in Git.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20050720162251]
[TAG 1.0.4pre1
David Roundy <[EMAIL PROTECTED]>**20050718112234]
[make configure automatically guess the release state based on defaultrepo and tags.
David Roundy <[EMAIL PROTECTED]>**20050718112222]
[fix write_problem to show all problems.
David Roundy <[EMAIL PROTECTED]>**20050717110628]
[don't import head and tail, which are in the prelude.
David Roundy <[EMAIL PROTECTED]>**20050716143547]
[Push and pull can now show the detailed diffs of patches
Jim Radford <[EMAIL PROTECTED]>**20050717042645
 The same distinction is now made between --summary and --verbose
 as changes makes.
]
[Rename bound variable in fromJust macro.
Juliusz Chroboczek <[EMAIL PROTECTED]>**20050716221705
Avoids ``shadows existing variable'' warnings which for some reason are
 errors.

 Could we please use Lisp macros instead?
]
[TAG 2005-07-18
Ian Lynagh <[EMAIL PROTECTED]>**20050718193534]
Patch bundle hash:
49e81fa60eb09670f3c21825915ae51eb87b7bb2
_______________________________________________
darcs-devel mailing list
[email protected]
http://www.abridgegame.org/cgi-bin/mailman/listinfo/darcs-devel



_______________________________________________
darcs-devel mailing list
[email protected]
http://www.abridgegame.org/cgi-bin/mailman/listinfo/darcs-devel

Reply via email to