monotone

monotone Mtn Source Tree

Root/work.hh

1#ifndef __WORK_HH__
2#define __WORK_HH__
3
4// copyright (C) 2002, 2003 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 <string>
10#include <set>
11#include <map>
12
13#include "change_set.hh"
14#include "manifest.hh"
15#include "vocab.hh"
16
17//
18// this file defines structures to deal with the "working copy" of a tree
19//
20
21//
22// working copy book-keeping files are stored in a directory called MT, off
23// the root of the working copy source tree (analogous to the CVS or .svn
24// directories). there is no hierarchy of MT directories; only one exists,
25// and it is always at the root. it contains the following files:
26//
27// MT/revision -- contains the id of the checked out revision
28// MT/work -- (optional) a set of added, deleted or moved pathnames
29// this file is, syntactically, a path_rearrangement
30// MT/options -- the database, branch and key options currently in use
31// MT/log -- user edited log file
32// MT/inodeprints -- file fingerprint cache, presence turns on "reckless"
33// mode
34//
35// as work proceeds, the files in the working directory either change their
36// sha1 fingerprints from those listed in the revision's manifest, or else are
37// added or deleted or renamed (and the paths of those changes recorded in
38// 'MT/work').
39//
40// when it comes time to commit, the change_set is calculated by applying
41// the path_rearrangement to the manifest and then calculating the
42// delta_set between the modified manifest and the files in the working
43// copy.
44//
45// MT/inodes, if present, can be used to speed up this last step.
46
47typedef std::set<file_path> path_set;
48
49struct file_itemizer : public tree_walker
50{
51 app_state & app;
52 path_set & known;
53 path_set & unknown;
54 path_set & ignored;
55 file_itemizer(app_state & a, path_set & k, path_set & u, path_set & i)
56 : app(a), known(k), unknown(u), ignored(i) {}
57 virtual void file_itemizer::visit_file(file_path const & path);
58};
59
60void
61build_additions(std::vector<file_path> const & args,
62 manifest_map const & m_old,
63 app_state & app,
64 change_set::path_rearrangement & pr);
65
66void
67build_deletions(std::vector<file_path> const & args,
68 manifest_map const & m_old,
69 app_state & app,
70 change_set::path_rearrangement & pr);
71
72void
73build_rename(file_path const & src,
74 file_path const & dst,
75 manifest_map const & m_old,
76 change_set::path_rearrangement & pr);
77
78
79// the "work" file contains the current path rearrangement representing
80// uncommitted add/drop/rename operations in the serialized change set format
81
82void get_path_rearrangement(change_set::path_rearrangement & w);
83void remove_path_rearrangement();
84void put_path_rearrangement(change_set::path_rearrangement & w);
85
86// the "revision" file contains the base revision id that the current working
87// copy was checked out from
88
89void get_revision_id(revision_id & c);
90void put_revision_id(revision_id const & rev);
91void get_base_revision(app_state & app,
92 revision_id & rid,
93 manifest_id & mid,
94 manifest_map & man);
95void get_base_manifest(app_state & app, manifest_map & man);
96
97// the "user log" is a file the user can edit as they program to record
98// changes they make to their source code. Upon commit the file is read
99// and passed to the edit_comment lua hook. If the commit is a success,
100// the user log is then blanked. If the commit does not succeed, no
101// change is made to the user log file.
102
103void get_user_log_path(local_path & ul_path);
104
105void read_user_log(data & dat);
106
107void blank_user_log();
108
109bool has_contents_user_log();
110
111// the "options map" is another administrative file, stored in
112// MT/options. it keeps a list of name/value pairs which are considered
113// "persistent options", associated with a particular the working copy and
114// implied unless overridden on the command line. the main ones are
115// --branch and --db, although some others may follow in the future.
116
117typedef std::map<std::string, utf8> options_map;
118
119void get_options_path(local_path & o_path);
120
121void read_options_map(data const & dat, options_map & options);
122
123void write_options_map(data & dat,
124 options_map const & options);
125
126// the "local dump file' is a debugging file, stored in MT/debug. if we
127// crash, we save some debugging information here.
128
129void get_local_dump_path(local_path & d_path);
130
131// the 'inodeprints file' contains inode fingerprints
132
133void get_inodeprints_path(local_path & ip_path);
134
135bool in_inodeprints_mode();
136
137void read_inodeprints(data & dat);
138
139void write_inodeprints(data const & dat);
140
141void enable_inodeprints();
142
143// the "attribute map" is part of a working copy. it is *not* stored in MT,
144// because its contents are considered part of the "content" of a tree of
145// files. it is therefore stored in .mt-attrs, in the root of your
146// tree. you do not need a .mt-attrs file, it's just an extension
147// mechanism.
148//
149// the contents of the .mt-attrs file is a list of [file, name, value]
150// triples, each of which assigns a particular "extended attribute" to a
151// file in your manifest. example "extended attributes" are things like
152// "set the execute bit" or "this file is read-only" or whatnot. they are
153// intrinsic properties of the files, but not actually part of the file's
154// data stream. so they're kept here.
155
156typedef std::map<file_path, std::map<std::string, std::string> > attr_map;
157
158void get_attr_path(file_path & a_path);
159
160void read_attr_map(data const & dat, attr_map & attrs);
161
162void write_attr_map(data & dat,
163 attr_map const & options);
164
165extern std::string const encoding_attribute;
166
167bool get_attribute_from_db(file_path const & file,
168 std::string const & attr_key,
169 manifest_map const & man,
170 std::string & attr_val,
171 app_state & app);
172
173bool get_attribute_from_working_copy(file_path const & file,
174 std::string const & attr_key,
175 std::string & attr_val);
176
177void update_any_attrs(app_state & app);
178
179extern std::string const binary_encoding;
180extern std::string const default_encoding;
181
182#endif // __WORK_HH__

Archive Download this file

Branches

Tags

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