49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
** not overwritten. Edits are merged into the new version.
**
*/
void update_cmd(void){
int vid; /* Current version */
int tid; /* Target version - version we are changing to */
Stmt q;
if( g.argc!=3 && g.argc!=2 ){
usage("?VERSION?");
}
db_must_be_within_tree();
vid = db_lget_int("checkout", 0);
if( vid==0 ){
vid = 1;
}
if( db_exists("SELECT 1 FROM vmerge") ){
fossil_fatal("cannot update an uncommitted merge");
}
if( g.argc==3 ){
tid = name_to_rid(g.argv[2]);
if( tid==0 ){
fossil_fatal("not a version: %s", g.argv[2]);
}
if( !is_a_version(tid) ){
fossil_fatal("not a version: %s", g.argv[2]);
}
}else{
compute_leaves(vid);
if( db_int(0, "SELECT count(*) FROM leaves")>1 ){
db_prepare(&q,
"%s "
" AND event.objid IN leaves"
" ORDER BY event.mtime DESC",
timeline_query_for_tty()
);
print_timeline(&q, 100);
db_finalize(&q);
fossil_fatal("Multiple descendents");
}
tid = db_int(0, "SELECT rid FROM leaves");
}
db_begin_transaction();
vfile_check_signature(vid);
undo_begin();
load_vfile_from_rid(tid);
|
>
>
|
|
|
>
>
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
** not overwritten. Edits are merged into the new version.
**
*/
void update_cmd(void){
int vid; /* Current version */
int tid; /* Target version - version we are changing to */
Stmt q;
int latestFlag; /* Pick the latest version if true */
latestFlag = find_option("latest",0, 0)!=0;
if( g.argc!=3 && g.argc!=2 ){
usage("?VERSION?");
}
db_must_be_within_tree();
vid = db_lget_int("checkout", 0);
if( vid==0 ){
fossil_fatal("cannot find current version");
}
if( db_exists("SELECT 1 FROM vmerge") ){
fossil_fatal("cannot update an uncommitted merge");
}
if( g.argc==3 ){
tid = name_to_rid(g.argv[2]);
if( tid==0 ){
fossil_fatal("not a version: %s", g.argv[2]);
}
if( !is_a_version(tid) ){
fossil_fatal("not a version: %s", g.argv[2]);
}
}else{
compute_leaves(vid);
if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
db_prepare(&q,
"%s "
" AND event.objid IN leaves"
" ORDER BY event.mtime DESC",
timeline_query_for_tty()
);
print_timeline(&q, 100);
db_finalize(&q);
fossil_fatal("Multiple descendents");
}
tid = db_int(0, "SELECT rid FROM leaves, event"
" WHERE event.objid=leaves.rid"
" ORDER BY event.mtime DESC");
}
db_begin_transaction();
vfile_check_signature(vid);
undo_begin();
load_vfile_from_rid(tid);
|