How can I determine who locked a file using SVN?

一世执手 提交于 2020-07-05 00:15:35

问题


We are using SVN server 1.4 (I think) with the clients being either the command line client or TortoiseSVN.


回答1:


The command line client shows the lock owner with the command "svn info".

In TortoiseSVN, you can see the lock owner in the "properties" context menu (tab "subversion").




回答2:


Use svn status --show-updates to discover locks on files. In the following example, Sally discovers there is a lock on raisin.jpg.

$ whoami
sally

$ svn status --show-updates
M              23   bar.c
M    O         32   raisin.jpg
       *       72   foo.h
Status against revision:     105

Once you know the lock, you can use svn -info to discover who set the lock. Notice "Lock Owner" below:

$ svn info http://svn.example.com/repos/project/raisin.jpg
Path: raisin.jpg
Name: raisin.jpg
URL: http://svn.example.com/repos/project/raisin.jpg
Repository UUID: edb2f264-5ef2-0310-a47a-87b0ce17a8ec
Revision: 105
Node Kind: file
Last Changed Author: sally
Last Changed Rev: 32
Last Changed Date: 2005-01-25 12:43:04 -0600 (Tue, 25 Jan 2005)
Lock Token: opaquelocktoken:fc2b4dee-98f9-0310-abf3-653ff3226e6b
Lock Owner: harry
Lock Created: 2005-02-16 13:29:18 -0500 (Wed, 16 Feb 2005)
Lock Comment (1 line):
Need to make a quick tweak to this image.



回答3:


Using the repo-browser feature of TortoiseSVN there is a lock column that shows the user who locked the file.

Right click on the local working copy -> TortoiseSVN-> repo-browser.




回答4:


Steps to check:

  1. Right click on the file/folder on which you want to determine the lock

  2. Go to TortoiseSVN Options >> Repo-browser

  3. A new window will open and you will get a table view

  4. Lock column in the table will show who has the lock




回答5:


  1. Right click the file, select TortoiseSVN, then Check for modifications
  2. Click Check repository
  3. Scroll to the right to see the Lock column



回答6:


The following Python script shows all locks and who owns them:

#!/usr/bin/python
# coding=UTF-8

# This tool shows who owns the locks in a subversion repository

import sys
import subprocess

if len(sys.argv) > 1:
    p = subprocess.Popen(['svn', 'status', '-u', sys.argv[1]], bufsize=1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
    p = subprocess.Popen(['svn', 'status', '-u'], bufsize=1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

(so, se) = p.communicate() # start command

lines = [x[21:].strip() for x in so.split('\n') if len(x) > 5 and x[5] == 'K']

for line in lines:
    p = subprocess.Popen(['svn', 'info', line], bufsize=1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (so, se) = p.communicate()
    details = [x[12:].strip() for x in so.split('\n') if x.startswith('Lock Owner')][0]
    print '[%s] (%s)' % (details, line)



回答7:


Check the red book section 'Discovering locks'. I believe it contains the answer.




回答8:


I had also this problem concerning the .aux files. The solution/problem in my case was that no subdirectories havind a larger depth than 1 are allowed. If you want to use this the subdirectories in the tmp folder must be existing. e.g. --> src--> introduction-->introduction.tex requires --> tmp--> introduction-->introduction.aux ******

The underlined directory must be existing. So in the case of subversion management commit also the directory structure in the tmp folder (without the *.aux) files.



来源:https://stackoverflow.com/questions/853328/how-can-i-determine-who-locked-a-file-using-svn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!