Hello community, here is the log from the commit of package ghc-diff3 for openSUSE:Factory checked in at 2017-03-14 10:04:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-diff3 (Old) and /work/SRC/openSUSE:Factory/.ghc-diff3.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-diff3" Tue Mar 14 10:04:35 2017 rev:2 rq:461624 version:0.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-diff3/ghc-diff3.changes 2016-09-25 14:41:45.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-diff3.new/ghc-diff3.changes 2017-03-14 10:04:36.268880990 +0100 @@ -1,0 +2,5 @@ +Sun Feb 12 14:19:13 UTC 2017 - [email protected] + +- Update to version 0.3.0 with cabal2obs. + +------------------------------------------------------------------- Old: ---- diff3-0.2.0.3.tar.gz New: ---- diff3-0.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-diff3.spec ++++++ --- /var/tmp/diff_new_pack.h5pKHH/_old 2017-03-14 10:04:36.796806237 +0100 +++ /var/tmp/diff_new_pack.h5pKHH/_new 2017-03-14 10:04:36.796806237 +0100 @@ -1,7 +1,7 @@ # # spec file for package ghc-diff3 # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,15 +19,14 @@ %global pkg_name diff3 %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.2.0.3 +Version: 0.3.0 Release: 0 Summary: Perform a 3-way difference of documents License: BSD-3-Clause -Group: System/Libraries +Group: Development/Languages/Other Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel -# Begin cabal-rpm deps: BuildRequires: ghc-Diff-devel BuildRequires: ghc-rpm-macros BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -36,7 +35,6 @@ BuildRequires: ghc-test-framework-devel BuildRequires: ghc-test-framework-quickcheck2-devel %endif -# End cabal-rpm deps %description Perform a 3-way difference of documents. @@ -55,20 +53,14 @@ %prep %setup -q -n %{pkg_name}-%{version} - %build %ghc_lib_build - %install %ghc_lib_install - %check -%if %{with tests} -%{cabal} test -%endif - +%cabal_test %post devel %ghc_pkg_recache ++++++ diff3-0.2.0.3.tar.gz -> diff3-0.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/diff3-0.2.0.3/diff3.cabal new/diff3-0.3.0/diff3.cabal --- old/diff3-0.2.0.3/diff3.cabal 2013-07-24 16:50:30.000000000 +0200 +++ new/diff3-0.3.0/diff3.cabal 2016-12-19 12:33:32.000000000 +0100 @@ -1,5 +1,5 @@ name: diff3 -version: 0.2.0.3 +version: 0.3.0 synopsis: Perform a 3-way difference of documents homepage: http://github.com/ocharles/diff3.git license: BSD3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/diff3-0.2.0.3/src/Data/Algorithm/Diff3.hs new/diff3-0.3.0/src/Data/Algorithm/Diff3.hs --- old/diff3-0.2.0.3/src/Data/Algorithm/Diff3.hs 2013-07-24 16:50:30.000000000 +0200 +++ new/diff3-0.3.0/src/Data/Algorithm/Diff3.hs 2016-12-19 12:33:32.000000000 +0100 @@ -100,8 +100,8 @@ (bs, tb) = break isBoth b am = sum $ map motion as bm = sum $ map motion bs - (as', ta') = incurMotion bm ta - (bs', tb') = incurMotion am tb + (as', ta') = if bm > am then incurMotion (bm-am) ta else ([], ta) + (bs', tb') = if am > bm then incurMotion (am-bm) tb else ([], tb) in if am == bm then ((as, bs), ta, tb) else ((as ++ as', bs ++ bs'), [], []) <> go ta' tb' @@ -118,7 +118,7 @@ incurMotion _ [] = ([], []) incurMotion 0 as = ([], as) incurMotion n (a@(Both _ _):as) = ([a], []) <> incurMotion (pred n) as -incurMotion n (a@(Second _):as) = ([a], []) <> incurMotion (pred n) as +incurMotion n (a@(First _):as) = ([a], []) <> incurMotion (pred n) as incurMotion n (a:as) = ([a], []) <> incurMotion n as diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/diff3-0.2.0.3/test/properties.hs new/diff3-0.3.0/test/properties.hs --- old/diff3-0.2.0.3/test/properties.hs 2013-07-24 16:50:30.000000000 +0200 +++ new/diff3-0.3.0/test/properties.hs 2016-12-19 12:33:32.000000000 +0100 @@ -21,6 +21,40 @@ identityMerge :: [Int] -> Bool identityMerge as = merge (diff3 as as as) == Right as +-- The value in `Just a` has to match the next list item +-- `Nothing` is a wildcard that can match zero or more list items +matching :: (Eq a) => [Maybe a] -> [a] -> Bool +matching [] [] = True +matching [] bs = False +matching (Just a:as) (b:bs) = a == b && matching as bs +matching (Just a:as) [] = False +matching (as@(Nothing:as')) (bs@(_:bs')) = matching as' bs || matching as bs' +matching (Nothing:as') (bs@[]) = matching as' bs + +matchLeft :: [Int] -> [Int] -> [Int] -> Bool +matchLeft left original right = matching (matcher $ diff3 left original right) left + where matcher [] = [] + matcher (LeftChange as:hs) = map Just as ++ matcher hs + matcher (RightChange as:hs) = Nothing : matcher hs + matcher (Unchanged as:hs) = map Just as ++ matcher hs + matcher (Conflict as os bs:hs) = map Just as ++ matcher hs + +matchRight :: [Int] -> [Int] -> [Int] -> Bool +matchRight left original right = matching (matcher $ diff3 left original right) right + where matcher [] = [] + matcher (LeftChange as:hs) = Nothing : matcher hs + matcher (RightChange as:hs) = map Just as ++ matcher hs + matcher (Unchanged as:hs) = map Just as ++ matcher hs + matcher (Conflict as os bs:hs) = map Just bs ++ matcher hs + +matchOriginal :: [Int] -> [Int] -> [Int] -> Bool +matchOriginal left original right = matching (matcher $ diff3 left original right) original + where matcher [] = [] + matcher (LeftChange as:hs) = Nothing : matcher hs + matcher (RightChange as:hs) = Nothing : matcher hs + matcher (Unchanged as:hs) = map Just as ++ matcher hs + matcher (Conflict as os bs:hs) = map Just os ++ matcher hs + main :: IO () main = let testOpts = mempty { topt_maximum_generated_tests = Just 1000 } @@ -30,5 +64,8 @@ , testProperty "Can make changes in right document" rightChanges , testProperty "Left/right identical changes conflict" identicalChanges , testProperty "The 'identity' merge always succeeds" identityMerge + , testProperty "Left side of diff is part of left input" matchLeft + , testProperty "Right side of diff is part of right input" matchRight + , testProperty "Original parts of diff are part of original input" matchOriginal ] runner
