monotone

monotone Mtn Source Tree

Root/diff_patch.hh

1#ifndef __DIFF_PATCH_HH__
2#define __DIFF_PATCH_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13#include "vocab.hh"
14#include "roster.hh"
15
16#include <boost/shared_ptr.hpp>
17
18#include <map>
19#include <vector>
20
21class app_state;
22
23struct conflict {};
24
25// this file is to contain some stripped down, in-process implementations
26// of GNU-diffutils-like things (diff, diff3, maybe patch..)
27
28void make_diff(std::string const & filename1,
29 std::string const & filename2,
30 file_id const & id1,
31 file_id const & id2,
32 data const & data1,
33 data const & data2,
34 std::ostream & ost,
35 diff_type type,
36 std::string const & pattern);
37
38bool merge3(std::vector<std::string> const & ancestor,
39 std::vector<std::string> const & left,
40 std::vector<std::string> const & right,
41 std::vector<std::string> & merged);
42
43struct
44content_merge_adaptor
45{
46 virtual void record_merge(file_id const & left_ident,
47 file_id const & right_ident,
48 file_id const & merged_ident,
49 file_data const & left_data,
50 file_data const & right_data,
51 file_data const & merged_data) = 0;
52
53 virtual void get_ancestral_roster(node_id nid,
54 boost::shared_ptr<roster_t const> & anc) = 0;
55
56 virtual void get_version(file_id const & ident,
57 file_data & dat) const = 0;
58
59 virtual ~content_merge_adaptor() {}
60};
61
62struct
63content_merge_database_adaptor
64 : public content_merge_adaptor
65{
66 app_state & app;
67 revision_id lca;
68 marking_map const & mm;
69 std::map<revision_id, boost::shared_ptr<roster_t const> > rosters;
70 content_merge_database_adaptor (app_state & app,
71 revision_id const & left,
72 revision_id const & right,
73 marking_map const & mm);
74 void record_merge(file_id const & left_ident,
75 file_id const & right_ident,
76 file_id const & merged_ident,
77 file_data const & left_data,
78 file_data const & right_data,
79 file_data const & merged_data);
80
81 void get_ancestral_roster(node_id nid,
82 boost::shared_ptr<roster_t const> & anc);
83
84 void get_version(file_id const & ident,
85 file_data & dat) const;
86};
87
88struct
89content_merge_workspace_adaptor
90 : public content_merge_adaptor
91{
92 std::map<file_id, file_data> temporary_store;
93 app_state & app;
94 boost::shared_ptr<roster_t const> base;
95 std::map<file_id, file_path> content_paths;
96 content_merge_workspace_adaptor (app_state & app,
97 boost::shared_ptr<roster_t const> base,
98 std::map<file_id, file_path> const & paths)
99 : app(app), base(base), content_paths(paths)
100 {}
101 void record_merge(file_id const & left_ident,
102 file_id const & right_ident,
103 file_id const & merged_ident,
104 file_data const & left_data,
105 file_data const & right_data,
106 file_data const & merged_data);
107
108 void get_ancestral_roster(node_id nid,
109 boost::shared_ptr<roster_t const> & anc);
110
111 void get_version(file_id const & ident,
112 file_data & dat) const;
113};
114
115struct content_merger
116{
117 app_state & app;
118 roster_t const & anc_ros;
119 roster_t const & left_ros;
120 roster_t const & right_ros;
121
122 content_merge_adaptor & adaptor;
123
124 content_merger(app_state & app,
125 roster_t const & anc_ros,
126 roster_t const & left_ros,
127 roster_t const & right_ros,
128 content_merge_adaptor & adaptor);
129
130 // merge3 on a file (line by line)
131 bool try_to_merge_files(file_path const & anc_path,
132 file_path const & left_path,
133 file_path const & right_path,
134 file_path const & merged_path,
135 file_id const & ancestor_id,
136 file_id const & left_id,
137 file_id const & right,
138 file_id & merged_id);
139
140 std::string get_file_encoding(file_path const & path,
141 roster_t const & ros);
142
143 bool attribute_manual_merge(file_path const & path,
144 roster_t const & ros);
145};
146
147// Local Variables:
148// mode: C++
149// fill-column: 76
150// c-file-style: "gnu"
151// indent-tabs-mode: nil
152// End:
153// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
154
155#endif // __DIFF_PATCH_HH__

Archive Download this file

Branches

Tags

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