darcs

Patch 272 Limit index updates to relevant subtree in a few cases.

Title Limit index updates to relevant subtree in a few cases.
Superseder Nosy List kowey, mornfall
Related Issues
Status accepted Assigned To
Milestone

Created on 2010-06-07.20:01:43 by mornfall, last changed 2011-05-10.20:06:26 by darcswatch. Tracked on DarcsWatch.

Files
File name Status Uploaded Type Edit Remove
limit-index-updates-to-relevant-subtree-in-a-few-cases_.dpatch mornfall, 2010-06-07.20:01:43 text/x-darcs-patch
unnamed mornfall, 2010-06-07.20:01:43
See mailing list archives for discussion on individual patches.
Messages
msg11315 (view) Author: mornfall Date: 2010-06-07.20:01:43
This has been sitting around on my mainline branch for a while. Guess I just
forgot to send it... Should be self-explanatory (I hope).

Yours,
   Petr.

1 patch for repository darcs-unstable@darcs.net:darcs:

Sun May  9 12:22:48 CEST 2010  Petr Rockai <me@mornfall.net>
  * Limit index updates to relevant subtree in a few cases.
Attachments
msg11326 (view) Author: kowey Date: 2010-06-08.09:52:32
On Mon, Jun 07, 2010 at 20:01:43 +0000, Petr Ročkai wrote:
> This has been sitting around on my mainline branch for a while. Guess I just
> forgot to send it... Should be self-explanatory (I hope).

Seems to make sense.  I was going to ask "what if the
user does not pass in any paths on the command line?", but I think
this tells restrictSubpaths helper tells me the answer,

      restrictPaths :: FilterTree t m => t m -> t m
      restrictPaths = if null subpaths then id else filter (filterPaths anchored)

By the way, I seem to remember having seen and reported a recent bug
where 'whatsnew .' would break but 'whatsnew' without any arguments
would be fine.  Do you know what I'm referring to?  I can't find it on
the tracker or in my local list!

The comments below are just Eric-reads-the-patch, no action on your part
needed.

> Sun May  9 12:22:48 CEST 2010  Petr Rockai <me@mornfall.net>
>   * Limit index updates to relevant subtree in a few cases.

Limit index updates to relevant subtree in a few cases.
-------------------------------------------------------
> Petr Rockai <me@mornfall.net>**20100509102248
>  Ignore-this: fea041133d039cecead73935f0cd6762
> ] hunk ./src/Darcs/Commands/Diff.lhs 210

> -               restrict <- restrictSubpaths repository subpaths
> -               restrict `fmap` readUnrecorded repository >>= (flip writePlainTree (toFilePath ndir))
> +               readUnrecorded repository subpaths >>= (flip writePlainTree (toFilePath ndir))

Basically, it looks like we're taking these smarts from the diff command
and refactoring them into readUnrecorded.

The smarts in question are explained in Petr's haddock:
>  -- | Obtains a Tree corresponding to the "unrecorded" state of the repository:
> +-- the working tree plus the "pending" patch. The optional list of paths (it is
> +-- ignored if empty) allows to restrict the query to a subtree.
> +--
> +-- Limiting the query may be more efficient, since hashes on the uninteresting
> +-- parts of the index do not need to go through an up-to-date check (which
> +-- involves a relatively expensive lstat(2) per file.

The commands that consequently inherit said smarts are

> hunk ./src/Darcs/Commands/Remove.lhs 101
> hunk ./src/Darcs/Commands/Replace.lhs 171
> hunk ./src/Darcs/Commands/WhatsNew.lhs 113

There's also this bit which does not change any behaviour

> hunk ./src/Darcs/Repository/Merge.hs 71
>       debugMessage "Checking for unrecorded conflicts..."
>       have_unrecorded_conflicts <- checkUnrecordedConflicts opts pc
>       debugMessage "Reading working directory..."
> -     working <- readUnrecorded r
> +     working <- readUnrecorded r []

> -readUnrecorded :: (RepoPatch p) => Repository p C(r u t) -> IO (Tree IO)
> -readUnrecorded repo = readIndex repo >>= I.updateIndex

> +readUnrecorded :: (RepoPatch p) => Repository p C(r u t) -> [SubPath] -> IO (Tree IO)
> +readUnrecorded repo paths = do
> +  relevant <- restrictSubpaths repo paths
> +  readIndex repo >>= I.updateIndex . relevant

And here's the meat of the change.

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
msg11330 (view) Author: darcswatch Date: 2010-06-08.10:22:59
This patch bundle (with 1 patches) was just applied to the repository http://darcs.net/.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-012f2e6521bc3d6f8095faa1696d3bd67ff0f1fa
msg14249 (view) Author: darcswatch Date: 2011-05-10.20:06:26
This patch bundle (with 1 patches) was just applied to the repository http://darcs.net/reviewed.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-012f2e6521bc3d6f8095faa1696d3bd67ff0f1fa
History
Date User Action Args
2010-06-07 20:01:43mornfallcreate
2010-06-07 20:03:08darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-012f2e6521bc3d6f8095faa1696d3bd67ff0f1fa
2010-06-08 09:52:32koweysetnosy: + kowey
messages: + msg11326
2010-06-08 10:22:59darcswatchsetstatus: needs-review -> accepted
messages: + msg11330
2011-05-10 20:06:26darcswatchsetmessages: + msg14249