Hello community,

here is the log from the commit of package resolve-trivial-conflicts for 
openSUSE:Factory checked in at 2017-03-24 02:19:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/resolve-trivial-conflicts (Old)
 and      /work/SRC/openSUSE:Factory/.resolve-trivial-conflicts.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "resolve-trivial-conflicts"

Fri Mar 24 02:19:46 2017 rev:2 rq:479417 version:0.3.2.4

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/resolve-trivial-conflicts/resolve-trivial-conflicts.changes
      2017-03-08 01:03:24.292422529 +0100
+++ 
/work/SRC/openSUSE:Factory/.resolve-trivial-conflicts.new/resolve-trivial-conflicts.changes
 2017-03-24 02:19:47.671855475 +0100
@@ -1,0 +2,10 @@
+Sun Jan  8 21:14:14 UTC 2017 - [email protected]
+
+- Update to version 0.3.2.4 with cabal2obs.
+
+-------------------------------------------------------------------
+Sun Oct 30 16:30:34 UTC 2016 - [email protected]
+
+- Update to version 0.3.2.3 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  resolve-trivial-conflicts-0.3.2.2.tar.gz

New:
----
  resolve-trivial-conflicts-0.3.2.4.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ resolve-trivial-conflicts.spec ++++++
--- /var/tmp/diff_new_pack.l8syqW/_old  2017-03-24 02:19:48.231776251 +0100
+++ /var/tmp/diff_new_pack.l8syqW/_new  2017-03-24 02:19:48.235775685 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package resolve-trivial-conflicts
 #
-# 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
@@ -17,7 +17,7 @@
 
 
 Name:           resolve-trivial-conflicts
-Version:        0.3.2.2
+Version:        0.3.2.4
 Release:        0
 Summary:        Remove trivial conflict markers in a git repository
 License:        GPL-2.0+

++++++ resolve-trivial-conflicts-0.3.2.2.tar.gz -> 
resolve-trivial-conflicts-0.3.2.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/resolve-trivial-conflicts-0.3.2.2/resolve-trivial-conflicts.cabal 
new/resolve-trivial-conflicts-0.3.2.4/resolve-trivial-conflicts.cabal
--- old/resolve-trivial-conflicts-0.3.2.2/resolve-trivial-conflicts.cabal       
2016-01-16 12:54:35.000000000 +0100
+++ new/resolve-trivial-conflicts-0.3.2.4/resolve-trivial-conflicts.cabal       
2016-12-20 19:06:44.000000000 +0100
@@ -2,7 +2,7 @@
 -- further documentation, see http://haskell.org/cabal/users-guide/
 
 name:                resolve-trivial-conflicts
-version:             0.3.2.2
+version:             0.3.2.4
 synopsis:            Remove trivial conflict markers in a git repository
 description:         Remove trivial conflict markers in a git repository
 homepage:            https://github.com/ElastiLotem/resolve-trivial-conflicts
@@ -22,8 +22,6 @@
 
 executable resolve-trivial-conflicts
   main-is:             resolve_trivial_conflicts.hs
-  ghc-options:         -rtsopts -Wall
-  ghc-prof-options:    -rtsopts -Wall -auto-all -caf-all
   other-modules:       PPDiff, Opts
   -- other-extensions:
   build-depends:       base >=4.6 && <5
@@ -35,6 +33,6 @@
                      , unix >=2.7
                      , Diff >=0.3
                      , ansi-terminal >=0.6.2
-                     , optparse-applicative >=0.11 && <0.13
+                     , optparse-applicative >=0.11 && <0.14
   -- hs-source-dirs:
   default-language:    Haskell2010
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/resolve-trivial-conflicts-0.3.2.2/resolve_trivial_conflicts.hs 
new/resolve-trivial-conflicts-0.3.2.4/resolve_trivial_conflicts.hs
--- old/resolve-trivial-conflicts-0.3.2.2/resolve_trivial_conflicts.hs  
2016-01-16 12:54:35.000000000 +0100
+++ new/resolve-trivial-conflicts-0.3.2.4/resolve_trivial_conflicts.hs  
2016-12-20 19:06:44.000000000 +0100
@@ -40,21 +40,53 @@
     , cLinesB     :: [String]
     } deriving (Show)
 
-prettyConflict :: Conflict -> String
-prettyConflict Conflict {..} =
-    unlines $ concat
+prettyConflictLines :: Conflict -> [String]
+prettyConflictLines Conflict {..} =
+    concat
     [ snd cMarkerA    : cLinesA
     , snd cMarkerBase : cLinesBase
     , snd cMarkerB    : cLinesB
     , [snd cMarkerEnd]
     ]
 
-resolveConflict :: Conflict -> Maybe String
-resolveConflict Conflict{..}
-    | cLinesA == cLinesBase = Just $ unlines cLinesB
-    | cLinesB == cLinesBase = Just $ unlines cLinesA
-    | cLinesA == cLinesB = Just $ unlines cLinesA
-    | otherwise = Nothing
+prettyConflict :: Conflict -> String
+prettyConflict = unlines . prettyConflictLines
+
+lengthOfCommonPrefix :: Eq a => [a] -> [a] -> Int
+lengthOfCommonPrefix x y = length $ takeWhile id $ zipWith (==) x y
+
+data Resolution
+    = NoResolution
+    | Resolution String
+    | PartialResolution String
+
+resolveConflict :: Conflict -> Resolution
+resolveConflict conflict@Conflict{..}
+    | cLinesA == cLinesBase = Resolution $ unlines cLinesB
+    | cLinesB == cLinesBase = Resolution $ unlines cLinesA
+    | cLinesA == cLinesB = Resolution $ unlines cLinesA
+    | matchTop > 0 || matchBottom > 0 =
+        PartialResolution $ unlines $
+        take matchTop cLinesBase ++
+        prettyConflictLines conflict
+        { cLinesA = unmatched cLinesA
+        , cLinesBase = unmatched cLinesBase
+        , cLinesB = unmatched cLinesB
+        } ++
+        takeEnd matchBottom cLinesBase
+    | otherwise = NoResolution
+    where
+        matchTop =
+            minimum $ map (lengthOfCommonPrefix cLinesBase) [cLinesA, cLinesB]
+        revBottom = reverse . drop matchTop
+        revBottomBase = revBottom cLinesBase
+        matchBottom =
+            minimum $
+            map (lengthOfCommonPrefix revBottomBase . revBottom)
+            [cLinesA, cLinesB]
+        dropEnd count xs = take (length xs - count) xs
+        takeEnd count xs = drop (length xs - count) xs
+        unmatched xs = drop matchTop $ dropEnd matchBottom xs
 
 -- '>' -> ">>>>>>> "
 markerPrefix :: Char -> String
@@ -123,6 +155,7 @@
 
 data NewContent = NewContent
     { _resolvedSuccessfully :: Int
+    , _reducedConflicts :: Int
     , _failedToResolve :: Int
     , _newContent :: String
     }
@@ -138,19 +171,22 @@
 getConflictDiff2s Conflict{..} = (cMarkerA, cMarkerB, getDiff cLinesA cLinesB)
 
 resolveContent :: [Either String Conflict] -> NewContent
-resolveContent = asResult . mconcat . map go
+resolveContent =
+    asResult . mconcat . map go
     where
-        asResult (Monoid.Sum successes, Monoid.Sum failures, newContent) =
+        asResult (Monoid.Sum successes, Monoid.Sum reductions, Monoid.Sum 
failures, newContent) =
             NewContent
             { _resolvedSuccessfully = successes
+            , _reducedConflicts = reductions
             , _failedToResolve = failures
             , _newContent = newContent
             }
-        go (Left line) = (Monoid.Sum 0, Monoid.Sum 0, unlines [line])
+        go (Left line) = (Monoid.Sum 0, Monoid.Sum 0, Monoid.Sum 0, unlines 
[line])
         go (Right conflict) =
             case resolveConflict conflict of
-            Nothing -> (Monoid.Sum 0, Monoid.Sum 1, prettyConflict conflict)
-            Just trivialLines -> (Monoid.Sum 1, Monoid.Sum 0, trivialLines)
+            NoResolution -> (Monoid.Sum 0, Monoid.Sum 0, Monoid.Sum 1, 
prettyConflict conflict)
+            Resolution trivialLines -> (Monoid.Sum 1, Monoid.Sum 0, Monoid.Sum 
0, trivialLines)
+            PartialResolution newLines -> (Monoid.Sum 0, Monoid.Sum 1, 
Monoid.Sum 0, newLines)
 
 gitAdd :: FilePath -> IO ()
 gitAdd fileName =
@@ -195,26 +231,32 @@
 resolve colorEnable opts fileName =
     resolveContent . parseConflicts <$> readFile fileName
     >>= \case
-    NewContent successes failures newContent
-        | successes == 0 && failures == 0 ->
+    NewContent successes reductions failures newContent
+        | successes == 0 && allGood ->
           do  putStrLn $ fileName ++ ": No conflicts, git-adding"
               gitAdd fileName
-        | successes == 0 ->
+        | successes == 0 && reductions == 0 ->
           do  putStrLn $ concat
                   [ fileName, ": Failed to resolve any of the "
                   , show failures, " conflicts" ]
               doDump
+        | successes == 0 ->
+          do  putStrLn $ concat
+                  [ fileName, ": Reduced ", show reductions, " conflicts"]
+              overwrite fileName newContent
+              doDump
         | otherwise ->
           do  putStrLn $ concat
                   [ fileName, ": Successfully resolved ", show successes
-                  , " conflicts (failed to resolve " ++ show failures ++ " 
conflicts)"
-                  , if failures == 0 then ", git adding" else ""
+                  , " conflicts (failed to resolve " ++ show (reductions + 
failures) ++ " conflicts)"
+                  , if allGood then ", git adding" else ""
                   ]
               overwrite fileName newContent
-              if failures == 0
+              if allGood
                   then gitAdd fileName
                   else doDump
         where
+            allGood = failures == 0 && reductions == 0
             doDump =
                 dumpAndOpenEditor colorEnable opts fileName
                 [ conflict | Right conflict <- parseConflicts newContent ]


Reply via email to