monotone

monotone Mtn Source Tree

Root/revision.hh

1#ifndef __REVISION_HH__
2#define __REVISION_HH__
3
4// copyright (C) 2004 graydon hoare <graydon@pobox.com>
5// all rights reserved.
6// licensed to the public under the terms of the GNU GPL (>= 2)
7// see the file COPYING for details
8
9#include <set>
10#include <string>
11
12#include <boost/shared_ptr.hpp>
13
14#include "app_state.hh"
15#include "change_set.hh"
16#include "vocab.hh"
17
18// a revision is a text object. It has a precise, normalizable serial form
19// as UTF-8 text. it also has some sub-components. not all of these
20// sub-components are separately serialized (they could be but there is no
21// call for it). a grammar (aside from the parsing code) for the serialized
22// form will show up here eventually. until then, here is an example.
23// form will show up here eventually. until then, here is an example.
24//
25// new_manifest [16afa28e8783987223993d67f54700f0ecfedfaa]
26//
27// old_revision [d023242b16cbdfd46686a5d217af14e3c339f2b4]
28// old_manifest [2dc4a99e27a0026395fbd4226103614928c55c77]
29//
30// delete_file "deleted-file.cc"
31//
32// rename_file "old-file.cc"
33// to "new-file.cc"
34//
35// add_file "added-file.cc"
36//
37// patch "added-file.cc"
38// from []
39// to [da39a3ee5e6b4b0d3255bfef95601890afd80709]
40//
41// patch "changed-file.cc"
42// from [588fd8a7bcde43a46f0bde1dd1d13e9e77cf25a1]
43// to [559133b166c3154c864f912e9f9452bfc452dfdd]
44//
45// patch "new-file.cc"
46// from [95b50ede90037557fd0fbbfad6a9fdd67b0bf413]
47// to [bd39086b9da776fc22abd45734836e8afb59c8c0]
48
49typedef std::map<revision_id, std::pair<manifest_id, boost::shared_ptr<change_set> > >
50edge_map;
51
52typedef edge_map::value_type
53edge_entry;
54
55struct
56revision_set
57{
58 void check_sane() const;
59 revision_set() {}
60 revision_set(revision_set const & other);
61 revision_set const & operator=(revision_set const & other);
62 manifest_id new_manifest;
63 edge_map edges;
64};
65
66inline revision_id const &
67edge_old_revision(edge_entry const & e)
68{
69 return e.first;
70}
71
72inline revision_id const &
73edge_old_revision(edge_map::const_iterator i)
74{
75 return i->first;
76}
77
78inline manifest_id const &
79edge_old_manifest(edge_entry const & e)
80{
81 return e.second.first;
82}
83
84inline manifest_id const &
85edge_old_manifest(edge_map::const_iterator i)
86{
87 return i->second.first;
88}
89
90inline change_set const &
91edge_changes(edge_entry const & e)
92{
93 return *(e.second.second);
94}
95
96inline change_set const &
97edge_changes(edge_map::const_iterator i)
98{
99 return *(i->second.second);
100}
101
102void
103read_revision_set(data const & dat,
104 revision_set & rev);
105
106void
107read_revision_set(revision_data const & dat,
108 revision_set & rev);
109
110void
111write_revision_set(revision_set const & rev,
112 data & dat);
113
114void
115write_revision_set(revision_set const & rev,
116 revision_data & dat);
117
118// sanity checking
119
120void
121check_sane_history(revision_id const & child_id, int depth, app_state & app);
122
123// graph walking
124
125bool
126find_common_ancestor_for_merge(revision_id const & left,
127 revision_id const & right,
128 revision_id & anc,
129 app_state & app);
130
131bool
132find_least_common_ancestor(revision_id const & left,
133 revision_id const & right,
134 revision_id & anc,
135 app_state & app);
136
137bool
138is_ancestor(revision_id const & ancestor,
139 revision_id const & descendent,
140 app_state & app);
141
142void
143toposort(std::set<revision_id> const & revisions,
144 std::vector<revision_id> & sorted,
145 app_state & app);
146
147void
148erase_ancestors(std::set<revision_id> & revisions, app_state & app);
149
150void
151ancestry_difference(revision_id const & a, std::set<revision_id> const & bs,
152 std::set<revision_id> & new_stuff,
153 app_state & app);
154
155void
156calculate_composite_change_set(revision_id const & ancestor,
157 revision_id const & child,
158 app_state & app,
159 change_set & composed);
160
161void
162calculate_arbitrary_change_set(revision_id const & start,
163 revision_id const & end,
164 app_state & app,
165 change_set & composed);
166
167void
168build_changesets_from_manifest_ancestry(app_state & app);
169
170void
171build_changesets_from_existing_revs(app_state & app);
172
173// basic_io access to printers and parsers
174
175namespace basic_io { struct printer; struct parser; }
176
177void
178print_revision(basic_io::printer & printer,
179 revision_set const & rev);
180
181void
182parse_revision(basic_io::parser & parser,
183 revision_set & rev);
184
185void
186print_edge(basic_io::printer & printer,
187 edge_entry const & e);
188
189void
190parse_edge(basic_io::parser & parser,
191 edge_map & es);
192
193#endif // __REVISION_HH__

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status