Merge lp:~adrien-saladin/ptools/bzrrev into lp:ptools

Proposed by Adrien Saladin
Status: Merged
Approved by: Adrien Saladin
Approved revision: no longer in the source branch.
Merge reported by: Adrien Saladin
Merged at revision: not available
Proposed branch: lp:~adrien-saladin/ptools/bzrrev
Merge into: lp:ptools
Diff against target: 816 lines (+77/-368)
43 files modified
.bzrignore (+2/-0)
PyAttract/Attract.py (+5/-4)
SConstruct (+2/-10)
atom.cpp (+0/-1)
atom.h (+0/-3)
atomselection.cpp (+0/-1)
atomselection.h (+0/-1)
attractrigidbody.cpp (+0/-1)
attractrigidbody.h (+0/-1)
basetypes.cpp (+0/-1)
basetypes.h (+0/-1)
bzrrev.py (+39/-0)
coord3d.cpp (+0/-1)
coord3d.h (+0/-1)
coordsarray.cpp (+0/-1)
coordsarray.h (+0/-1)
derivify.h (+0/-1)
forcefield.cpp (+0/-1)
forcefield.h (+0/-1)
geometry.cpp (+0/-1)
geometry.h (+0/-1)
interface.py (+3/-4)
mcopff.cpp (+0/-1)
mcopff.h (+0/-1)
pairlist.cpp (+0/-1)
pairlist.h (+0/-1)
pdbio.cpp (+0/-1)
pdbio.h (+0/-1)
ptools.h (+0/-1)
py_details.h (+0/-1)
rigidbody.cpp (+0/-1)
rigidbody.h (+0/-1)
rmsd.cpp (+0/-1)
rmsd.h (+0/-1)
screw.h (+0/-1)
superpose.cpp (+0/-1)
superpose.h (+0/-1)
surface.cpp (+0/-1)
surface.h (+0/-1)
svnrev.c (+0/-280)
svnrev.h (+0/-18)
version.cpp (+6/-6)
version.h (+20/-10)
To merge this branch: bzr merge lp:~adrien-saladin/ptools/bzrrev
Reviewer Review Type Date Requested Status
Pierre Poulain Approve
Review via email: mp+21328@code.launchpad.net

Description of the change

switch from svnrev to a bzr-powered revision numbering system.

Please test :)

To post a comment you must log in.
Revision history for this message
Pierre Poulain (pierrepo) wrote :

How do I test correctly?
Just downloading the branch, compiling PTools and running PyAttract?

Revision history for this message
Pierre Poulain (pierrepo) wrote :

I tried. Compiled fine.
I get this with Attract.py
----------------------------------------------------------------------------------

**********************************************************************
** ATTRACT (Python edition) **
** version: 0.3 **
**********************************************************************
Attract.py
using PTools rev.:433, from branch: bzrrev, unique id: <email address hidden>

----------------------------------------------------------------------------------
I am not sure "version: 0.3" means anything. Is it for major revision, i.e milestones?
Instead of "0.3", could we have "1.0"?

Can you remove ":" after version, PTools, branch and unique id?

Revision history for this message
Adrien Saladin (adrien-saladin) wrote :

I'll do this tonight.
Should I encapsulate revision number, unique id, etc inside the
Attract header, instead of
'version 0.3' ?

Cheers,
Adrien

On Tue, Mar 16, 2010 at 11:16 AM, Pierre Poulain <email address hidden> wrote:
> I tried. Compiled fine.
> I get this with Attract.py
> ----------------------------------------------------------------------------------
>
> **********************************************************************
> **                ATTRACT  (Python edition)                         **
> **                version: 0.3                                      **
> **********************************************************************
> Attract.py
> using PTools rev.:433, from branch: bzrrev, unique id: <email address hidden>
>
> ----------------------------------------------------------------------------------
> I am not sure "version: 0.3" means anything. Is it for major revision, i.e milestones?
> Instead of "0.3", could we have "1.0"?
>
> Can you remove ":" after version, PTools, branch and unique id?
>
>
>
> --
> https://code.launchpad.net/~adrien-saladin/ptools/bzrrev/+merge/21328
> You are the owner of lp:~adrien-saladin/ptools/bzrrev.
>

Revision history for this message
Pierre Poulain (pierrepo) wrote :

I believe we should have two numberings.
One corresponding to the PTools library revision number (i.e 433), updated automatically by bazaar.
A second, corresponding to the PTools library version number (i.e. 1.0.4c a this time), updated manually and linked to what launchpad calls milestones.

As I said, revision number is increased at each commit. We increase version number only if major improvements have been brought to PTools.

The revision numbering system is coded in PTools (this is the purpose of this branch).
Could we had a version numbering system in PTools ? For example, in defining a new "std::string verstr" in version.h and setting up "this->verstr = 1.0.4c" in version.ccp

This way we could have:
----------------------------------------------------------------------------------

**********************************************************************
** ATTRACT (Python edition) **
** version: 1.0.4c **
**********************************************************************
Attract.py
using PTools rev.:433, from branch: bzrrev, unique id: <email address hidden>
----------------------------------------------------------------------------------

lp:~adrien-saladin/ptools/bzrrev updated
434. By Adrien Saladin

minor output format fix

Revision history for this message
Adrien Saladin (adrien-saladin) wrote :

Did my last commit fix the version issue ?

Revision history for this message
Pierre Poulain (pierrepo) wrote :

Yes and no.
Yes for the revision numbering and no for the version numbering.
"version: this is a development version," is not sufficient.
However, I will approve the branch.
I guess we have to talk more on the version numbering, I'll raise a bug for it.

review: Approve
lp:~adrien-saladin/ptools/bzrrev updated
435. By Adrien Saladin

cleaning all $Id$ from .h and .cpp files

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-01-30 17:37:52 +0000
3+++ .bzrignore 2010-03-17 22:36:38 +0000
4@@ -6,3 +6,5 @@
5 svnrev
6 .sconsign*
7 Tests/ptoolstest.bin
8+version.py
9+bzrrev.h
10
11=== modified file 'PyAttract/Attract.py'
12--- PyAttract/Attract.py 2008-11-25 12:42:39 +0000
13+++ PyAttract/Attract.py 2010-03-17 22:36:38 +0000
14@@ -191,11 +191,12 @@
15 print """
16 **********************************************************************
17 ** ATTRACT (Python edition) **
18-** version: 0.3 **
19+** version: this is a development version, **
20+** see below for details **
21 **********************************************************************
22-Attract.py: $Id$
23-using PTools: %s
24-"""%(Version().revstr)
25+Attract.py
26+using PTools revision %s, from branch %s, unique id %s
27+"""%(Version().revstr, Version().branchnick, Version().revid)
28
29
30
31
32=== modified file 'SConstruct'
33--- SConstruct 2010-02-04 13:30:21 +0000
34+++ SConstruct 2010-03-17 22:36:38 +0000
35@@ -18,11 +18,6 @@
36 user_path_boost = ""
37
38
39-
40-
41-#if you add a file in this list, please make sure that
42-#this .cpp file begins with " //$Id$"
43-#and type: svn propset svn:keywords Id filename
44 COMMON_CPP = Split ("""atom.cpp
45 basetypes.cpp
46 rigidbody.cpp
47@@ -53,6 +48,8 @@
48 COMMON_CPPPATH=['.']
49 FFLAGS="-g"
50
51+#generates bzrrev.h:
52+import bzrrev
53
54
55 def FIND_FILE(name,path, useEnvPath=False):
56@@ -186,11 +183,6 @@
57 PYTHON_CPP.append("Pybindings/%s"%file)
58
59
60-#generate svnrev.h (revision number of the library)
61-os.system("gcc svnrev.c -o svnrev")
62-svnrevfiles = [f for f in os.listdir('.') if fnmatch.fnmatch(f, "*.cpp") or fnmatch.fnmatch(f,"*.h") and not fnmatch.fnmatch(f,"svnrev.*") ] #list every .h or .cpp
63-os.system("./svnrev %s"%(" ".join(svnrevfiles)))
64-
65
66 if compile_mode == "release":
67 ccflags = "-Wall -O2 -fPIC -Woverloaded-virtual -DNDEBUG -ffunction-sections -fvisibility=hidden"
68
69=== modified file 'atom.cpp'
70--- atom.cpp 2009-05-24 20:30:19 +0000
71+++ atom.cpp 2010-03-17 22:36:38 +0000
72@@ -1,4 +1,3 @@
73-// $Id$
74 #include <sstream>
75 #include <stdio.h>
76
77
78=== modified file 'atom.h'
79--- atom.h 2008-11-25 12:26:40 +0000
80+++ atom.h 2010-03-17 22:36:38 +0000
81@@ -1,6 +1,3 @@
82-// $Id$
83-
84-
85 #ifndef ATOM_H
86 #define ATOM_H
87
88
89=== modified file 'atomselection.cpp'
90--- atomselection.cpp 2008-12-23 11:05:27 +0000
91+++ atomselection.cpp 2010-03-17 22:36:38 +0000
92@@ -1,4 +1,3 @@
93-// $Id$
94 //
95 // C++ Implementation: atomselection
96 //
97
98=== modified file 'atomselection.h'
99--- atomselection.h 2008-12-23 11:05:27 +0000
100+++ atomselection.h 2010-03-17 22:36:38 +0000
101@@ -1,4 +1,3 @@
102-// $Id$
103 //
104 // C++ Interface: atomselection
105 //
106
107=== modified file 'attractrigidbody.cpp'
108--- attractrigidbody.cpp 2009-03-12 13:32:25 +0000
109+++ attractrigidbody.cpp 2010-03-17 22:36:38 +0000
110@@ -1,4 +1,3 @@
111-// $Id$
112 /****************************************************************************
113 * Copyright (C) 2008 Adrien Saladin *
114 * adrien.saladin@gmail.com *
115
116=== modified file 'attractrigidbody.h'
117--- attractrigidbody.h 2009-03-12 13:32:25 +0000
118+++ attractrigidbody.h 2010-03-17 22:36:38 +0000
119@@ -1,4 +1,3 @@
120-// $Id$
121 /****************************************************************************
122 * Copyright (C) 2008 Adrien Saladin *
123 * adrien.saladin@gmail.com *
124
125=== modified file 'basetypes.cpp'
126--- basetypes.cpp 2008-12-22 15:05:30 +0000
127+++ basetypes.cpp 2010-03-17 22:36:38 +0000
128@@ -1,4 +1,3 @@
129-// $Id$
130 /****************************************************************************
131 * Copyright (C) 2006-2008 Adrien Saladin *
132 * adrien.saladin@gmail.com *
133
134=== modified file 'basetypes.h'
135--- basetypes.h 2010-03-12 22:33:32 +0000
136+++ basetypes.h 2010-03-17 22:36:38 +0000
137@@ -1,4 +1,3 @@
138-// $Id$
139 /****************************************************************************
140 * Copyright (C) 2006-2008 Adrien Saladin *
141 * adrien.saladin@gmail.com *
142
143=== added file 'bzrrev.py'
144--- bzrrev.py 1970-01-01 00:00:00 +0000
145+++ bzrrev.py 2010-03-17 22:36:38 +0000
146@@ -0,0 +1,39 @@
147+#!/usr/bin/env python
148+
149+import os
150+
151+
152+################### bzrRev: uses bzr branch (if exists) information to
153+# determine a unique revision number
154+def bzrRev():
155+ if os.path.exists(".bzr"):
156+ os.system("bzr version-info --python> version.py")
157+ from string import Template
158+ import version #import newly generated version.py file
159+ fich = open("bzrrev.h","w")
160+
161+ template=Template("""/* This file was generated by the "bzrRev" function
162+ * in SConstruct
163+ * You should not modify it manually, as it may be re-generated.
164+
165+ */
166+
167+#ifndef BZRREH_H
168+#define BZRREV_H
169+
170+#define BZR_REV $revno
171+#define BZR_REVSTR "$revno"
172+#define BZR_BRANCHNICK "$branch_nick"
173+#define BZR_REVDATE "$date"
174+#define BZR_REVID "$revision_id"
175+#define SVN_MODIFIED "$clean"
176+
177+#endif /* BZRREV_H */
178+
179+
180+""")
181+ fich.write(template.substitute(version.version_info))
182+
183+
184+
185+bzrRev()
186\ No newline at end of file
187
188=== modified file 'coord3d.cpp'
189--- coord3d.cpp 2008-11-25 12:26:40 +0000
190+++ coord3d.cpp 2010-03-17 22:36:38 +0000
191@@ -1,4 +1,3 @@
192-// $Id$
193 #include "coord3d.h"
194
195 #include <string>
196
197=== modified file 'coord3d.h'
198--- coord3d.h 2008-11-25 12:26:40 +0000
199+++ coord3d.h 2010-03-17 22:36:38 +0000
200@@ -1,4 +1,3 @@
201-// $Id$
202 #ifndef COORD3D_H
203 #define COORD3D_H
204
205
206=== modified file 'coordsarray.cpp'
207--- coordsarray.cpp 2009-06-02 14:57:07 +0000
208+++ coordsarray.cpp 2010-03-17 22:36:38 +0000
209@@ -1,4 +1,3 @@
210-// $Id$
211 /****************************************************************************
212 * Copyright (C) 2008 Adrien Saladin *
213 * adrien.saladin@gmail.com *
214
215=== modified file 'coordsarray.h'
216--- coordsarray.h 2008-11-25 12:26:40 +0000
217+++ coordsarray.h 2010-03-17 22:36:38 +0000
218@@ -1,4 +1,3 @@
219-// $Id$
220 /****************************************************************************
221 * Copyright (C) 2008 Adrien Saladin *
222 * adrien.saladin@gmail.com *
223
224=== modified file 'derivify.h'
225--- derivify.h 2008-11-25 12:26:40 +0000
226+++ derivify.h 2010-03-17 22:36:38 +0000
227@@ -1,4 +1,3 @@
228-// $Id$
229 /****************************************************************************
230 * Copyright Joaquim R. R. A. Martins, Peter Sturdza *
231 * *
232
233=== modified file 'forcefield.cpp'
234--- forcefield.cpp 2010-02-04 13:30:21 +0000
235+++ forcefield.cpp 2010-03-17 22:36:38 +0000
236@@ -1,4 +1,3 @@
237-// $Id$
238 #include "forcefield.h"
239 #include "geometry.h"
240 #include "rmsd.h"
241
242=== modified file 'forcefield.h'
243--- forcefield.h 2010-02-04 13:30:21 +0000
244+++ forcefield.h 2010-03-17 22:36:38 +0000
245@@ -1,4 +1,3 @@
246-// $Id$
247 #ifndef FORCEFIELD_H
248 #define FORCEFIELD_H
249
250
251=== modified file 'geometry.cpp'
252--- geometry.cpp 2008-12-19 23:07:46 +0000
253+++ geometry.cpp 2010-03-17 22:36:38 +0000
254@@ -1,4 +1,3 @@
255-// $Id$
256 #include "geometry.h"
257
258
259
260=== modified file 'geometry.h'
261--- geometry.h 2008-12-19 23:07:46 +0000
262+++ geometry.h 2010-03-17 22:36:38 +0000
263@@ -1,4 +1,3 @@
264-// $Id$
265 #ifndef GEOMETRY
266 #define GEOMETRY
267
268
269=== modified file 'interface.py'
270--- interface.py 2009-01-24 17:35:21 +0000
271+++ interface.py 2010-03-17 22:36:38 +0000
272@@ -3,10 +3,9 @@
273
274 import fnmatch
275
276-#generate svnrev.h (revision number of the library)
277-os.system("gcc svnrev.c -o svnrev")
278-svnrevfiles = [f for f in os.listdir('.') if fnmatch.fnmatch(f, "*.cpp") or fnmatch.fnmatch(f,"*.h") and not fnmatch.fnmatch(f,"svnrev.*") ] #list every .h or .cpp
279-os.system("./svnrev %s"%(" ".join(svnrevfiles)))
280+#generates bzrrev.h:
281+import bzrrev
282+
283
284 #Creating an instance of class that will help you to expose your declarations
285 mb = module_builder.module_builder_t( [os.path.abspath('./ptools.h'), os.path.abspath('./py_details.h')]
286
287=== modified file 'mcopff.cpp'
288--- mcopff.cpp 2008-11-25 12:26:40 +0000
289+++ mcopff.cpp 2010-03-17 22:36:38 +0000
290@@ -1,4 +1,3 @@
291-// $Id$
292 #include "mcopff.h"
293 #include <cassert>
294
295
296=== modified file 'mcopff.h'
297--- mcopff.h 2010-02-04 13:30:21 +0000
298+++ mcopff.h 2010-03-17 22:36:38 +0000
299@@ -1,4 +1,3 @@
300-// $Id$
301 // multicopy-forcefield
302 //
303 //
304
305=== modified file 'pairlist.cpp'
306--- pairlist.cpp 2008-11-25 12:26:40 +0000
307+++ pairlist.cpp 2010-03-17 22:36:38 +0000
308@@ -1,4 +1,3 @@
309-// $Id$
310 #include "pairlist.h"
311
312 namespace PTools
313
314=== modified file 'pairlist.h'
315--- pairlist.h 2008-11-25 12:26:40 +0000
316+++ pairlist.h 2010-03-17 22:36:38 +0000
317@@ -1,4 +1,3 @@
318-// $Id$
319 #ifndef PAIRLIST_H
320 #define PAIRLIST_H
321
322
323=== modified file 'pdbio.cpp'
324--- pdbio.cpp 2009-01-23 10:24:54 +0000
325+++ pdbio.cpp 2010-03-17 22:36:38 +0000
326@@ -1,4 +1,3 @@
327-// $Id$
328 #include <algorithm>
329 #include <cctype>
330 #include <iostream>
331
332=== modified file 'pdbio.h'
333--- pdbio.h 2009-01-23 10:24:54 +0000
334+++ pdbio.h 2010-03-17 22:36:38 +0000
335@@ -1,4 +1,3 @@
336-// $Id$
337 #ifndef PDBIO_H
338 #define PDBIO_H
339
340
341=== modified file 'ptools.h'
342--- ptools.h 2008-12-22 15:05:30 +0000
343+++ ptools.h 2010-03-17 22:36:38 +0000
344@@ -1,4 +1,3 @@
345-// $Id$
346 //
347 // C++ Interface: generic interface for ptools
348 //
349
350=== modified file 'py_details.h'
351--- py_details.h 2008-11-25 12:26:40 +0000
352+++ py_details.h 2010-03-17 22:36:38 +0000
353@@ -1,4 +1,3 @@
354-// $Id$
355 #include "pairlist.h"
356 #include "ptools.h"
357 #include "coord3d.h"
358
359=== modified file 'rigidbody.cpp'
360--- rigidbody.cpp 2009-05-24 20:30:19 +0000
361+++ rigidbody.cpp 2010-03-17 22:36:38 +0000
362@@ -1,4 +1,3 @@
363-// $Id$
364 /****************************************************************************
365 * Copyright (C) 2006-2008 Adrien Saladin *
366 * adrien.saladin@gmail.com *
367
368=== modified file 'rigidbody.h'
369--- rigidbody.h 2009-05-24 20:30:19 +0000
370+++ rigidbody.h 2010-03-17 22:36:38 +0000
371@@ -1,4 +1,3 @@
372-// $Id$
373 /****************************************************************************
374 * Copyright (C) 2006-2008 Adrien Saladin *
375 * adrien.saladin@gmail.com *
376
377=== modified file 'rmsd.cpp'
378--- rmsd.cpp 2008-12-22 15:05:30 +0000
379+++ rmsd.cpp 2010-03-17 22:36:38 +0000
380@@ -1,4 +1,3 @@
381-// $Id$
382 #include <iostream>
383 #include <cassert>
384 #include <stdexcept>
385
386=== modified file 'rmsd.h'
387--- rmsd.h 2008-12-22 15:05:30 +0000
388+++ rmsd.h 2010-03-17 22:36:38 +0000
389@@ -1,4 +1,3 @@
390-// $Id$
391 #ifndef RMSD_H
392 #define RMSD_H
393
394
395=== modified file 'screw.h'
396--- screw.h 2008-12-22 15:05:30 +0000
397+++ screw.h 2010-03-17 22:36:38 +0000
398@@ -1,4 +1,3 @@
399-// $Id$
400 /****************************************************************************
401 * Copyright (C) 2006-2008 Adrien Saladin *
402 * adrien.saladin@gmail.com *
403
404=== modified file 'superpose.cpp'
405--- superpose.cpp 2008-12-22 15:05:30 +0000
406+++ superpose.cpp 2010-03-17 22:36:38 +0000
407@@ -1,4 +1,3 @@
408-// $Id$
409 /****************************************************************************
410 * Copyright (C) 2006-2008 Adrien Saladin *
411 * adrien.saladin@gmail.com *
412
413=== modified file 'superpose.h'
414--- superpose.h 2008-12-22 15:05:30 +0000
415+++ superpose.h 2010-03-17 22:36:38 +0000
416@@ -1,4 +1,3 @@
417-// $Id$
418 /****************************************************************************
419 * Copyright (C) 2006-2008 Adrien Saladin *
420 * adrien.saladin@gmail.com *
421
422=== modified file 'surface.cpp'
423--- surface.cpp 2010-03-12 22:04:33 +0000
424+++ surface.cpp 2010-03-17 22:36:38 +0000
425@@ -1,4 +1,3 @@
426-// $Id$
427
428 #include "surface.h"
429 #include "attractrigidbody.h"
430
431=== modified file 'surface.h'
432--- surface.h 2010-03-12 22:04:33 +0000
433+++ surface.h 2010-03-17 22:36:38 +0000
434@@ -1,4 +1,3 @@
435-// $Id$
436 #include <iostream>
437 #include <fstream>
438 #include <string>
439
440=== removed file 'svnrev.c'
441--- svnrev.c 2008-11-25 12:26:40 +0000
442+++ svnrev.c 1970-01-01 00:00:00 +0000
443@@ -1,280 +0,0 @@
444-/* SvnRev
445- *
446- * This utility retrieves the highest number that follows the "$Id:�$" keyword
447- * or a combination of the $Rev:�$ and $Date:�$ keywords. The Subversion
448- * version control system expands these keywords and keeps them up to date.
449- * For an example of the tag, see the end of this comment.
450- *
451- * Details on the usage and the operation of this utility is available on-line
452- * at http://www.compuphase.com/svnrev.htm.
453- *
454- *
455- * License
456- *
457- * Copyright (c) 2005-2007, ITB CompuPhase (www.compuphase.com).
458- *
459- * This software is provided "as-is", without any express or implied warranty.
460- * In no event will the authors be held liable for any damages arising from
461- * the use of this software.
462- *
463- * Permission is granted to anyone to use this software for any purpose,
464- * including commercial applications, and to alter it and redistribute it
465- * freely, subject to the following restrictions:
466- *
467- * 1. The origin of this software must not be misrepresented; you must not
468- * claim that you wrote the original software. If you use this software in
469- * a product, an acknowledgment in the product documentation would be
470- * appreciated but is not required.
471- * 2. Altered source versions must be plainly marked as such, and must not be
472- * misrepresented as being the original software.
473- * 3. This notice may not be removed or altered from any source distribution.
474- *
475- * Pursuant to #2 above: this version was modified by Tom McCann (tommc@spoken.com)
476- * to support output of .java files.
477- *
478- * Version: $Id: svnrev.c 3852 2007-11-26 10:37:51Z thiadmer $
479- */
480-
481-#include <stdio.h>
482-#include <stdlib.h>
483-#include <string.h>
484-#include "svnrev.h"
485-
486-
487-#if defined __WIN32__ || defined _Win32 || defined _WIN32
488- #define DIRSEP '\\'
489-#elif defined macintosh
490- #define DIRSEP ':'
491-#else
492- /* assume Linux/Unix */
493- #define DIRSEP '/'
494-#endif
495-
496-
497-static void about(void)
498-{
499- printf("svnrev 1.5." SVN_REVSTR "\n\n");
500- printf("Usage: svnrev [-ofilename] [-i] [-jpackage] <input> [input [...]]\n\n"
501- "The -o option sets the filename for the output file with the build number.\n"
502- "When no filename follows \"-o\", the result is written to stdout. The default\n"
503- "filename is \"svnrev.h\" for C/C++ and \"VersionInfo.java\" for Java.\n\n"
504- "The -i option should be used when the file list is only a partial set of all\n"
505- "files. With this option, svnrev also scans the output file that was generated\n"
506- "on a previous run.\n\n"
507- "The -j option writes a java package file instead of a C/C++ header file. The\n"
508- "name of the package must follow the option.\n");
509- exit(1);
510-}
511-
512-static void processfile(const char *name, int failsilent,
513- int *max_build, int *accum_build,
514- int *max_year, int *max_month, int *max_day,
515- int *ismodified)
516-
517-{
518- char str[512], str_base[512];
519- char name_base[512];
520- char *p1;
521- FILE *fp, *fp_base;
522- int build, maj_build;
523- int year, month, day;
524- int cnt;
525- char modchar;
526-
527- /* since we also want to verify whether the file is modified in version
528- * control, get the path to the working copy name
529- * for every source file "<path>\<filename>, the "working copy" base can
530- * be found in "<path>\.svn\text-base\<filename>.svn-base"
531- */
532- if ((p1 = strrchr(name, DIRSEP)) != NULL) {
533- ++p1; /* skip directory separator character ('\' in Windows, '/' in Linux) */
534- strncpy(name_base, name, (int)(p1 - name));
535- name_base[(int)(p1 - name)] = '\0';
536- } else {
537- name_base[0] = '\0';
538- p1 = (char*)name;
539- } /* if */
540- sprintf(name_base + strlen(name_base), ".svn%ctext-base%c%s.svn-base",
541- DIRSEP, DIRSEP, p1);
542-
543- /* first extract the revision keywords */
544- fp = fopen(name, "r");
545- if (fp == NULL) {
546- if (!failsilent)
547- fprintf(stderr, "Failed to open input file '%s'\n", name);
548- return;
549- } /* if */
550- fp_base = fopen(name_base, "r"); /* fail silently */
551- build = 0;
552- maj_build = 0; /* RCS / CVS */
553- year = month = day = 0;
554-
555- while (fgets(str, sizeof str, fp) != NULL) {
556- if (fp_base == NULL || fgets(str_base, sizeof str_base, fp_base) == NULL)
557- str_base[0] = '\0';
558- if ((p1 = strstr(str, "$Id:")) != NULL && strchr(p1+1, '$') != NULL) {
559- if (sscanf(p1, "$Id: %*s %d %d-%d-%d", &build, &year, &month, &day) < 4
560- && sscanf(p1, "$Id: %*s %d %d/%d/%d", &build, &year, &month, &day) < 4)
561- if (sscanf(p1, "$Id: %*s %d.%d %d-%d-%d", &maj_build, &build, &year, &month, &day) < 5)
562- sscanf(p1, "$Id: %*s %d.%d %d/%d/%d", &maj_build, &build, &year, &month, &day);
563- } else if ((p1 = strstr(str, "$Rev:")) != NULL && strchr(p1+1, '$') != NULL) {
564- if (sscanf(p1, "$Rev: %d.%d", &maj_build, &build) < 2) {
565- sscanf(p1, "$Rev: %d", &build);
566- maj_build = 0;
567- } /* if */
568- } else if ((p1 = strstr(str, "$Revision:")) != NULL && strchr(p1+1, '$') != NULL) {
569- if (sscanf(p1, "$Revision: %d.%d", &maj_build, &build) < 2) {
570- /* SvnRev also writes this keyword in its own generated file; read it
571- * back for partial updates
572- */
573- cnt = sscanf(p1, "$Revision: %d%c", &build, &modchar);
574- if (cnt == 2 && modchar == 'M' && ismodified != NULL)
575- *ismodified = 1;
576- maj_build = 0;
577- } /* if */
578- } else if ((p1 = strstr(str, "$Date:")) != NULL && strchr(p1+1, '$') != NULL) {
579- if (sscanf(p1, "$Date: %d-%d-%d", &year, &month, &day) < 3)
580- sscanf(p1, "$Date: %d/%d/%d", &year, &month, &day);
581- } else if (ismodified != NULL && *ismodified == 0 && fp_base != NULL) {
582- /* no keyword present, compare the lines for equivalence */
583- *ismodified = strcmp(str, str_base) != 0;
584- } /* if */
585-
586- if (maj_build)
587- *accum_build += build; /* RCS / CVS */
588- else if (build > *max_build)
589- *max_build = build; /* Subversion */
590- if (year > *max_year
591- || (year == *max_year && month > *max_month)
592- || (year == *max_year && month == *max_month && day > *max_day))
593- {
594- *max_year = year;
595- *max_month = month;
596- *max_day = day;
597- } /* if */
598- if (build > 0 && year > 0 && (fp_base == NULL || ismodified == NULL || *ismodified != 0))
599- break; /* both build # and date found, not comparing or modification
600- * already found => no need to search further */
601-
602- } /* while */
603- fclose(fp);
604- if (fp_base != NULL)
605- fclose(fp_base);
606-}
607-
608-int main(int argc, char *argv[])
609-{
610- char *outname = NULL;
611- FILE *fp;
612- int index;
613- int process_self = 0;
614- int max_build, accum_build;
615- int max_year, max_month, max_day;
616- int ismodified;
617- int write_java = 0; /* flag for Java output, 0=.h output, 1=.java output */
618- /* java package to put revision info in.
619- * REVIEW - I assume if you want Java output you will specify a package. */
620- char *java_package = NULL;
621-
622- if (argc <= 1)
623- about();
624-
625- /* phase 1: scan through all files and get the highest build number */
626-
627- max_build = 0;
628- accum_build = 0; /* for RCS / CVS */
629- max_year = max_month = max_day = 0;
630- ismodified = 0;
631- for (index = 1; index < argc; index++) {
632- /* check for options */
633- if (argv[index][0] == '-'
634-#if defined __WIN32__ || defined _Win32 || defined _WIN32
635- || argv[index][0] == '/'
636-#endif
637- )
638- {
639- switch (argv[index][1]) {
640- case 'o':
641- outname = &argv[index][2];
642- continue;
643- case 'i':
644- process_self = 1;
645- continue;
646- case 'j':
647- write_java=1;
648- java_package = &argv[index][2];
649- continue;
650- default:
651- fprintf(stderr, "Invalid option '%s'\n", argv[index]);
652- about();
653- } /* switch */
654- } /* if */
655-
656- processfile(argv[index], 0, &max_build, &accum_build, &max_year, &max_month, &max_day, &ismodified);
657- } /* for */
658-
659- if (outname == NULL)
660- outname = write_java ? "SvnRevision.java" : "svnrev.h";
661-
662- /* also run over the existing header file, if any */
663- if (process_self && *outname != '\0')
664- processfile(outname, 1, &max_build, &accum_build, &max_year, &max_month, &max_day, NULL/*&ismodified*/);
665-
666- if (accum_build > max_build)
667- max_build = accum_build;
668-
669- /* phase 2: write a file with this highest build number */
670- if (*outname == '\0') {
671- fp = stdout;
672- } else if ((fp = fopen(outname, "w")) == NULL) {
673- fprintf(stderr, "Failed to create output file '%s'\n", outname);
674- return 2;
675- } /* if */
676- if (*outname != '\0') {
677- /* don't print the comments to stdout */
678- fprintf(fp, "/* This file was generated by the \"svnrev\" utility\n"
679- " * (http://www.compuphase.com/svnrev.htm).\n"
680- " * You should not modify it manually, as it may be re-generated.\n"
681- " *\n");
682- if (ismodified)
683- fprintf(fp, " * $Revision: %dM$\n", max_build);
684- else
685- fprintf(fp, " * $Revision: %d$\n", max_build);
686- fprintf(fp, " * $Date: %04d-%02d-%02d$\n"
687- " */\n\n", max_year, max_month, max_day);
688- } /* if */
689-
690- if (write_java) {
691- if (java_package == NULL || *java_package == '\0')
692- java_package = "com.compuphase";
693- fprintf(fp, "package %s;\n\n", java_package);
694- fprintf(fp, "public interface SvnRevision\n");
695- fprintf(fp, "{\n");
696- fprintf(fp, " public final static int SVN_REV = %d;\n", max_build);
697- if (ismodified)
698- fprintf(fp, " public final static String SVN_REVSTR = \"%dM\";\n", max_build);
699- else
700- fprintf(fp, " public final static String SVN_REVSTR = \"%d\";\n", max_build);
701- fprintf(fp, " public final static String SVN_REVDATE = \"%04d-%02d-%02d\";\n", max_year, max_month, max_day);
702- fprintf(fp, " public final static long SVN_REVSTAMP = %04d%02d%02dL;\n", max_year, max_month, max_day);
703- fprintf(fp, " public final static int SVN_MODIFIED = %d;\n", ismodified);
704- fprintf(fp, "}\n\n");
705- } else {
706- fprintf(fp, "#ifndef SVNREH_H\n");
707- fprintf(fp, "#define SVNREV_H\n\n");
708- fprintf(fp, "#define SVN_REV\t\t%d\n", max_build);
709- if (ismodified)
710- fprintf(fp, "#define SVN_REVSTR\t\"%dM\"\n", max_build);
711- else
712- fprintf(fp, "#define SVN_REVSTR\t\"%d\"\n", max_build);
713- fprintf(fp, "#define SVN_REVDATE\t\"%04d-%02d-%02d\"\n", max_year, max_month, max_day);
714- fprintf(fp, "#define SVN_REVSTAMP\t%04d%02d%02dL\n", max_year, max_month, max_day);
715- fprintf(fp, "#define SVN_MODIFIED\t%d\n", ismodified);
716- fprintf(fp, "\n#endif /* SVNREV_H */\n");
717- } /* if */
718-
719- if (*outname != '\0')
720- fclose(fp);
721-
722- return 0;
723-}
724
725=== removed file 'svnrev.h'
726--- svnrev.h 2010-02-04 13:30:21 +0000
727+++ svnrev.h 1970-01-01 00:00:00 +0000
728@@ -1,18 +0,0 @@
729-/* This file was generated by the "svnrev" utility
730- * (http://www.compuphase.com/svnrev.htm).
731- * You should not modify it manually, as it may be re-generated.
732- *
733- * $Revision: 0$
734- * $Date: 0000-00-00$
735- */
736-
737-#ifndef SVNREH_H
738-#define SVNREV_H
739-
740-#define SVN_REV 0
741-#define SVN_REVSTR "0"
742-#define SVN_REVDATE "0000-00-00"
743-#define SVN_REVSTAMP 00000000L
744-#define SVN_MODIFIED 0
745-
746-#endif /* SVNREV_H */
747
748=== modified file 'version.cpp'
749--- version.cpp 2008-12-23 11:05:27 +0000
750+++ version.cpp 2010-03-17 22:36:38 +0000
751@@ -1,13 +1,13 @@
752-//$Id$
753+
754 #include "version.h"
755
756-
757 Version::Version()
758 {
759-
760-revnb = SVN_REV;
761-revstr = std::string(SVN_REVSTR);
762-revdate = SVN_REVDATE;
763+this->revnb = BZR_REV;
764+this->revstr = BZR_REVSTR;
765+this->revdate = BZR_REVDATE;
766+this->revid = BZR_REVID;
767+this->branchnick = BZR_BRANCHNICK;
768 }
769
770
771
772=== modified file 'version.h'
773--- version.h 2008-11-25 12:26:40 +0000
774+++ version.h 2010-03-17 22:36:38 +0000
775@@ -1,22 +1,32 @@
776-// $Id$
777 #ifndef VERSION_H
778 #define VERSION_H
779
780
781-#include "svnrev.h"
782+#include "bzrrev.h"
783 #include <string>
784
785-
786+/*! \brief PTools version class
787+*
788+* This simple class is used to define unique
789+* revision numbers, now relying on bazaar.
790+* This unique number can be used to know exactly
791+* which version of the library was used to perform
792+* a simulation.
793+*/
794 struct Version
795 {
796
797-int revnb;
798-std::string revstr;
799-std::string revdate;
800-std::string revstamp;
801-
802-
803-Version(); //default constructor
804+//public attributes
805+public:
806+ int revnb;
807+ std::string revstr;
808+ std::string revdate;
809+ std::string revid;
810+ std::string branchnick;
811+
812+//public methods
813+public:
814+ Version(); //default constructor
815
816 };
817

Subscribers

People subscribed via source and target branches

to all changes: