darcs

Patch 703 Refactor movedirfilename to use stripPre... (and 6 more)

Title Refactor movedirfilename to use stripPre... (and 6 more)
Superseder Nosy List owst
Related Issues
Status accepted Assigned To
Milestone

Created on 2012-01-24.01:56:38 by owst, last changed 2012-03-31.01:24:27 by gh.

Files
File name Status Uploaded Type Edit Remove
fix-improper-handling-of-filenames-that-are-prefixes_of_-but-not-parents_of-a-target-filename_.dpatch owst, 2012-01-31.00:34:00 application/x-darcs-patch
patch-preview.txt owst, 2012-01-24.01:56:36 text/x-darcs-patch
patch-preview.txt owst, 2012-01-31.00:34:00 text/x-darcs-patch
refactor-movedirfilename-to-use-stripprefix-lib-function_-rather-than-equivalent-hand_rolled-code_.dpatch owst, 2012-01-24.01:56:36 application/x-darcs-patch
unnamed owst, 2012-01-24.01:56:36
unnamed owst, 2012-01-31.00:34:00
See mailing list archives for discussion on individual patches.
Messages
msg15054 (view) Author: owst Date: 2012-01-24.01:56:36
Some related tidy ups, then fix issue2136. A slightly invasive change, but now
actually does as expected (and suggested by original comments).

7 patches for repository http://darcs.net:

Tue Jan 24 00:09:08 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
  * Refactor movedirfilename to use stripPrefix lib function, rather than equivalent hand-rolled code.

Tue Jan 24 00:15:06 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
  * Use <$> instead of fmap in Patch/Apply.hs

Tue Jan 24 00:23:08 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
  * Add new helper function to determine if a given filename is the parentOrEqual of another.

Tue Jan 24 00:51:08 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
  * Replace applyToFilepaths with applyToFilePaths to match casing of FilePath

Tue Jan 24 00:57:41 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
  * Rename withFilePaths -> withFileNames, since it operates on FileNames not FilePaths.

Tue Jan 24 01:37:28 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
  * Resolve Issue2136: Correctly track renames of multiple files in Changes --xml.
  For each file passed to Changes, track its original name, and show the first
  patch that created it. Update lookTouch to track exactly which files are
  touched, and renames. Create utility function to provide old behaviour of just
  obtaining the effect of the patch on a filepath list.

Tue Jan 24 01:57:21 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
  * Add current_name attribute to created_as in changes --xml on multiple files.
  Without this attribute it wasn't necessarily clear which original name
  corresponded to which input filename.
Attachments
msg15077 (view) Author: owst Date: 2012-01-31.00:34:00
Add a test and fix for improper handling in annotate/changes where renaming
a->b would affect any filename with a prefix of b.

1 patch for repository http://darcs.net:

Tue Jan 31 00:36:10 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
  * Fix improper handling of FileNames that are prefixes-of, but not parents-of a target FileName.
Attachments
msg15441 (view) Author: gh Date: 2012-03-31.01:23:49
> Tue Jan 24 00:09:08 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
>  * Refactor movedirfilename to use stripPrefix lib function, rather than equivalent hand-rolled code.

Ok.

> Tue Jan 24 00:15:06 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
>  * Use <$> instead of fmap in Patch/Apply.hs

Doesn't hurt, I prefer <$> over fmap too.

> Tue Jan 24 00:23:08 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
>  * Add new helper function to determine if a given filename is the parentOrEqual of another.

Ok.

> Tue Jan 24 00:51:08 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
>  * Replace applyToFilepaths with applyToFilePaths to match casing of FilePath

Style patch.

> Tue Jan 24 00:57:41 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
>  * Rename withFilePaths -> withFileNames, since it operates on FileNames not FilePaths.

I agree.

> Tue Jan 24 01:37:28 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
>  * Resolve Issue2136: Correctly track renames of multiple files in Changes --xml.
>  For each file passed to Changes, track its original name, and show the first
>  patch that created it. Update lookTouch to track exactly which files are
>  touched, and renames. Create utility function to provide old behaviour of just
>  obtaining the effect of the patch on a filepath list.

The main logic of this patch belongs in
Darcs.Commands.Changes.(filterPatchesByNames|changeLog) and
Darcs.Patch.ApplyMonad (trackOrigRename)

At first I thought trackOrigRename would fail to track a renaming of
an intermediate directory, say, d2 -> d3 in ./d1/d2/f, but in fact
the renaming would be ./d1/d2 -> ./d1/d3 hene the prefix comparison
done by isParentOrEqOf is right.

The included shell test looks good.

Apart from the code changes, the patch introduces comments in
Darcs.Patch.ApplyMonad, so that's nice.
I would have liked to have haddocks in Darcs.Patch.Apply (to
understand the changes to applyToFilePaths/effectOnFilePaths), and
Darcs.Commands.Changes (getChangesInfo), thought!

> Tue Jan 24 01:57:21 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
>  * Add current_name attribute to created_as in changes --xml on multiple files.
>  Without this attribute it wasn't necessarily clear which original name
>  corresponded to which input filename.

Good idea.

> Tue Jan 31 00:36:10 GMT 2012  Owen Stephens <darcs@owenstephens.co.uk>
>  * Fix improper handling of FileNames that are prefixes-of, but not parents-of a target FileName.

Indeed, before that, ./filex would have been considered a parent of
./filexxx for instance.
History
Date User Action Args
2012-01-24 01:56:38owstcreate
2012-01-31 00:34:00owstsetfiles: + patch-preview.txt, fix-improper-handling-of-filenames-that-are-prefixes_of_-but-not-parents_of-a-target-filename_.dpatch, unnamed
messages: + msg15077
2012-02-22 21:14:29ganeshsetstatus: needs-screening -> needs-review
2012-03-23 21:05:28mndrixsettitle: Refactor movedirfilename to use stripPre... (and 6 more) -> Resolve Issue2136: Correctly track renames of multiple files in Changes --xml
2012-03-31 01:23:49ghsetmessages: + msg15441
title: Resolve Issue2136: Correctly track renames of multiple files in Changes --xml -> Refactor movedirfilename to use stripPre... (and 6 more)
2012-03-31 01:24:27ghsetstatus: needs-review -> accepted