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 "vocab.hh"
12
13#include <string>
14#include <vector>
15#include <iostream>
16
17struct conflict {};
18
19// this file is to contain some stripped down, in-process implementations
20// of GNU-diffutils-like things (diff, diff3, maybe patch..)
21
22bool guess_binary(std::string const & s);
23
24enum diff_type
25{
26 unified_diff,
27 context_diff
28};
29
30void make_diff(std::string const & filename1,
31 std::string const & filename2,
32 std::vector<std::string> const & lines1,
33 std::vector<std::string> const & lines2,
34 std::ostream & ost,
35 diff_type type);
36
37bool merge3(std::vector<std::string> const & ancestor,
38 std::vector<std::string> const & left,
39 std::vector<std::string> const & right,
40 std::vector<std::string> & merged);
41
42struct merge_provider
43{
44 app_state & app;
45 manifest_map const & anc_man;
46 manifest_map const & left_man;
47 manifest_map const & right_man;
48 merge_provider(app_state & app,
49 manifest_map const & anc_man,
50 manifest_map const & left_man,
51 manifest_map const & right_man);
52
53 // merge3 on a file (line by line)
54 virtual bool try_to_merge_files(file_path const & anc_path,
55 file_path const & left_path,
56 file_path const & right_path,
57 file_path const & merged_path,
58 file_id const & ancestor_id,
59 file_id const & left_id,
60 file_id const & right,
61 file_id & merged_id);
62
63 // merge2 on a file (line by line)
64 virtual bool try_to_merge_files(file_path const & left_path,
65 file_path const & right_path,
66 file_path const & merged_path,
67 file_id const & left_id,
68 file_id const & right_id,
69 file_id & merged);
70
71 virtual void record_merge(file_id const & left_ident,
72 file_id const & right_ident,
73 file_id const & merged_ident,
74 file_data const & left_data,
75 file_data const & merged_data);
76
77 virtual void get_version(file_path const & path,
78 file_id const & ident,
79 file_data & dat);
80
81 virtual std::string get_file_encoding(file_path const & path,
82manifest_map const & man);
83
84 virtual ~merge_provider() {}
85};
86
87struct update_merge_provider : public merge_provider
88{
89 std::map<file_id, file_data> temporary_store;
90 update_merge_provider(app_state & app,
91manifest_map const & anc_man,
92manifest_map const & left_man,
93manifest_map const & right_man);
94
95 virtual void record_merge(file_id const & left_ident,
96 file_id const & right_ident,
97 file_id const & merged_ident,
98 file_data const & left_data,
99 file_data const & merged_data);
100
101 virtual void get_version(file_path const & path,
102 file_id const & ident,
103 file_data & dat);
104
105 virtual std::string get_file_encoding(file_path const & path,
106manifest_map const & man);
107
108 virtual ~update_merge_provider() {}
109};
110
111
112#endif // __DIFF_PATCH_HH__

Archive Download this file

Branches

Tags

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