Last change
on this file since 18870 was 12928, checked in by bastiK, 7 years ago |
see #15229 - do not copy the entire preferences list, just to set a custom server API in OAuth wizard
|
-
Property svn:executable
set to
*
|
File size:
1.6 KB
|
Line | |
---|
1 | #!/usr/bin/python
|
---|
2 | # License: CC0
|
---|
3 |
|
---|
4 | """
|
---|
5 | Helper script to replace "@since xxx" in Javadoc by the upcoming revision number.
|
---|
6 |
|
---|
7 | Will retrieve the current revision number from the server. It runs over all
|
---|
8 | modified and added .java files and replaces xxx in "since xxx" by the revision
|
---|
9 | number that is to be expected for the next commit.
|
---|
10 | """
|
---|
11 |
|
---|
12 | import xml.etree.ElementTree as ElementTree
|
---|
13 | import subprocess
|
---|
14 | import re
|
---|
15 |
|
---|
16 | revision = None
|
---|
17 |
|
---|
18 | def main():
|
---|
19 | svn_status = subprocess.check_output("svn status --xml".split(" "))
|
---|
20 | for el in ElementTree.fromstring(svn_status).findall("./target/entry"):
|
---|
21 | if el.find('wc-status').get("item") not in ["added", "modified"]:
|
---|
22 | continue
|
---|
23 | path = el.get("path")
|
---|
24 | if not path.endswith('.java'):
|
---|
25 | continue
|
---|
26 | with open(path, 'r') as f:
|
---|
27 | filedata = f.read()
|
---|
28 | filedata2 = re.sub("since xxx", lambda _: "since {}".format(get_revision()), filedata)
|
---|
29 | if filedata != filedata2:
|
---|
30 | print("replacing 'since xxx' with 'since {}' in '{}'".format(get_revision(), path))
|
---|
31 | with open(path, 'w') as f:
|
---|
32 | f.write(filedata2)
|
---|
33 |
|
---|
34 | def get_revision():
|
---|
35 | global revision
|
---|
36 | if revision is not None:
|
---|
37 | return revision
|
---|
38 | svn_info_local = subprocess.check_output("svn info --xml".split(" "))
|
---|
39 | rep_url = ElementTree.fromstring(svn_info_local).findtext("./entry/repository/root")
|
---|
40 | svn_info_server = subprocess.check_output("svn info --xml".split(" ") + [rep_url])
|
---|
41 | revision = int(ElementTree.fromstring(svn_info_server).find("./entry").get("revision")) + 1
|
---|
42 | return revision
|
---|
43 |
|
---|
44 | main()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.