Merge lp:~hjd/widelands/utils-cleanup into lp:widelands

Proposed by Hans Joachim Desserud
Status: Merged
Merged at revision: 6996
Proposed branch: lp:~hjd/widelands/utils-cleanup
Merge into: lp:widelands
Diff against target: 114 lines (+2/-72)
3 files modified
utils/count-longlines.py (+0/-49)
utils/create_cppcheck_report (+1/-1)
utils/detect_revision.py (+1/-22)
To merge this branch: bzr merge lp:~hjd/widelands/utils-cleanup
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+224023@code.launchpad.net

Description of the change

* detect_revsion had the ability to detect git revision, however from what I could see it boiled down to using git-svn to get the svn revision. Feel free to correct me if this still makes sense, but it seems to be a relic from when Widelands lived on sourceforge, was hosted with subversion and someone presumably used git-svn to get nifty features like branches.
* Removed count-longlines.py since line length is checked at compile time by codecheck.
* When reading the cppcheck manpage I discovered that --std=c++11 is the default option. I am not sure how relevant checking against the other standards were (c99 and posix), so I simply removed them, since I figured c++11 was the most important one.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Good changes! Thanks for cleaning up.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'utils/count-longlines.py'
2--- utils/count-longlines.py 2010-11-15 21:23:02 +0000
3+++ utils/count-longlines.py 1970-01-01 00:00:00 +0000
4@@ -1,49 +0,0 @@
5-#!/usr/bin/python -tt
6-"""./count-longlines.py
7-(called from main widelands directory)
8-
9-Count lines that are too long to fit on 80 character screens
10-when using different tabwidths."""
11-
12-import fnmatch
13-import os
14-import string
15-import fileinput
16-import sys
17-
18-def find(root, glob):
19- files=[]
20- for file in os.listdir(root):
21- file=os.path.join(root, file)
22- if fnmatch.fnmatch(file, glob):
23- files.append(file)
24- if os.path.isdir(file):
25- files+=find(file, glob)
26- return files
27-
28-files =find(".", "*.h")
29-files+=find(".", "*.cc")
30-
31-shortlines=0
32-longlines=0
33-oversizelines=0
34-
35-for line in fileinput.input(files):
36- line2=line.expandtabs(2).rstrip()
37- line3=line.expandtabs(3).rstrip()
38-
39- if len(line3)>80:
40- longlines+=1
41- if len(line2)>80:
42- oversizelines+=1
43- else:
44- shortlines+=1
45-
46-lines=shortlines + longlines
47-print
48-print "Total lines: %7i 100.00%%" % (lines)
49-print "Short lines <80 @ tabwidth=3: %7i %6.2f%%" % (shortlines, 100.0*shortlines/lines)
50-print "Long lines >80 @ tabwidth=3: %7i %6.2f%%" % (longlines, 100.0*longlines/lines)
51-print
52-print "OVERSIZE LINES !! >80 @ tabwidth=2: %7i %6.2f%%" % (oversizelines, 100.0*oversizelines/lines)
53-print
54
55=== modified file 'utils/create_cppcheck_report'
56--- utils/create_cppcheck_report 2012-04-29 15:44:08 +0000
57+++ utils/create_cppcheck_report 2014-06-21 15:30:27 +0000
58@@ -8,7 +8,7 @@
59 cppcheck --version >> $FILE
60 echo "</h2>" >> $FILE
61 echo "<div>" >> $FILE
62-cppcheck --force --quiet --verbose --std=posix --std=c99 --std=c++11 --enable=all -I src src 2>&1 | sed "s@^\[\(.*\):\([[:digit:]]\+\)\]: \(.*\)\$@<a href=\"http://bazaar.launchpad.net/%7Ewidelands-dev/widelands/trunk/annotate/head%3A/\1\?#L\2\">\1:\2</a>: \3<br/>@" >> $FILE
63+cppcheck --force --quiet --verbose --enable=all -I src src 2>&1 | sed "s@^\[\(.*\):\([[:digit:]]\+\)\]: \(.*\)\$@<a href=\"http://bazaar.launchpad.net/%7Ewidelands-dev/widelands/trunk/annotate/head%3A/\1\?#L\2\">\1:\2</a>: \3<br/>@" >> $FILE
64 echo "</div>" >> $FILE
65 echo "</body>" >> $FILE
66 echo "</html>" >> $FILE
67
68=== modified file 'utils/detect_revision.py'
69--- utils/detect_revision.py 2013-07-26 09:50:23 +0000
70+++ utils/detect_revision.py 2014-06-21 15:30:27 +0000
71@@ -2,7 +2,7 @@
72 # -*- coding: utf-8 -*-
73
74 # Tries to find out the repository revision of the current working directory
75-# using bzr or git
76+# using bzr or debian/changelog
77
78 import os
79 import sys
80@@ -52,26 +52,6 @@
81 if os.path.exists(fname):
82 return open(fname).read().strip()
83
84-def detect_git_revision():
85- if not sys.platform.startswith('linux') and \
86- not sys.platform.startswith('darwin'):
87- return None
88-
89- is_git_workdir=os.system('git show >/dev/null 2>&1')==0
90- if is_git_workdir:
91- git_revnum=os.popen('git show --pretty=format:%h | head -n 1').read().rstrip()
92- is_pristine=os.popen('git show --pretty=format:%b | grep ^git-svn-id\\:').read().find("git-svn-id:") == 0
93- common_ancestor=os.popen('git show-branch --sha1-name refs/remotes/git-svn HEAD | tail -n 1 | sed "s@++ \\[\\([0-9a-f]*\\)\\] .*@\\1@"').read().rstrip()
94- svn_revnum=os.popen('git show --pretty=format:%b%n '+common_ancestor+' | grep ^git-svn-id\\: -m 1 | sed "sM.*@\\([0-9]*\\) .*M\\1M"').read().rstrip()
95-
96- if svn_revnum=='':
97- return 'unofficial-git-%s' % (git_revnum,)
98- elif is_pristine:
99- return 'unofficial-git-%s(svn%s)' % (git_revnum, svn_revnum)
100- else:
101- return 'unofficial-git-%s(svn%s+changes)' % (git_revnum, svn_revnum)
102-
103-
104 def detect_bzr_revision():
105 if __has_bzrlib:
106 b = BzrDir.open(base_path).open_branch()
107@@ -92,7 +72,6 @@
108 def detect_revision():
109 for func in (
110 check_for_explicit_version,
111- detect_git_revision,
112 detect_bzr_revision,
113 detect_debian_version):
114 rv = func()

Subscribers

People subscribed via source and target branches

to status/vote changes: