b.m.Merge3(object) : class documentation

Part of bzrlib.merge3 View In Hierarchy

3-way merge of texts.

Given BASE, OTHER, THIS, tries to produce a combined text incorporating the changes from both BASE->OTHER and BASE->THIS. All three will typically be sequences of lines.

Method __init__ Constructor.
Method merge_lines Return merge in cvs-like form.
Method merge_annotated Return merge with conflicts, showing origin of lines.
Method merge_groups Yield sequence of line groups. Each one is a tuple:
Method merge_regions Return sequences of matching and conflicting regions.
Method reprocess_merge_regions Where there are conflict regions, remove the agreed lines.
Static Method mismatch_region Undocumented
Method find_sync_regions Return a list of sync regions, where both descendents match the base.
Method find_unconflicted Return a list of ranges in base that are not conflicted.
Method _refine_cherrypick_conflict When cherrypicking b => a, ignore matches with b and base.
def __init__(self, base, a, b, is_cherrypick=False, allow_objects=False):
Constructor.
Parametersbaselines in BASE
alines in A
blines in B
is_cherrypickflag indicating if this merge is a cherrypick. When cherrypicking b => a, matches with b and base do not conflict.
allow_objectsif True, do not require that base, a and b are plain Python strs. Also prevents BinaryFile from being raised. Lines can be any sequence of comparable and hashable Python objects.
def merge_lines(self, name_a=None, name_b=None, name_base=None, start_marker='<<<<<<<', mid_marker='=======', end_marker='>>>>>>>', base_marker=None, reprocess=False):
Return merge in cvs-like form.
def merge_annotated(self):
Return merge with conflicts, showing origin of lines.

Most useful for debugging merge.

def merge_groups(self):

Yield sequence of line groups. Each one is a tuple:

'unchanged', lines
Lines unchanged from base
'a', lines
Lines taken from a
'same', lines
Lines taken from a (and equal to b)
'b', lines
Lines taken from b
'conflict', base_lines, a_lines, b_lines
Lines from base were changed to either a or b and conflict.
def merge_regions(self):
Return sequences of matching and conflicting regions.

This returns tuples, where the first value says what kind we have:

'unchanged', start, end
Take a region of base[start:end]
'same', astart, aend
b and a are different from base but give the same result
'a', start, end
Non-clashing insertion from a[start:end]

Method is as follows:

The two sequences align only on regions which match the base and both descendents. These are found by doing a two-way diff of each one against the base, and then finding the intersections between those regions. These "sync regions" are by definition unchanged in both and easily dealt with.

The regions in between can be in any of three cases: conflicted, or changed on only one side.

def _refine_cherrypick_conflict(self, zstart, zend, astart, aend, bstart, bend):
When cherrypicking b => a, ignore matches with b and base.
def reprocess_merge_regions(self, merge_regions):
Where there are conflict regions, remove the agreed lines.

Lines where both A and B have made the same changes are eliminated.

@staticmethod
def mismatch_region(next_a, region_ia, next_b, region_ib):
Undocumented
def find_sync_regions(self):
Return a list of sync regions, where both descendents match the base.

Generates a list of (base1, base2, a1, a2, b1, b2). There is always a zero-length sync region at the end of all the files.

def find_unconflicted(self):
Return a list of ranges in base that are not conflicted.
API Documentation for Bazaar, generated by pydoctor at 2014-09-20 00:01:57.