monotone

monotone Mtn Source Tree

Root/diff_patch.hh

1#ifndef __DIFF_PATCH_HH__
2#define __DIFF_PATCH_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 "app_state.hh"
10#include "cert.hh"
11#include "manifest.hh"
12#include "vocab.hh"
13
14#include <string>
15#include <vector>
16#include <iostream>
17
18// this file is to contain some stripped down, in-process implementations
19// of GNU-diffutils-like things (diff, diff3, maybe patch..)
20
21bool guess_binary(std::string const & s);
22
23void unidiff(std::string const & filename1,
24 std::string const & filename2,
25 std::vector<std::string> const & lines1,
26 std::vector<std::string> const & lines2,
27 std::ostream & ost);
28
29bool merge3(std::vector<std::string> const & ancestor,
30 std::vector<std::string> const & left,
31 std::vector<std::string> const & right,
32 std::vector<std::string> & merged);
33
34
35
36struct path_id_pair;
37
38// you pass one of these in to the next function, to give it a callback
39// strategy for merging individual elements in a manifest.
40
41struct file_merge_provider
42{
43 // merge3 on a file (line by line)
44 virtual bool try_to_merge_files(path_id_pair const & ancestor,
45 path_id_pair const & left,
46 path_id_pair const & right,
47 path_id_pair & merged) = 0;
48
49 // merge2 on a file (line by line)
50 virtual bool try_to_merge_files(path_id_pair const & left,
51 path_id_pair const & right,
52 path_id_pair & merged) = 0;
53};
54
55struct simple_merge_provider : public file_merge_provider
56{
57 app_state & app;
58 simple_merge_provider(app_state & app);
59 virtual bool try_to_merge_files(path_id_pair const & ancestor,
60 path_id_pair const & left,
61 path_id_pair const & right,
62 path_id_pair & merged);
63 virtual bool try_to_merge_files(path_id_pair const & left,
64 path_id_pair const & right,
65 path_id_pair & merged);
66 virtual void record_merge(file_id const & left_ident,
67 file_id const & right_ident,
68 file_id const & merged_ident,
69 file_data const & left_data,
70 file_data const & merged_data);
71 virtual void get_version(path_id_pair const & pip, file_data & dat);
72
73};
74
75struct update_merge_provider : public simple_merge_provider
76{
77 std::map<file_id, file_data> temporary_store;
78 update_merge_provider(app_state & app);
79 virtual void record_merge(file_id const & left_ident,
80 file_id const & right_ident,
81 file_id const & merged_ident,
82 file_data const & left_data,
83 file_data const & merged_data);
84 virtual void get_version(path_id_pair const & pip, file_data & dat);
85 virtual ~update_merge_provider() {}
86};
87
88// this does a set-theoretic merge3 on the manifests
89
90bool merge3(manifest_map const & ancestor,
91 manifest_map const & left,
92 manifest_map const & right,
93 app_state & app,
94 file_merge_provider & file_merger,
95 manifest_map & merged,
96 rename_set & left_renames,
97 rename_set & right_renames);
98
99// ditto but the weaker merge2
100
101bool merge2(manifest_map const & left,
102 manifest_map const & right,
103 app_state & app,
104 file_merge_provider & file_merger,
105 manifest_map & merged);
106
107
108#endif // __DIFF_PATCH_HH__

Archive Download this file

Branches

Tags

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