[darcs-users] [issue1208] wish: darcs trackdown --bisect

Matthias Fischmann mf-hcafe-15c311f0c at etc-network.de
Thu Dec 3 17:35:04 UTC 2009



Hi again, quick question: I have implemented '--last' and it works,
but I am not sure whether this is how I should do it.  Anybody care to
drop a quick comment, like "yes, that's fine", or "no, use
... instead"?

Thanks,
Matthias


$ darcs whatsnew
hunk ./src/Darcs/Commands/TrackDown.lhs 29
-import Darcs.Arguments ( DarcsFlag(SetScriptsExecutable, Bisect), workingRepoDir, bisect,
-                         setScriptsExecutableOption )
+import Darcs.Arguments ( DarcsFlag(SetScriptsExecutable, Bisect, LastN, AfterPatch),
+                         workingRepoDir, bisect, matchRange,
+                         setScriptsExecutableOption,
+                       )
hunk ./src/Darcs/Commands/TrackDown.lhs 38
-                       lengthRL, lengthFL, mapRL, mapFL )
+                       lengthRL, lengthFL, mapRL, mapFL, takeRL, takeFL )
hunk ./src/Darcs/Commands/TrackDown.lhs 41
+import Darcs.Match ( getFirstMatch, getPartialFirstMatch, getPartialSecondMatch,
+                     firstMatch, secondMatch,
+                     matchFirstPatchset, matchSecondPatchset )
hunk ./src/Darcs/Commands/TrackDown.lhs 49
+import Debug.Trace ( trace )  -- should probably not be here after debugging.
hunk ./src/Darcs/Commands/TrackDown.lhs 83
-                          commandBasicOptions = [workingRepoDir, bisect]}
+                          commandBasicOptions = [workingRepoDir, bisect, matchRange]}
hunk ./src/Darcs/Commands/TrackDown.lhs 87
-  patches <- read_repo repository
+  patches <- read_repo repository >>= cropToMatchRangeRL opts . mapRL_RL hopefully . concatRL
hunk ./src/Darcs/Commands/TrackDown.lhs 105
-     else trackNextLinear) opts test (mapRL_RL hopefully . concatRL $ patches)
+     else trackNextLinear) opts test patches
+
+
+cropToMatchRangeRL :: [DarcsFlag] -> RL (Named p) C(x y) -> IO (RL (Named p) C(x y))
+cropToMatchRangeRL opts patches = do
+ 
+  let patches' = case [ i | LastN i <- opts ] of
+                   []   -> patches
+                   [i]  -> takeRL i patches
+                   _    -> assert False $ error "'--last' must not occur more than once."
+                              -- FIXME: is this appropriate error handling?
+
+  return patches'
+
+
hunk ./src/Darcs/Ordered.hs 32
-                             unsafeMap_l2f, filterE, filterFL,
+                             unsafeMap_l2f, filterE, filterFL, takeRL, takeFL,
hunk ./src/Darcs/Ordered.hs 42
+import Control.Exception
hunk ./src/Darcs/Ordered.hs 145
+takeRL :: Int -> RL p C(x y) -> RL p C(x y)
+takeRL i _ | i < 0 = assert False $ error "takeRL: negative argument."
+takeRL 0 _ = NilRL
+takeRL _ NilRL = NilRL
+takeRL i (x:<:xs) = x :<: takeRL (i-1) xs
+
+takeFL :: Int -> FL p C(x y) -> FL p C(x y)
+takeFL i _ | i < 0 = assert False $ error "takeFL: negative argument."
+takeFL 0 _ = NilFL
+takeFL _ NilFL = NilFL
+takeFL i (x:>:xs) = x :>: takeFL (i-1) xs
+


More information about the darcs-users mailing list