[darcs-devel] [issue2272] darcs rebase unsuspend should automate or semi-automate handling unrecorded changes

Ivan Zakharyaschev bugs at darcs.net
Wed Dec 23 12:33:37 UTC 2015


Ivan Zakharyaschev <imz at altlinux.org> added the comment:

As a first and very simple thing to try to do with the code, I've
factored out the piece of code that deals with unrecorded changes from
"suspend". The patch is below. (It's very simple, just taking out the
piece of code; but the diff got a bit complicated to read.)

BTW, whose darcs repo is best to fork from at hub.darcs.net? I'd like to
save my changes there (to have a backup of my working copy and to
publish them)?

patch 25a4f08b946aea68d646cbb5f40fc6eb6a545943
Author: Ivan Zakharyaschev <imz at altlinux.org>
Date:   Wed Dec 23 14:38:23 MSK 2015
  * Rebase.hs: factored out afterPending from doSuspend
  
  
  I'm preparing a simple fix for issue2272. A similar check is to be
  used for unsuspend, too (instead of simply refusing to proceed if
  there are unrecorded changes).
  
diff -rN -u -d old-darcs/src/Darcs/UI/Commands/Rebase.hs
new-darcs/src/Darcs/UI/Commands/Rebase.hs
--- old-darcs/src/Darcs/UI/Commands/Rebase.hs	2015-12-23
15:37:20.519694154 +0300
+++ new-darcs/src/Darcs/UI/Commands/Rebase.hs	2015-12-23
15:37:20.519694154 +0300
@@ -260,9 +260,22 @@
     -> FL (PatchInfoAnd (Rebasing p)) wX wT
     -> IO (Repository (Rebasing p) wR wU wX)
 doSuspend opts repository qs rOld psToSuspend = do
+    FlippedSeal psAfterPending <- afterPending opts repository psToSuspend
+    rNew <- mkSuspended (mapFL_FL (ToEdit . fmapNamed unNormal .
hopefully) psToSuspend +>+ qs)
+    invalidateIndex repository
+    repository' <- tentativelyRemovePatches repository (compression
opts) YesUpdateWorking (psToSuspend +>+ (rOld :>: NilFL))
+    tentativelyAddToPending repository' YesUpdateWorking $ invert $
effect psToSuspend
+    repository'' <- tentativelyAddPatch repository' (compression opts)
(verbosity opts) YesUpdateWorking (n2pia rNew)
+    _ <- applyToWorking repository'' (verbosity opts) (invert
psAfterPending)
+            `catch` \(e :: IOException) -> fail ("Couldn't undo patch
in working dir.\n" ++ show e)
+    return repository''
+  where unNormal :: Rebasing p wA wB -> p wA wB
+        unNormal (Normal q) = q
+        unNormal (Suspended _) = error "Can't suspend a rebase patch"
+
+afterPending opts repository psToSuspend = do
     pend <- unrecordedChanges (diffingOpts opts) repository Nothing
-    FlippedSeal psAfterPending <-
-        let effectPsToSuspend = effect psToSuspend in
+    let effectPsToSuspend = effect psToSuspend in
         case commute (effectPsToSuspend :> pend) of
             Just (_ :> res) -> return (FlippedSeal res)
             Nothing -> do
@@ -277,20 +290,7 @@
                             showNicely suspendedConflicts $$
                             text "conflict with these local changes:" $$
                             showNicely pendConflicts
-                fail $ "Can't suspend selected patches without
reverting some unrecorded change. Use --verbose to see the details."
-
-
-    rNew <- mkSuspended (mapFL_FL (ToEdit . fmapNamed unNormal .
hopefully) psToSuspend +>+ qs)
-    invalidateIndex repository
-    repository' <- tentativelyRemovePatches repository (compression
opts) YesUpdateWorking (psToSuspend +>+ (rOld :>: NilFL))
-    tentativelyAddToPending repository' YesUpdateWorking $ invert $
effect psToSuspend
-    repository'' <- tentativelyAddPatch repository' (compression opts)
(verbosity opts) YesUpdateWorking (n2pia rNew)
-    _ <- applyToWorking repository'' (verbosity opts) (invert
psAfterPending)
-            `catch` \(e :: IOException) -> fail ("Couldn't undo patch
in working dir.\n" ++ show e)
-    return repository''
-  where unNormal :: Rebasing p wA wB -> p wA wB
-        unNormal (Normal q) = q
-        unNormal (Suspended _) = error "Can't suspend a rebase patch"
+                fail $ "Can't (un)suspend selected patches without
reverting some unrecorded change. Use --verbose to see the details."
 
 unsuspendBasicOpts :: DarcsOption a
                       (Maybe O.AllowConflicts

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/issue2272>
__________________________________


More information about the darcs-devel mailing list