[commit: packages/Cabal] ghc-head: init: generate build-depends with >=x.x && <x.y syntax instead of ==x.* (3ef4f03)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:25:11 CEST 2013


Repository : ssh://git@git.haskell.org/Cabal

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=3ef4f03ceeed85525c5e2b7691627a177eb984df

>---------------------------------------------------------------

commit 3ef4f03ceeed85525c5e2b7691627a177eb984df
Author: Brent Yorgey <byorgey at cis.upenn.edu>
Date:   Tue May 14 14:46:03 2013 -0400

    init: generate build-depends with >=x.x && <x.y syntax instead of ==x.*
    
    fixes #1329.


>---------------------------------------------------------------

3ef4f03ceeed85525c5e2b7691627a177eb984df
 cabal-install/Distribution/Client/Init.hs |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/cabal-install/Distribution/Client/Init.hs b/cabal-install/Distribution/Client/Init.hs
index 60b27d0..e978141 100644
--- a/cabal-install/Distribution/Client/Init.hs
+++ b/cabal-install/Distribution/Client/Init.hs
@@ -54,7 +54,7 @@ import Text.PrettyPrint hiding (mode, cat)
 import Data.Version
   ( Version(..) )
 import Distribution.Version
-  ( orLaterVersion, withinVersion, VersionRange )
+  ( orLaterVersion, earlierVersion, intersectVersionRanges, VersionRange )
 import Distribution.Verbosity
   ( Verbosity )
 import Distribution.ModuleName
@@ -400,7 +400,18 @@ chooseDep flags (m, Just ps)
                             (pvpize . maximum . map P.pkgVersion $ pids)
 
     pvpize :: Version -> VersionRange
-    pvpize v = withinVersion $ v { versionBranch = take 2 (versionBranch v) }
+    pvpize v = orLaterVersion v'
+               `intersectVersionRanges`
+               earlierVersion (incVersion 1 v')
+      where v' = (v { versionBranch = take 2 (versionBranch v) })
+
+incVersion :: Int -> Version -> Version
+incVersion n (Version vlist tags) = Version (incVersion' n vlist) tags
+  where
+    incVersion' 0 []     = [1]
+    incVersion' 0 (v:_)  = [v+1]
+    incVersion' m []     = replicate m 0 ++ [1]
+    incVersion' m (v:vs) = v : incVersion' (m-1) vs
 
 ---------------------------------------------------------------------------
 --  Prompting/user interaction  -------------------------------------------





More information about the ghc-commits mailing list