New submission from Ganesh Sittampalam <[email protected]>:

This is for 2.5. The first patch is already in HEAD.

The third patch ("generalise the type of treeDiff") is somewhat
gratuitous as I make no use of the generalisation, but I just    
couldn't leave it ungeneralised once I noticed :-)

4 patches for repository http://darcs.net/releases/branch-2.5:

Tue Aug 10 18:34:48 BST 2010  Eric Kow <[email protected]>
  * Accept issue1913: buggy mapPrimFL.

Thu Aug 19 07:02:51 BST 2010  Ganesh Sittampalam <[email protected]>
  * make issue1913 test actually fail

Thu Aug 19 07:41:52 BST 2010  Ganesh Sittampalam <[email protected]>
  * generalise the type of treeDiff

Thu Aug 19 22:19:41 BST 2010  Ganesh Sittampalam <[email protected]>
  * resolve issue1913: sort changes in treeDiff

----------
files: accept-issue1913_-buggy-mapprimfl_.dpatch, unnamed
messages: 12238
nosy: ganesh
status: needs-review
title: Accept issue1913: buggy mapPrimFL. (and 3 more)

__________________________________
Darcs bug tracker <[email protected]>
<http://bugs.darcs.net/patch353>
__________________________________
New patches:

[Accept issue1913: buggy mapPrimFL.
Eric Kow <[email protected]>**20100810173448
 Ignore-this: 298f8bb5a3dbebafd6de809593a077fb
] addfile ./tests/failing-issue1913-diffing.sh
hunk ./tests/failing-issue1913-diffing.sh 1
+#!/usr/bin/env bash
+## Test for issue1913 - test for directory diffing
+##
+## Copyright (C) 2010 Ian Lynagh
+##
+## Permission is hereby granted, free of charge, to any person
+## obtaining a copy of this software and associated documentation
+## files (the "Software"), to deal in the Software without
+## restriction, including without limitation the rights to use, copy,
+## modify, merge, publish, distribute, sublicense, and/or sell copies
+## of the Software, and to permit persons to whom the Software is
+## furnished to do so, subject to the following conditions:
+##
+## The above copyright notice and this permission notice shall be
+## included in all copies or substantial portions of the Software.
+##
+## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+## BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+## ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+## CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+## SOFTWARE.
+
+. lib                           # Load some portability helpers.
+rm -rf R                        # Another script may have left a mess.
+darcs init      --repo R        # Create our test repos.
+
+cd R
+mkdir foo
+touch foo/foofile
+darcs rec -l -a -m "foo patch"
+mkdir bar
+touch bar/barfile
+rm -r foo
+darcs rec -l -a -m "bar patch"
+cd ..
[make issue1913 test actually fail
Ganesh Sittampalam <[email protected]>**20100819060251
 Ignore-this: 1f27289bbdb87b0d3c8ce5793d19d232
] hunk ./tests/failing-issue1913-diffing.sh 38
 touch bar/barfile
 rm -r foo
 darcs rec -l -a -m "bar patch"
+not darcs whatsnew -l
 cd ..
[generalise the type of treeDiff
Ganesh Sittampalam <[email protected]>**20100819064152
 Ignore-this: 1b01d02a3581c8967ac612d2d725d8ad
] hunk ./src/Darcs/Diff.hs 41
 
 #include "gadts.h"
 
-treeDiff :: Gap w => (FilePath -> FileType) -> Tree IO -> Tree IO -> IO (w (FL Prim))
+treeDiff :: forall m w . (Functor m, Monad m, Gap w) => (FilePath -> FileType) -> Tree m -> Tree m -> m (w (FL Prim))
 treeDiff ft t1 t2 = do
   (from, to) <- diffTrees t1 t2
   diffs <- sequence $ zipTrees diff from to
hunk ./src/Darcs/Diff.hs 46
   return $ foldr (joinGap (+>+)) (emptyGap NilFL) diffs
-    where diff :: Gap w
-               => AnchoredPath -> Maybe (TreeItem IO) -> Maybe (TreeItem IO)
-               -> IO (w (FL Prim))
+    where diff :: AnchoredPath -> Maybe (TreeItem m) -> Maybe (TreeItem m)
+               -> m (w (FL Prim))
           diff _ (Just (SubTree _)) (Just (SubTree _)) = return (emptyGap NilFL)
           diff p (Just (SubTree _)) Nothing =
               return $ freeGap (rmdir (anchorPath "" p) :>: NilFL)
[resolve issue1913: sort changes in treeDiff
Ganesh Sittampalam <[email protected]>**20100819211941
 Ignore-this: 3693df699c664a8f47dc0e0f974c9b7d
] move ./tests/failing-issue1913-diffing.sh ./tests/issue1913-diffing.sh
hunk ./src/Darcs/Diff.hs 37
 import qualified Data.ByteString.Lazy.Char8 as BLC
 import qualified Data.ByteString as BS
 import qualified Data.ByteString.Lazy as BL
+import Data.List ( sortBy )
 import ByteStringUtils( isFunky )
 
 #include "gadts.h"
hunk ./src/Darcs/Diff.hs 41
+#include "impossible.h"
+
+data Diff m = Added (TreeItem m) | Removed (TreeItem m) | Changed (TreeItem m) (TreeItem m)
+
+getDiff :: AnchoredPath -> Maybe (TreeItem m) -> Maybe (TreeItem m) -> (AnchoredPath, Diff m)
+getDiff p Nothing (Just t) = (p, Added t)
+getDiff p (Just from) (Just to) = (p, Changed from to)
+getDiff p (Just t) Nothing = (p, Removed t)
+getDiff p Nothing Nothing = impossible -- zipTrees should never return this
 
 treeDiff :: forall m w . (Functor m, Monad m, Gap w) => (FilePath -> FileType) -> Tree m -> Tree m -> m (w (FL Prim))
 treeDiff ft t1 t2 = do
hunk ./src/Darcs/Diff.hs 54
   (from, to) <- diffTrees t1 t2
-  diffs <- sequence $ zipTrees diff from to
+  diffs <- mapM (uncurry diff) $ sortBy organise $ zipTrees getDiff from to
   return $ foldr (joinGap (+>+)) (emptyGap NilFL) diffs
hunk ./src/Darcs/Diff.hs 56
-    where diff :: AnchoredPath -> Maybe (TreeItem m) -> Maybe (TreeItem m)
-               -> m (w (FL Prim))
-          diff _ (Just (SubTree _)) (Just (SubTree _)) = return (emptyGap NilFL)
-          diff p (Just (SubTree _)) Nothing =
+    where
+          -- sort into removes, changes, adds, with removes in reverse-path order
+          -- and everything else in forward order
+          organise :: (AnchoredPath, Diff m) -> (AnchoredPath, Diff m) -> Ordering
+
+          organise (p1, Changed _ _ ) (p2, Changed _ _) = compare p1 p2
+          organise (p1, Added _)      (p2, Added _)   = compare p1 p2
+          organise (p1, Removed _)    (p2, Removed _) = compare p2 p1
+
+          organise (p1, Removed _) _ = LT
+          organise _ (p1, Removed _) = GT
+
+          organise (p1, Changed _ _) _ = LT
+          organise _ (p1, Changed _ _) = GT
+
+          diff :: AnchoredPath -> Diff m -> m (w (FL Prim))
+          diff _ (Changed (SubTree _) (SubTree _)) = return (emptyGap NilFL)
+          diff p (Removed (SubTree _)) =
               return $ freeGap (rmdir (anchorPath "" p) :>: NilFL)
hunk ./src/Darcs/Diff.hs 75
-          diff p Nothing (Just (SubTree _)) =
+          diff p (Added (SubTree _)) =
               return $ freeGap (adddir (anchorPath "" p) :>: NilFL)
hunk ./src/Darcs/Diff.hs 77
-          diff p Nothing b'@(Just (File _)) =
-              do diff' <- diff p (Just (File emptyBlob)) b'
+          diff p (Added b'@(File _)) =
+              do diff' <- diff p (Changed (File emptyBlob) b')
                  return $ joinGap (:>:) (freeGap (addfile (anchorPath "" p))) diff'
hunk ./src/Darcs/Diff.hs 80
-          diff p a'@(Just (File _)) Nothing =
-              do diff' <- diff p a' (Just (File emptyBlob))
+          diff p (Removed a'@(File _)) =
+              do diff' <- diff p (Changed a' (File emptyBlob))
                  return $ joinGap (+>+) diff' (freeGap (rmfile (anchorPath "" p) :>: NilFL))
hunk ./src/Darcs/Diff.hs 83
-          diff p (Just (File a')) (Just (File b')) =
+          diff p (Changed (File a') (File b')) =
               do a <- readBlob a'
                  b <- readBlob b'
                  let path = anchorPath "" p
hunk ./src/Darcs/Diff.hs 93
                    _ -> return $ if a /= b
                                     then freeGap (binary path (strict a) (strict b) :>: NilFL)
                                     else emptyGap NilFL
-          diff p _ _ = fail $ "Missing case at path " ++ show p
+          diff p _ = fail $ "Missing case at path " ++ show p
           text_diff p a b
               | BL.null a && BL.null b = emptyGap NilFL
               | BL.null a = freeGap (diff_from_empty p b)

Context:

[Fix tests that were broken by issue1898 fix.
Eric Kow <[email protected]>**20100815202529
 Ignore-this: f25c2aaed8c0063cee2f31c179345190
 These tests were confused by Darcs UI messages.
] 
[Fix tests that were broken by issue1875 fix.
Eric Kow <[email protected]>**20100815202223
 Ignore-this: bd6e7066799e39f3529a485f6fbeed42
 
 The tests were assuming --set-default.  As these are artifical repositories for
 test cases, we sometimes have cases where we pull/push from freshly created
 repositories with no defaultrepo.
] 
[Resolve issue1898: notify user when they can use set-default.
Eric Kow <[email protected]>**20100812155901
 Ignore-this: 638b575b32d700cfae9f057293cd5aa8
] 
[Fix the remote-repo flag if it's not a URL.
Eric Kow <[email protected]>**20100812150920
 Ignore-this: 10082e2dc200ece25ece1519242962e2
 The word 'fix' here refers to the filepath canonicalisation mechanism
 that makes it easier to check filepath equality.
] 
[Resolve issue1875: avoid accidentally setting default.
Eric Kow <[email protected]>**20100812154847
 Ignore-this: d03cfc6111805515ae4f1ca467beab2c
 Two cases fixed:
  - setting default on dry-run
  - setting default on darcs get --no-set-default
] 
[Generalise issue1875 test on not setting default.
Eric Kow <[email protected]>**20100812154827
 Ignore-this: 127842d85545f411ce71e8d065d2c268
] 
[Accept issue1875: darcs does not honor no-set-default on fetch.
Eric Kow <[email protected]>**20100812152637
 Ignore-this: 32573c47c25ec3e5ad187a5537f50c73
] 
[Accept issue1898: set-default notification system.
Eric Kow <[email protected]>**20100811141903
 Ignore-this: d33212de428eaf5e2fd85aa4a6cc644a
] 
[TAG 2.4.98.3
Reinier Lamers <[email protected]>**20100815194519
 Ignore-this: e3a3c30d7dd2fbe49c846c48510a9c3c
] 
Patch bundle hash:
3527af72d46aac9e3021c850df61f0200092a372

Attachment: unnamed
Description: Binary data

_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to