Commit ed3b0977 authored by Claes Sjofors's avatar Claes Sjofors

Wb revision, pwg-files added auatomatically, and doc

parent 1b1e0251
......@@ -8463,23 +8463,77 @@ the same development environment. A project points at a Proview base, e.g. V3.4,
when creating a project you have to choose which base the project should point at.
<h2>Path
The project consists of a directory tree where databases, source files, archives etc are stored.
The path is the root directory of this tree.
The project consists of a directory tree where databases, source files, archives etc are
stored. The path is the root directory of this tree.
</topic>
</chapter>
<chapter>
<topic> revisions
Revisions
<h1>Revisions window
Revisions are handled from the Revisions window. It's opened from the menu in the configurator,
File/Revisions.
A revision is a state in the development environment that is stored in a version control
system. The revision should include all source files to make it possible to restore a revision.
A revision can be used to review the state when the revision was created, and also to build
runable systems from the restored source to test or run aa restore revision in production.
The currently supported version control system is Git. A new repository will be created on
$pwrp_root/src when the first revision is created.
<h1>Revision window
Revisions are handled from the Revision window that is opened from the File menu in the
configurator.
<h1>Create a revision
A new revision is created from Functions/New Revison in the menu. New revisions can only be
created if the currently checkedout revision is the end point of a branch.
<image>dg_fig124.png
<b>Fig Create a new revision
<h1>Restore a revision
A revision is restored from Functions/Restore in the menu. Select the revision to restore
first.
<image>dg_fig125.png
<b>Fig Restore a revision
When a revision is restored the checked out revision is marked with a radio button in the list.
Also in the configurator title bar, the current revision is written.
<image>dg_fig126.png
<b>Fig An old revision is restored
<h1>Create a branch
If on old revision in the main line is restored, a branch can be created by creating a new
revision from this point. In the figure above, a branch has be created from revision V2.0.1.
New revisions can also be created from the end point of the branch. In the figure above, a
new revision can be created from V2.0.1-2 that is an end point, but not from V2.0.1-1.
<h1>New files
New files, e.g. c-applications, are not automatically added to the git repository.
This has to be done manually. New files are displayed by Git as untracked files in the
'git status' command. Untracked files can be added with the 'git add' command and will then
be included in the next revision.
Note! It's important to add new files to be able to restore a complete revision.
<b>Example
<c>> git status
<c>On branch B_V2.0.5
<c>Untracked files:
<c> (use "git add <file>..." to include in what will be committed)
<c> appl/ra_appl.c
<c>> git add appl/ra_appl.c
</topic>
</chapter>
<chapter>
<topic> dg_tools
Verktyg
Tools
pwrc <t>Command interface to development database. <link> dg_pwrc
wb_ge <t>Ge editor <link> wb_ge
......
......@@ -8352,6 +8352,68 @@ Path
</topic>
</chapter>
<chapter>
<topic> revisions
Revisioner
En revision är ett tillstånd i utvecklingsmiljön som lagras i ett versionskontrollsystem.
Revisionen ska innehålla alla källkodsfiler så att det är möjligt att återskapa en revision.
En revision kan användas för att visa det tillstånd som rådde när revisionen skapades, men
också för att bygga körbara system från den återskapade koden för test eller för att köra
revisionen in produktion.
Det versionskontrollsystem som supportas för närvarande är Git. Ett nytt repository skapas
på katalogen $pwrp_root/src när det första revisionen skapas.
<h1>Revisionsfönstret
Revisioner hanteras från revisionsfönstret som öppnas från File menyn i konfiguratorn.
<h1>Skapa en revision
En ny revision skapas från Functions/New Revision i menyn. Nya revisioner kan endast skapas
om den utcheckade revisionen är en ändpunkt på en gren.
<image>dg_fig124.png
<b>Fig Skapa en ny revision
<h1>Återskapa en revision
En revision återskapas från Functions/Restore i menyn. Välj ut den revision som ska återskapas
först.
<image>dg_fig125.png
<b>Fig Återskapa en revision
Utcheckad revision markeras med en radioknapp i listan. Även i konfiguratorns titel anges
den utcheckade revisionen.
<image>dg_fig126.png
<b>Fig En revision återskapas
<h1>Skapa en gren
Om en gammal revision i huvudlinjen återskapas, kan en gren skapas genom att skapa en ny
revision från denna punkt. I figuren ovan har en gren skapats från revision V2.0.1. Nya
revisioner kan även skapas från ändpunkter av grenar. I figuren ovan, kan en ny revision
skapas frän V2.0.1-2, som är en ändpunkt, men inte från V2.0.1-1.
<h1>Nya filer
Nya filer, t ex c-applikationer, adderas inte automatiskt till git-repositoryt. Detta måste
göras manuellt. Nya filer visas av Git som 'untracked files' med 'git status' kommandot.
Untracked files kan adderas med 'git add' kommandot och kommer sedan att inkluderas i
nästa revision.
OBS! Det är viktigt att addera nya filer för att kunna återskapa en komplett revision.
<b>Exampel
<c>> git status
<c>On branch B_V2.0.5
<c>Untracked files:
<c> (use "git add <file>..." to include in what will be committed)
<c> appl/ra_appl.c
<c>> git add appl/ra_appl.c
</topic>
</chapter>
<chapter>
<topic> dg_tools
Verktyg
......
......@@ -54,6 +54,7 @@
#include "wb_merep.h"
#include "wb_log.h"
#include "wb_dblock.h"
#include "wb_revision.h"
#include "glow.h"
#include "glow_growctx.h"
......@@ -1073,6 +1074,8 @@ void wb_build::xttgraph( pwr_tOid oid)
strcpy( name, action);
if (( s = strrchr( name, '.')))
*s = 0;
wb_revision::check_add_file( src_fname);
wb_log::log( wlog_eCategory_GeBuild, name, 0);
m_sts = PWRB__SUCCESS;
}
......@@ -1328,6 +1331,8 @@ void wb_build::webgraph( pwr_tOid oid)
strcpy( name, graph_name);
if (( s = strrchr( name, '.')))
*s = 0;
wb_revision::check_add_file( src_fname);
wb_log::log( wlog_eCategory_GeBuild, name, 0);
m_sts = PWRB__SUCCESS;
}
......@@ -1418,6 +1423,7 @@ void wb_build::appgraph( pwr_tOid oid)
strcpy( name, graph_name);
if (( s = strrchr( name, '.')))
*s = 0;
wb_revision::check_add_file( src_fname);
wb_log::log( wlog_eCategory_GeBuild, name, 0);
m_sts = PWRB__SUCCESS;
}
......
......@@ -53,8 +53,6 @@ wb_revision::wb_revision( void *parent_ctx, wb_session *ses):
{
char current[80];
m_manager = new wb_version_manager_git();
read_file();
switch ( m_manager_enum) {
......@@ -97,6 +95,20 @@ wb_revision::wb_revision( void *parent_ctx, wb_session *ses):
}
}
wb_revision::wb_revision():
m_parent_ctx(0), m_session(0), m_manager(0), m_manager_enum(pwr_eVersionManagerEnum_None),
m_read(false), m_current_idx(-1), m_current_main_idx(-1), m_current_sub_idx(-1), m_command_cb(0)
{
read_file_meta();
switch ( m_manager_enum) {
case pwr_eVersionManagerEnum_Git:
m_manager = new wb_version_manager_git();
break;
default: ;
}
}
char *wb_revision::branch_name( char *name)
{
static char bname[80];
......@@ -541,6 +553,40 @@ void wb_revision::read_file()
m_read = true;
}
void wb_revision::read_file_meta()
{
pwr_tFileName fname;
char line[200];
char item_array[6][80];
dcli_translate_filename( fname, "$pwrp_db/pwrp_cnf_revision.dat");
ifstream fp( fname, ios::in);
if ( !fp) {
m_read = true;
return;
}
while ( fp.getline( line, sizeof(line))) {
wb_rev_item item;
int nr;
nr = dcli_parse( line, " ", "", (char *)item_array,
sizeof(item_array)/sizeof(item_array[0]),
sizeof(item_array[0]), 0);
if ( nr == 3 && strcmp( item_array[0], "#!") == 0 && strcmp( item_array[1], "RevisionManager") == 0) {
if ( strcmp( item_array[2], "1") == 0)
m_manager_enum = pwr_eVersionManagerEnum_Git;
else
m_manager_enum = pwr_eVersionManagerEnum_None;
continue;
}
if ( strcmp( item_array[0], "#!") != 0)
break;
}
fp.close();
}
void wb_revision::write_file()
{
pwr_tFileName fname;
......@@ -713,6 +759,14 @@ void wb_revision::next_name( char *name)
strcpy( name, "");
}
int wb_revision::check_add_file( char *filename)
{
wb_revision rev;
if ( rev.m_manager)
return rev.m_manager->check_add( filename);
return 0;
}
void wb_version_manager_git::init()
{
pwr_tFileName fname;
......@@ -925,3 +979,59 @@ int wb_version_manager_git::check( vector<wb_rev_item>& v)
return REV__SUCCESS;
}
int wb_version_manager_git::check_add( char *filename)
{
pwr_tCmd cmd;
pwr_tFileName fname, f2name;
char *s, *s1 = 0;
pwr_tFileName rname = "$pwrp_tmp/gitresult.tmp";
char line[200];
int sts;
dcli_translate_filename( rname, rname);
dcli_translate_filename( f2name, filename);
int cnt = 0;
bool found = false;
for ( s = &f2name[strlen(f2name)-1]; s != f2name; s--) {
if ( *s == '/') {
cnt++;
if ( cnt == 2) {
strncpy( fname, s + 1, sizeof(fname));
found = true;
break;
}
else
s1 = s;
}
}
if ( !found && s1)
strncpy( fname, s1 + 1, sizeof(fname));
else if ( !found)
strncpy( fname, filename, sizeof(fname));
sprintf( cmd, "cd $pwrp_root/src; git ls-files -o --exclude-standard | grep %s$ > %s", fname, rname);
sts = system( cmd);
if ( sts != 0)
return 0;
ifstream fp( rname);
fp.getline( line, sizeof(line));
fp.close();
dcli_trim( line, line);
if ( strcmp( line, "") == 0)
return 0;
sprintf( cmd, "cd $pwrp_root/src; git add %s", line);
sts = system( cmd);
if ( sts != 0)
printf( "** Git error %d\n", sts);
sprintf( cmd, "rm -f %s", rname);
system( cmd);
return 1;
}
......@@ -85,7 +85,7 @@ class wb_version_manager
virtual int restore_revision( char *name, char *branch, int checkout_master, int checkout_branch) { return 0;}
virtual int get_current( char *name) { return 0;}
virtual int check( vector<wb_rev_item>& v) { return 0;}
virtual int check_add( char *filename) { return 0;}
};
class wb_version_manager_git : public wb_version_manager
......@@ -98,6 +98,7 @@ class wb_version_manager_git : public wb_version_manager
int restore_revision( char *name, char *branch, int checkout_master, int checkout_branch);
int get_current( char *name);
int check( vector<wb_rev_item>& v);
int check_add( char *filename);
};
class wb_revision : public wb_status
......@@ -115,6 +116,7 @@ class wb_revision : public wb_status
int (*m_command_cb)( void *ctx, char *cmd);
public:
wb_revision();
wb_revision( void *parent_ctx, wb_session *ses);
~wb_revision() {
if ( m_manager)
......@@ -126,6 +128,7 @@ class wb_revision : public wb_status
pwr_tStatus build_all();
pwr_tStatus remove( char *name);
void read_file();
void read_file_meta();
void write_file();
int add( char *name, char *description, char *version, pwr_tTime *date, bool in_main, int sub_idx);
void list();
......@@ -142,6 +145,7 @@ class wb_revision : public wb_status
static char *branch_name( char *name);
static void info( wb_rev_info *info);
static int check_add_file( char *filename);
};
#endif
......
......@@ -79,7 +79,7 @@
#include "wb_wnav_selformat.h"
#include "wb_nav.h"
#include "wb_log.h"
#include "wb_revision.h"
void Ge::set_title()
{
......@@ -1205,6 +1205,7 @@ void Ge::activate_build()
{
char name[40];
pwr_tCmd cmd;
pwr_tFileName fname;
graph->get_name( name);
if ( strcmp( name, "") == 0 || graph->is_modified()) {
......@@ -1215,6 +1216,9 @@ void Ge::activate_build()
sprintf( cmd, "cp -a $pwrp_pop/%s.pwg $pwrp_exe/", name);
system( cmd);
sprintf( fname, "$pwrp_pop/%s.pwg", name);
wb_revision::check_add_file( fname);
message( 'I', "Graph built");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment