[MERGE] Bug #107967: fix bzr mv --after on a directory

James Westby jw+debian at jameswestby.net
Sun Jul 15 10:33:51 BST 2007


On (14/07/07 03:29), Daniel Parks wrote:
> Hey,
>
> I've written a fix for bug #107967* along with some tests and a NEWS entry.
>
> In the mv command, we either rename one file/directory/whatever to another 
> path, or move a collection of things into a directory. In the past we could 
> determine which to perform based on whether or not the target was an 
> existing directory (or a symlink to a directory).
>
> This adds a special case to that decision:
>  if there are two paths specified
>  AND the target is a directory or a symlink to a directory (on the file 
> system)
>  AND the source doesn't exist on the file system
>  AND the source is versioned
>  AND the target is not versioned
>  AND the target is the same kind of thing as the source (directory or 
> symlink)
>  THEN rename the target to the source
>
> Let me know if you think there's a better way to accomplish this. :)
>

The bug is talking about bzr mv --after, whereas your patch does not
seem to consider the --after flag. The bug states that the correct thing
is done in when there is no need for --after, (the source doesn't
exist).

Your tests seem reasonable to have, but they don't seem to test all of 
the behaviour. There should be tests of moving a directory when the
source does and doesn't exist.

  mkdir a
  bzr add a
  mv a b
  mkdir a
  bzr mv a b

which needs --after to work, so have a test both with and without
--after. (Some of these may already be present, I didn't check,
sorry).

There should also be a test that something sensible is done for

  mkdir a
  bzr add a
  mv a b
  touch a
  bzr mv --after a b

I think there are a lot of cases to be careful of here, so I would
add plenty of tests, and then just raise an error for anything
ambiguous.

> +            if inv.path2id(rel_names[1]):
> +                # let tree.move decide which error to raise
> +                return True

I believe that

  if inv.path2id(rel_names[1]) is not None:

is preferred.

Thanks for working on this,

James

-- 
  James Westby   --    GPG Key ID: B577FE13    --     http://jameswestby.net/
  seccure key - (3+)k7|M*edCX/.A:n*N!>|&7U.L#9E)Tu)T0>AM - secp256r1/nistp256



More information about the bazaar mailing list