[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH v3] Reject checkouts to existing directory

From: Patrick Steinhardt <patrick.steinhardt_at_elegosoft.com>
Date: Wed, 9 Nov 2016 12:54:08 +0100

Hi,

this is version three of my patch regarding checkouts to existing
directories. Thanks for the feedback on the previous two patches.

This patch requires my currently in-flight patch
`svn_client_list4: accept `NULL patterns'. If it will not go into
trunk, I'll convert `verify_checkout_target` to use an empty
array instead of passing `NULL`.

The new version fixes an issue where I did not check correctly
whether the target directory is empty (that is I previously used
`svn_path_is_empty`, where I now correctly use
`svn_io_dir_empty`). Furthermore, I now check if the target is a
working copy and, if so, compare UUID and relative paths of the
wc and remote repository. These changes allowed me to drop all
previously required '--force' flags in our test suite, indicating
the changes now match more closely with existing use cases.

I stopped short of adding a new '--force-obstructed-checkout'
flag, which might be used instead of '--force' if the new checks
reject the checkout. After reading '--force's doc string, it
should actually do exactly what the new flag would be doing.
Furthermore, I no hope that it's not required that frequently.

Regards
Patrick

[[[
checkout_cmd: refuse obstructed checkouts

When a new checkout is done where the target dirctory already
exists, subversion will usually create a lot of tree conflicts
which are intimidating, especially to new users. This behavior
stems from release 1.8, where we started accepting checkouts to
existing directories without any safety-checks.

This patch changes semantics in that it introduces new safety
checks so that the user does not accidentally shoots himself into
the foot. We now only allow checkouts if one of the following
conditions holds true:

- the target directory does not exist
- the target directory is empty
- the target directory is a repository and has the same UUID and
  relative path as the repository that is to be checked out
- the repository to check out is empty
- the --force flag is given

The main use case solved by the above conditions is for
converting existing directories into a repository when the
repository is newly created as well as resuming checkouts.

* subversion/svn/checkout-cmd.c:
  (listing_cb): New callback to check whether the remote
                repository is empty.
  (verify_checkout_target): New function to check whether the
                            target checkout directory is a valid
                            one.
  (svn_cl__checkout): Now calls `verify_checkout_target` if no
                      --force flag is specified.
* subversion/tests/cmdline/checkout_tests.py:
  (checkout_with_obstructions): Replace old test and now assert
                                that subversion refuses to
                                checkout to non-empty dirs.
]]]

-- 
Patrick Steinhardt, Entwickler
elego Software Solutions GmbH, http://www.elego.de
Gebäude 12 (BIG), Gustav-Meyer-Allee 25, 13355 Berlin, Germany
Sitz der Gesellschaft: Berlin, USt-IdNr.: DE 163214194
Handelsregister: Amtsgericht Charlottenburg HRB 77719
Geschäftsführer: Olaf Wagner

Received on 2016-11-09 12:54:52 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.