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//
33// as work proceeds, the files in the working directory either change their
34// sha1 fingerprints from those listed in the revision's manifest, or else are
35// added or deleted or renamed (and the paths of those changes recorded in
36// 'MT/work').
37//
38// when it comes time to commit, the change_set is calculated by applying
39// the path_rearrangement to the manifest and then calculating the
40// delta_set between the modified manifest and the files in the working
41// copy.
42//
43
44typedef std::set<file_path> path_set;
45
46extern std::string const work_file_name;
47
48void extract_path_set(manifest_map const & man,
49 path_set & paths);
50
51void
52build_additions(std::vector<file_path> const & args,
53 manifest_map const & m_old,
54 app_state & app,
55 change_set::path_rearrangement & pr);
56
57void
58build_deletions(std::vector<file_path> const & args,
59 manifest_map const & m_old,
60 app_state & app,
61 change_set::path_rearrangement & pr);
62
63void
64build_rename(file_path const & src,
65 file_path const & dst,
66 manifest_map const & m_old,
67 change_set::path_rearrangement & pr);
68
69
70// the "user log" is a file the user can edit as they program to record
71// changes they make to their source code. Upon commit the file is read
72// and passed to the edit_comment lua hook. If the commit is a success,
73// the user log is then blanked. If the commit does not succeed, no
74// change is made to the user log file.
75
76void get_user_log_path(local_path & ul_path);
77
78void read_user_log(data & dat);
79
80void blank_user_log();
81
82bool has_contents_user_log();
83
84// the "options map" is another administrative file, stored in
85// MT/options. it keeps a list of name/value pairs which are considered
86// "persistent options", associated with a particular the working copy and
87// implied unless overridden on the command line. the main ones are
88// --branch and --db, although some others may follow in the future.
89
90typedef std::map<std::string, utf8> options_map;
91
92void get_options_path(local_path & o_path);
93
94void read_options_map(data const & dat, options_map & options);
95
96void write_options_map(data & dat,
97 options_map const & options);
98
99// the "local dump file' is a debugging file, stored in MT/debug. if we
100// crash, we save some debugging information here.
101
102void get_local_dump_path(local_path & d_path);
103
104// the "attribute map" is part of a working copy. it is *not* stored in MT,
105// because its contents are considered part of the "content" of a tree of
106// files. it is therefore stored in .mt-attrs, in the root of your
107// tree. you do not need a .mt-attrs file, it's just an extension
108// mechanism.
109//
110// the contents of the .mt-attrs file is a list of [file, name, value]
111// triples, each of which assigns a particular "extended attribute" to a
112// file in your manifest. example "extended attributes" are things like
113// "set the execute bit" or "this file is read-only" or whatnot. they are
114// intrinsic properties of the files, but not actually part of the file's
115// data stream. so they're kept here.
116
117typedef std::map<file_path, std::map<std::string, std::string> > attr_map;
118
119void get_attr_path(file_path & a_path);
120
121void read_attr_map(data const & dat, attr_map & attrs);
122
123void write_attr_map(data & dat,
124 attr_map const & options);
125
126void apply_attributes(app_state & app,
127 attr_map const & attr);
128
129extern std::string const encoding_attribute;
130
131bool get_attribute_from_db(file_path const & file,
132 std::string const & attr_key,
133 manifest_map const & man,
134 std::string & attr_val,
135 app_state & app);
136
137bool get_attribute_from_working_copy(file_path const & file,
138 std::string const & attr_key,
139 std::string & attr_val);
140
141extern std::string const binary_encoding;
142extern std::string const default_encoding;
143
144#endif // __WORK_HH__

Archive Download this file

Branches

Tags

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