monotone

monotone Mtn Source Tree

Root/manifest.hh

1#ifndef __MANIFEST_HH__
2#define __MANIFEST_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 <map>
10#include <set>
11#include <string>
12
13#include "quick_alloc.hh"
14#include "vocab.hh"
15#include "paths.hh"
16
17// this file defines the class of manifest_map objects, and various
18// comparison and i/o functions on them. a manifest_map is an unpacked
19// (analyzed) manifest_data blob. it specifies exactly which versions of
20// each file reside at which path location in a given tree. the textual
21// encoding of a manifest looks like this:
22//
23// ...
24// f2e5719b975e319c2371c98ed2c7231313fac9b5 fs/readdir.c
25// 81f0c9a0df254bc8d51bb785713a9f6d0b020b22 fs/read_write.c
26// 943851e7da46014cb07473b90d55dd5145f24de0 fs/pipe.c
27// ddc2686e000e97f670180c60a3066989e56a11a3 fs/open.c
28// 295d276e6c9ce64846d309a8e39507bcb0a14248 fs/namespace.c
29// 71e0274f16cd68bdf9a2bf5743b86fcc1e597cdc fs/namei.c
30// 1112c0f8054cebc9978aa77384e3e45c0f3b6472 fs/iobuf.c
31// 8ddcfcc568f33db6205316d072825d2e5c123275 fs/inode.c
32// ...
33//
34// which is essentially the result of running:
35//
36// 'find -type f | xargs sha1sum'
37//
38// with some minor tidying up of pathnames and sorting. manifests must
39// have only one entry for each pathname. the same sha1 can occur multiple
40// times in a manifest.
41
42typedef std::set<file_path> path_set;
43
44typedef std::pair<file_path const, file_id> manifest_entry;
45
46typedef std::map<file_path, file_id,
47 std::less<file_path>,
48 QA(manifest_entry) > manifest_map;
49
50inline file_path const &
51manifest_entry_path(manifest_entry const & e)
52{
53 return e.first;
54}
55
56inline file_path const &
57manifest_entry_path(manifest_map::const_iterator i)
58{
59 return i->first;
60}
61
62inline file_id const &
63manifest_entry_id(manifest_entry const & e)
64{
65 return e.second;
66}
67
68inline file_id const &
69manifest_entry_id(manifest_map::const_iterator i)
70{
71 return i->second;
72}
73
74std::ostream & operator<<(std::ostream & out, manifest_entry const & e);
75
76class app_state;
77
78void extract_path_set(manifest_map const & man, path_set & paths);
79
80void classify_manifest_paths(app_state & app,
81 manifest_map const & man,
82 path_set & missing,
83 path_set & changed,
84 path_set & unchanged);
85
86void build_restricted_manifest_map(path_set const & paths,
87 manifest_map const & m_old,
88 manifest_map & m_new,
89 app_state & app);
90
91void read_manifest_map(data const & dat,
92 manifest_map & man);
93
94void read_manifest_map(manifest_data const & dat,
95 manifest_map & man);
96
97void write_manifest_map(manifest_map const & man,
98 manifest_data & dat);
99
100void write_manifest_map(manifest_map const & man,
101 data & dat);
102
103void dump(manifest_map const & man, std::string & out);
104
105#endif // __MANIFEST_HH__

Archive Download this file

Branches

Tags

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