현재 Subversion 개정 명령
현재 개정 번호를 표시하는 Subversion 명령이 있습니까?
후에 svn checkout
나는 스크립트를 시작하고 싶은 변수에 개정 번호가 필요합니다. 같은 명령이 있으면 좋을 것 svn info get_revision_number
입니다.
최신 버전의 svn은 다음 --show-item
인수를 지원합니다 .
svn info --show-item revision
로컬 작업 사본의 개정 번호는 다음을 사용하십시오.
svn info --show-item last-changed-revision
다음 os.system()
과 같은 명령 줄을 실행하는 데 사용할 수 있습니다 .
svn info | grep "Revision" | awk '{print $2}'
야간 빌드 스크립트에서 수행합니다.
또한 일부 플랫폼에는 svnversion
명령이 있지만 사용하지 않을 이유가 있다고 생각합니다. 아, 맞아. svnversion을 사용하여 로컬 저장소와 비교하기 위해 원격 저장소에서 개정 번호를 가져올 수 없습니다.
더 편리한 (일부) svnversion
명령도 있습니다.
출력은 단일 개정 번호이거나 다음과 같은 형식 일 수 있습니다 (-h에서).
4123:4168 mixed revision working copy
4168M modified working copy
4123S switched working copy
4123:4168MS mixed revision, modified, switched working copy
이 파이썬 코드 조각을 사용하여 개정 정보를 추출합니다.
import re
import subprocess
p = subprocess.Popen(["svnversion"], stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
p.wait()
m = re.match(r'(|\d+M?S?):?(\d+)(M?)S?', p.stdout.read())
rev = int(m.group(2))
if m.group(3) == 'M':
rev += 1
먼저 svn 상태에는 개정 번호가 있으며 거기에서 읽을 수 있습니다.
또한 SVN에 저장하는 각 파일은 자체적으로 개정 번호를 저장할 수 있습니다.
$Rev$
파일에 키워드를 추가하고 propset을 실행합니다.svn propset svn:keywords "Revision" file
마지막으로 개정 번호도
.svn/entries
파일, 네 번째 줄에 있습니다.
이제 해당 파일을 체크 아웃 할 때마다 수정본이 그대로 유지됩니다.
REV =svn info svn://svn.code.sf.net/p/retroshare/code/trunk | grep 'Revision:' | cut -d\ -f2
svn info
, 나는 당신이 원하는 것입니다.
수정본을 원했다면 다음과 같이 할 수 있습니다.
svn info | grep "Revision:"
Subversion의 XML 출력을 활용하여 다음과 같이 사용하십시오.
# parse rev from popen "svn info --xml"
dom = xml.dom.minidom.parse(os.popen('svn info --xml'))
entry = dom.getElementsByTagName('entry')[0]
revision = entry.getAttribute('revision')
필요한 <commit revision=...>
항목 에 따라 항목이 원하는 항목이 더 많을 수 있습니다. 이것은 "Last Changed Rev"를 제공합니다. 이는 현재 트리의 코드가 실제로 변경 될 때까지 변경되지 않습니다. "Revision"(위에서 제공하는 것)이 리포지토리의 모든 항목이 변경 될 때마다 (분기도) 변경되는 것과는 대조적입니다. 그리고 당신은 "svn up"을하는데, 이것은 똑같지도 않고 자주 유용하지도 않습니다.
다음을 사용하여 수정 된 버전에서 @badcat의 답변을 사용했습니다 subprocess.check_output()
.
import subprocess
revision = subprocess.check_output("svn info | awk '/^Revision:/ {print $2}'", shell=True).strip()
svn과 인터페이스하기 위해 python을 사용 하려면 pysvn을 설치하고 사용할 수도 있습니다 .
Nobody mention for Windows world SubWCRev, which, properly used, can substitute needed data into the needed places automagically, if script call SubWCRev in form SubWCRev WC_PATH TPL-FILE READY-FILE
Sample of my post-commit hook (part of)
SubWCRev.exe CustomLocations Builder.tpl z:\Builder.bat
...
call z:\Builder.bat
where my Builder.tpl is
svn.exe export trunk z:\trunk$WCDATE=%Y%m%d$-r$WCREV$
as result, I have every time bat-file with variable part - name of dir - which corresponds to the metadata of Working Copy
I think I have to do svn info and then retrieve the number with a string manipulation from "Revision: xxxxxx" It would be just nice, if there were a command that returns just the number :)
Otherwise for old version, if '--show-item' is not recognize, you can use the following command :
svn log -r HEAD | grep -o -E "^r[0-9]{1,}" | sed 's/r//g'
Hope it helps.
참고URL : https://stackoverflow.com/questions/1991526/current-subversion-revision-command
'program story' 카테고리의 다른 글
자바 스크립트에 지연 추가 (0) | 2020.11.17 |
---|---|
오른쪽 괄호가있는 정렬 된 목록 (HTML) 하위 알파? (0) | 2020.11.17 |
jQuery로 호버 상태를 강제하는 방법은 무엇입니까? (0) | 2020.11.17 |
Linux : 기본 브라우저에서 URL을 여는 명령 (0) | 2020.11.17 |
네트워크에서 XAMPP에 액세스하려고 할 때 오류 발생 (0) | 2020.11.17 |