Looks like we're ready for push! I'll be pushing this in and adding a very minor whitespace cleanup.
Resolve issue1503: prefer local caches to remote ones ----------------------------------------------------- > pullCmd :: [DarcsFlag] -> [String] -> IO () > pullCmd opts repos = > - withRepoLock opts $- \repository -> > - fetchPatches opts' repos "pull" repository >>= applyPatches opts' > repository > + do > + pullingFrom <- mapM (fixUrl opts) repos > + withRepoLock opts $- \ initRepo -> do > + let repository = addLocal initRepo pullingFrom > + r <- fetchPatches opts' repos "pull" repository > + applyPatches opts' repository r > where > opts' = mergeOpts opts > hunk ./src/Darcs/Commands/Pull.lhs 186 > + addLocal repo repos = modifyCache repo $ \ (Ca cache) -> Ca $ [Cache > DarcsCache.Repo NotWritable r | r <- repos, isFile r ] ++ cache Yeah, I think this version has the right scope for the bits and pieces of helper code. > hunk ./src/Darcs/Repository/Cache.hs 15 > +-- | Compares two caches, a remote cache is greater than a local one. > +compareByLocality :: CacheLoc -> CacheLoc -> Ordering > +compareByLocality (Cache _ _ x) (Cache _ _ y) > + | isLocal x && isRemote y = LT > + | isRemote x && isLocal y = GT > + | otherwise = EQ > + where > + isRemote r= isUrl r || isSsh r > + isLocal = isFile At first, I was going to say something about the sortBy function assuming a total ordering, but I guess this *is* one: - antisymmetry - check - transitivity - check (well, you'll never have a < b < c) - totality - check Hmm, dunno what I was worried about. Maybe I was confused by the definition of EQ. Moment of superstition? > +-- | Modifies the cache of a given repository with the function f > +modifyCache :: FORALL(p r u t) (RepoPatch p) => Repository p C(r u t) -> > (Cache -> Cache) -> Repository p C(r u t) > +modifyCache (Repo dir opts rf (DarcsRepository pristine cache)) f = > + Repo dir opts rf (DarcsRepository pristine (f cache)) There's some trailing whitespace which I'll fix in a separate patch > hunk ./src/Darcs/Repository/Prefs.lhs 520 > - return $ Ca $ nub $ thisrepo ++ globalcache ++ globalsources ++ > + let tempCache = nub $ thisrepo ++ globalcache ++ globalsources ++ > here ++ [Cache Repo NotWritable repodir] ++ there > + return $ Ca $ sortBy compareByLocality tempCache This just introduces locality-based sorting into getCaches, so no matter how your repo has the caches sorted, it'll try the local ones first. -- Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow> PGP Key ID: 08AC04F9
signature.asc
Description: Digital signature
_______________________________________________ darcs-users mailing list darcs-users@darcs.net http://lists.osuosl.org/mailman/listinfo/darcs-users