You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Andrew Schwartz <as...@gmail.com> on 2015/03/27 17:04:43 UTC

unlocking a svn:needs-lock file

Hi,

I'm using svn on Windows.

If a file with the svn:needs-lock property is currently locked and is
locally modified, I think that 'svn unlock' should fail.  I'm seeing it
happily succeed.

After the 'svn unlock', the local checkout is in a bad state: it has local
modifications to an unlocked svn:needs-lock file.

Is there a legitimate use case here that I'm not thinking of?

Thanks,

Andrew

Re: unlocking a svn:needs-lock file

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Johan Corveleyn wrote on Fri, Mar 27, 2015 at 23:02:33 +0100:
> On Fri, Mar 27, 2015 at 5:04 PM, Andrew Schwartz <as...@gmail.com> wrote:
> > Hi,
> >
> > I'm using svn on Windows.
> >
> > If a file with the svn:needs-lock property is currently locked and is
> > locally modified, I think that 'svn unlock' should fail.  I'm seeing it
> > happily succeed.

Should 'svn unlock' warn if the unlock target has local modifications?
In the case of svn:needs-lock on a binary / hard-to-merge file, having
this warning would be consistent with our general policy of not losing
user data.

e.g.:

[[[
% svn unlock iota
svn: warning W%06d: 'iota' has local modifications
Unlocked 'iota'.
]]]

> > After the 'svn unlock', the local checkout is in a bad state: it has local
> > modifications to an unlocked svn:needs-lock file.
> 
> That's not a bad state. It may be unusual, but it's not 'bad'. It's
> the same as if you would edit the file directly with some editor,
> outside of svn's knowledge.
> 
> Keep in mind though that you won't be able to commit your changes if
> someone else has locked it.

... unless you break the lock.  ('svn lock' locks are advisory.)

Re: unlocking a svn:needs-lock file

Posted by Johan Corveleyn <jc...@gmail.com>.
On Fri, Mar 27, 2015 at 5:04 PM, Andrew Schwartz <as...@gmail.com> wrote:
> Hi,
>
> I'm using svn on Windows.
>
> If a file with the svn:needs-lock property is currently locked and is
> locally modified, I think that 'svn unlock' should fail.  I'm seeing it
> happily succeed.

I see no problem with that. The svn:needs-lock property is merely a
suggestion for the client that it *should* lock the file when it
intends to edit it. A well behaving svn client will make such files
read-only on the filesystem, but not much more. Good tools that are
integrated with an svn client will automatically offer to take a lock
when you start editing a file. But if you make such a file writable
yourself (unchecking the read-only flag from the file's properties),
and edit it with Notepad, there is nothing stopping you, and svn can't
possibly intervene to take a lock.

> After the 'svn unlock', the local checkout is in a bad state: it has local
> modifications to an unlocked svn:needs-lock file.

That's not a bad state. It may be unusual, but it's not 'bad'. It's
the same as if you would edit the file directly with some editor,
outside of svn's knowledge.

Keep in mind though that you won't be able to commit your changes if
someone else has locked it.

> Is there a legitimate use case here that I'm not thinking of?

For instance, if you decide to unlock it for now (to give others the
opportunity to edit it from their working copies), but still want to
keep your local changes for a while (perhaps to make a backup of them
to come back to it later or whatever).

Maybe you keep your file locally modified (but unlocked for a while),
do some other stuff, and lock the file later shortly before you decide
to commit your changes anyway.

-- 
Johan

Re: unlocking a svn:needs-lock file

Posted by Branko Čibej <br...@wandisco.com>.
On 27.03.2015 17:04, Andrew Schwartz wrote:
> Hi,
>
> I'm using svn on Windows.
>
> If a file with the svn:needs-lock property is currently locked and is
> locally modified, I think that 'svn unlock' should fail.  I'm seeing
> it happily succeed.

This is not a bug.

http://svnbook.red-bean.com/en/1.7/svn.advanced.locking.html#svn.advanced.locking.lock-communication

http://svnbook.red-bean.com/en/1.7/svn.basic.version-control-basics.html#svn.basic.vsn-models.lock-unlock


> After the 'svn unlock', the local checkout is in a bad state: it has
> local modifications to an unlocked svn:needs-lock file.

There is no 'bad state'. Locking is completely optional. You can commit
an unlocked file regardless of the svn:needs-lock property. The only
thing that property does is to make the file read-only by default in the
working copy, as a hint to the user.

> Is there a legitimate use case here that I'm not thinking of?

As the book says, 'svn:needs-lock' is just a communication mechanism. It
doesn't enforce a particular workflow.

-- Brane