~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-12 20:46:42 UTC
  • mto: This revision was merged to the branch mainline in revision 2071.
  • Revision ID: john@arbash-meinel.com-20060912204642-91599869cc863f07
Cleanup, deprecated, and get the tests passing again.

bzrlib.builtins.merge is heavily used by the test suite, though it is
really the wrong place for a function like that.
lazy imports work badly with doctests, but so far none of the doc tested
modules had anything worth testing in that fashion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    errors,
34
34
    ignores,
35
35
    log,
36
 
    merge,
 
36
    merge as _mod_merge,
37
37
    osutils,
38
38
    repository,
39
39
    transport,
2111
2111
 
2112
2112
    def help(self):
2113
2113
        from inspect import getdoc
2114
 
        return getdoc(self) + '\n' + merge.merge_type_help()
 
2114
        return getdoc(self) + '\n' + _mod_merge.merge_type_help()
2115
2115
 
2116
2116
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2117
2117
            show_base=False, reprocess=False, remember=False, 
2118
2118
            uncommitted=False):
2119
2119
        if merge_type is None:
2120
 
            merge_type = merge.Merge3Merger
 
2120
            merge_type = _mod_merge.Merge3Merger
2121
2121
 
2122
2122
        tree = WorkingTree.open_containing(u'.')[0]
2123
2123
 
2239
2239
 
2240
2240
    def help(self):
2241
2241
        from inspect import getdoc
2242
 
        return getdoc(self) + '\n' + merge.merge_type_help()
 
2242
        return getdoc(self) + '\n' + _mod_merge.merge_type_help()
2243
2243
 
2244
2244
    def run(self, file_list=None, merge_type=None, show_base=False,
2245
2245
            reprocess=False):
2246
2246
        if merge_type is None:
2247
 
            merge_type = merge.Merge3Merger
 
2247
            merge_type = _mod_merge.Merge3Merger
2248
2248
        tree, file_list = tree_files(file_list)
2249
2249
        tree.lock_write()
2250
2250
        try:
2274
2274
                    for name, ie in tree.inventory.iter_entries(file_id):
2275
2275
                        interesting_ids.add(ie.file_id)
2276
2276
                new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
2277
 
            merge.transform_tree(tree, tree.basis_tree(), interesting_ids)
 
2277
            _mod_merge.transform_tree(tree, tree.basis_tree(), interesting_ids)
2278
2278
            tree.set_conflicts(ConflictList(new_conflicts))
2279
2279
            if file_list is None:
2280
2280
                restore_files = list(tree.iter_conflicts())
2285
2285
                    restore(tree.abspath(filename))
2286
2286
                except NotConflicted:
2287
2287
                    pass
2288
 
            conflicts = merge.merge_inner(tree.branch, other_tree, base_tree,
2289
 
                                          this_tree=tree,
2290
 
                                          interesting_ids=interesting_ids,
2291
 
                                          other_rev_id=parents[1],
2292
 
                                          merge_type=merge_type,
2293
 
                                          show_base=show_base,
2294
 
                                          reprocess=reprocess)
 
2288
            conflicts = _mod_merge.merge_inner(
 
2289
                                      tree.branch, other_tree, base_tree,
 
2290
                                      this_tree=tree,
 
2291
                                      interesting_ids=interesting_ids,
 
2292
                                      other_rev_id=parents[1],
 
2293
                                      merge_type=merge_type,
 
2294
                                      show_base=show_base,
 
2295
                                      reprocess=reprocess)
2295
2296
        finally:
2296
2297
            tree.unlock()
2297
2298
        if conflicts > 0:
2311
2312
    aliases = ['merge-revert']
2312
2313
 
2313
2314
    def run(self, revision=None, no_backup=False, file_list=None):
2314
 
        from bzrlib.commands import parse_spec
2315
2315
        if file_list is not None:
2316
2316
            if len(file_list) == 0:
2317
2317
                raise BzrCommandError("No files specified")
2747
2747
def _merge_helper(other_revision, base_revision,
2748
2748
                  check_clean=True, ignore_zero=False,
2749
2749
                  this_dir=None, backup_files=False,
2750
 
                  merge_type=merge.Merge3Merger,
 
2750
                  merge_type=_mod_merge.Merge3Merger,
2751
2751
                  file_list=None, show_base=False, reprocess=False,
2752
2752
                  pb=DummyProgress()):
2753
2753
    """Merge changes into a tree.
2780
2780
    if this_dir is None:
2781
2781
        this_dir = u'.'
2782
2782
    this_tree = WorkingTree.open_containing(this_dir)[0]
2783
 
    if show_base and not merge_type is merge.Merge3Merger:
 
2783
    if show_base and not merge_type is _mod_merge.Merge3Merger:
2784
2784
        raise BzrCommandError("Show-base is not supported for this merge"
2785
2785
                              " type. %s" % merge_type)
2786
2786
    if reprocess and not merge_type.supports_reprocess:
2789
2789
    if reprocess and show_base:
2790
2790
        raise BzrCommandError("Cannot do conflict reduction and show base.")
2791
2791
    try:
2792
 
        merger = merge.Merger(this_tree.branch, this_tree=this_tree, pb=pb)
 
2792
        merger = _mod_merge.Merger(this_tree.branch, this_tree=this_tree,
 
2793
                                   pb=pb)
2793
2794
        merger.pp = ProgressPhase("Merge phase", 5, pb)
2794
2795
        merger.pp.next_phase()
2795
2796
        merger.check_basis(check_clean)
2812
2813
    return conflicts
2813
2814
 
2814
2815
 
 
2816
# Compatibility
 
2817
merge = _merge_helper
 
2818
 
 
2819
 
2815
2820
# these get imported and then picked up by the scan for cmd_*
2816
2821
# TODO: Some more consistent way to split command definitions across files;
2817
2822
# we do need to load at least some information about them to know of