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 "vocab.hh"
14#include "manifest.hh"
15
16//
17// this file defines structures to deal with the "working copy" of a tree
18//
19
20//
21// working copy book-keeping files are stored in a directory called MT, off
22// the root of the working copy source tree (analogous to the CVS or SVN
23// directories). there is no hierarchy of MT directories; only one exists,
24// and it is always at the root. it contains the following files:
25//
26// MT/manifest -- the check-out manifest, as defined in manifest.hh
27// MT/work -- (optional) a set of added, deleted or moved pathnames
28//
29// as work proceeds, the files in the working directory either change their
30// sha1 fingerprints from those listed in the manifest file, or else are
31// added or deleted (and the paths of those changes recorded in 'MT/work').
32//
33// when it comes time to commit, the change set is calculated by building a
34// path set from the old manifest, deleting old path elements, adding new
35// path elements, calculating the sha1 of each entry in the resulting path
36// set, and calculating a manifest delta (see manifest.hh) between the
37// check-out manifest and the new one.
38//
39// this is *completely decoupled* from the issue of importing appropriate
40// versions of files into the database. if the files already exist in the db,
41// there is no reason to import them anew.
42//
43
44typedef std::set<file_path> path_set;
45typedef std::map<file_path,file_path> rename_set;
46
47extern std::string const work_file_name;
48
49struct work_set
50{
51 // imprecise, uncommitted work record
52 path_set adds;
53 path_set dels;
54 rename_set renames;
55};
56
57void read_work_set(data const & dat,
58 work_set & work);
59
60void write_work_set(data & dat,
61 work_set const & work);
62
63void extract_path_set(manifest_map const & man,
64 path_set & paths);
65
66void apply_work_set(work_set const & work,
67 path_set & paths);
68
69void build_addition(file_path const & path,
70 app_state & app,
71 work_set & work,
72 manifest_map & man,
73 bool & rewrite_work);
74
75void build_deletion(file_path const & path,
76 app_state & app,
77 work_set & work,
78 manifest_map & man,
79 bool & rewrite_work);
80
81void build_rename(file_path const & src,
82 file_path const & dst,
83 app_state & app,
84 work_set & work,
85 manifest_map & man,
86 bool & rewrite_work);
87
88
89// the "options map" is another administrative file, stored in
90// MT/options. it keeps a list of name/value pairs which are considered
91// "persistent options", associated with a particular the working copy and
92// implied unless overridden on the command line. the main ones are
93// --branch and --db, although some others may follow in the future.
94
95typedef std::map<std::string, utf8> options_map;
96
97void get_options_path(local_path & o_path);
98
99void read_options_map(data const & dat, options_map & options);
100
101void write_options_map(data & dat,
102 options_map const & options);
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<std::pair<file_path, 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
129
130#endif // __WORK_HH__

Archive Download this file

Branches

Tags

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