in

CodePrairie .NET

South Dakota .NET User Group

chrisortman

January 2008 - Posts

  • Creating Subversion patches with git

    Adam expressed his frustration with creating tortoise compatible patches using git.

    He mentions a script that will do the job, which I have not yet tried. However if you are using git on windows you most likely have cygwin installed which you can use to install the patch.exe program.

    But first you need a patch file.

    This is pretty simple

    In my example I'm going to be creating a patch to fix FACILITIES-97 in castle project.

    First I need my local git repo ready

    git co -b bugs/facilities-97 castle-svn/trunk

    Now edit / test

    When you're all done prepare your index and commit

    git add .
    git commit -m "fixes (FACILITIES-97)"

    Now create your patch

    git format-patch castle-svn/trunk

    That last command will create a patch file for every commit that is in bugs/facilities-97 but not in castle-svn/trunk
    In this case I have a single commit so it creates 0001-fixes-FACILITIES-97.patch

    Now that you've got your patches they can be applied to svn like this

    patch -p1 -i 0001-fixes-FACILITIES-97.patch

    Now here's the gotcha. patch.exe can either read stdin or take a named file. My patches would always fail if I used stdin, so using -i to specify the filename is important.
    The -p1 switch tells patch to strip the first part of the path in the patch file because git generates file paths like
    /a/InversionOfControl/MicroKernel.....

    That's it, you're all done.

  • Which for Windows

    One thing I love about *nix is the which command which will tell me where a certain file is located if it is in my path.

    Say I have patch.exe in my path somewhere, but I don't know where, here's a quick powershell script to find out:

     

    foreach($p in $env:path.split(";")) { gci $p/patch.*}
  • Catching up with Castle trunk 4710

    I've just got done updating one of my projects from castle trunk 4044 to trunk 4710 and given the amount of changes thought I would share.

    First things first, fix up those compiler errors. I had quite a few, but they were easy and pretty much the same few things:

    • Rename IRailsEngineContext to IEngineContext
    • Change Filter methods to accept IController and IControllerContext instead of just Controller.
    • No more Context.Url, now it is Context.Request.Url
    • SetController method on helpers has changed to take IController and IControllerContext instead of Controller.
    • Since helpers now use IController instead of Controller there may be several missing methods or properties so just cast it to an instance of Controller.

     

    I'm so glad I have unit tests. When I first ran them I had many failures, but it was one fix:

    Error:

    Inner Exception
    NHibernate.HibernateException
    Message: Could not instantiate dialect class
    Source: NHibernate

    Problem:

    The key names for NHibernate configuration have changed

    Solution:

    Change your ActiveRecord configuration entries from this

    <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />

    to

    <add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />

     

    Then to get my site up and running:

    Error:

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
    Parser Error Message: Could not load type 'Castle.MonoRail.Framework.EngineContextModule'

    Problem:

    There is no more EngineContextModule

    Solution:

    Remove this from web.config <add name="monorail" type="Castle.MonoRail.Framework.EngineContextModule, Castle.MonoRail.Framework" />

     

    Error:

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
    Parser Error Message: An error occurred creating the configuration section handler for Brail: Could not load file or assembly 'Boo.Lang.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=32c39770e9a21a67' or one of its dependencies. The system cannot find the file specified.

    Problem:

    A new boo assembly has been added

    Solution:

    Add a reference to Boo.Lang.Extensions to your web project.

     

    Error:

    CommonScripts\Extensions.brail(7,9): BCE0044: Boo.Lang.Compiler.CompilerError: expecting "end", found 'except'. ---> CommonScripts\Extensions.brail:7:9: expecting "end", found 'except'

    Problem:

    I had defined an extension method in one of my brail common scripts that looked like

    [Boo.Lang.ExtensionAttribute]
    static def IsEmpty(val as duck) as bool:
    	try:
    		return true if val is null
    		return val.GetEnumerator().MoveNext() == false
    	end
    	except e as System.MissingMethodException:
    		return true
    	end
    end

    Solution:

    [Boo.Lang.ExtensionAttribute]
    static def IsEmpty(val as duck) as bool:
    	try:
    		return true if val is null
    		return val.GetEnumerator().MoveNext() == false
    	except e as System.MissingMethodException:
    		return true
    	end
    end

     

    Of note:

    Because of the new way MonoRail resolves its service container you can remove the useWindsorIntegration flag from your configuration. I think this will also mean you don't need to register a custom logging service as well.

  • Limitations of svn branching

    I generally run all my projects that use castle off the trunk. However it has been several months since I've taken any updates, mostly due to lack of time on my part.

    As I'm upgrading there are many many changes which require me to update my code. Most due to the introduction of IController and changes from IRailsEngineContext.

     

    One such instance is IResponse.BinaryWrite which seems to no longer be available.

    As I dig through svn to try to find if there is a replacement method or why it was removed etc I am hit right in the face with how poorly svn handles branching and merging. The only log message in the trunk is that all these changes were merged back in in one giant commit. If you want to go see what those changes were you need to go look through the branch that was merged, but even then there's no way of knowing exactly which changes were pulled ( I just assume all.)

    With git I would be able to see these sort of things and save myself a lot of time.

Powered by Community Server (Commercial Edition), by Telligent Systems