~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jonathan Lange
  • Date: 2009-06-26 08:46:52 UTC
  • mto: (4484.1.1 bring-1.16.1-back)
  • mto: This revision was merged to the branch mainline in revision 4485.
  • Revision ID: jml@canonical.com-20090626084652-x7wn8yimd3fj0j0y
Tweak NEWS slightly based on mbp's feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
946
946
            if branch_to.get_parent() is None or remember:
947
947
                branch_to.set_parent(branch_from.base)
948
948
 
949
 
        if branch_from is not branch_to:
950
 
            branch_from.lock_read()
 
949
        if revision is not None:
 
950
            revision_id = revision.as_revision_id(branch_from)
 
951
 
 
952
        branch_to.lock_write()
951
953
        try:
952
 
            if revision is not None:
953
 
                revision_id = revision.as_revision_id(branch_from)
954
 
 
955
 
            branch_to.lock_write()
956
 
            try:
957
 
                if tree_to is not None:
958
 
                    view_info = _get_view_info_for_change_reporter(tree_to)
959
 
                    change_reporter = delta._ChangeReporter(
960
 
                        unversioned_filter=tree_to.is_ignored,
961
 
                        view_info=view_info)
962
 
                    result = tree_to.pull(
963
 
                        branch_from, overwrite, revision_id, change_reporter,
964
 
                        possible_transports=possible_transports, local=local)
965
 
                else:
966
 
                    result = branch_to.pull(
967
 
                        branch_from, overwrite, revision_id, local=local)
968
 
 
969
 
                result.report(self.outf)
970
 
                if verbose and result.old_revid != result.new_revid:
971
 
                    log.show_branch_change(
972
 
                        branch_to, self.outf, result.old_revno,
973
 
                        result.old_revid)
974
 
            finally:
975
 
                branch_to.unlock()
 
954
            if tree_to is not None:
 
955
                view_info = _get_view_info_for_change_reporter(tree_to)
 
956
                change_reporter = delta._ChangeReporter(
 
957
                    unversioned_filter=tree_to.is_ignored, view_info=view_info)
 
958
                result = tree_to.pull(branch_from, overwrite, revision_id,
 
959
                                      change_reporter,
 
960
                                      possible_transports=possible_transports,
 
961
                                      local=local)
 
962
            else:
 
963
                result = branch_to.pull(branch_from, overwrite, revision_id,
 
964
                                      local=local)
 
965
 
 
966
            result.report(self.outf)
 
967
            if verbose and result.old_revid != result.new_revid:
 
968
                log.show_branch_change(branch_to, self.outf, result.old_revno,
 
969
                                       result.old_revid)
976
970
        finally:
977
 
            if branch_from is not branch_to:
978
 
                branch_from.unlock()
 
971
            branch_to.unlock()
979
972
 
980
973
 
981
974
class cmd_push(Command):
1028
1021
                'for the commit history. Only the work not present in the '
1029
1022
                'referenced branch is included in the branch created.',
1030
1023
            type=unicode),
1031
 
        Option('strict',
1032
 
               help='Refuse to push if there are uncommitted changes in'
1033
 
               ' the working tree.'),
1034
1024
        ]
1035
1025
    takes_args = ['location?']
1036
1026
    encoding_type = 'replace'
1038
1028
    def run(self, location=None, remember=False, overwrite=False,
1039
1029
        create_prefix=False, verbose=False, revision=None,
1040
1030
        use_existing_dir=False, directory=None, stacked_on=None,
1041
 
        stacked=False, strict=None):
 
1031
        stacked=False):
1042
1032
        from bzrlib.push import _show_push_branch
1043
1033
 
 
1034
        # Get the source branch and revision_id
1044
1035
        if directory is None:
1045
1036
            directory = '.'
1046
 
        # Get the source branch
1047
 
        (tree, br_from,
1048
 
         _unused) = bzrdir.BzrDir.open_containing_tree_or_branch(directory)
1049
 
        if strict is None:
1050
 
            strict = br_from.get_config().get_user_option('push_strict')
1051
 
            if strict is not None:
1052
 
                # FIXME: This should be better supported by config
1053
 
                # -- vila 20090611
1054
 
                bools = dict(yes=True, no=False, on=True, off=False,
1055
 
                             true=True, false=False)
1056
 
                try:
1057
 
                    strict = bools[strict.lower()]
1058
 
                except KeyError:
1059
 
                    strict = None
1060
 
        if strict:
1061
 
            changes = tree.changes_from(tree.basis_tree())
1062
 
            if changes.has_changed():
1063
 
                raise errors.UncommittedChanges(tree)
1064
 
        # Get the tip's revision_id
 
1037
        br_from = Branch.open_containing(directory)[0]
1065
1038
        revision = _get_one_revision('push', revision)
1066
1039
        if revision is not None:
1067
1040
            revision_id = revision.in_history(br_from).rev_id
1651
1624
                branch.set_append_revisions_only(True)
1652
1625
            except errors.UpgradeRequired:
1653
1626
                raise errors.BzrCommandError('This branch format cannot be set'
1654
 
                    ' to append-revisions-only.  Try --default.')
 
1627
                    ' to append-revisions-only.  Try --experimental-branch6')
1655
1628
        if not is_quiet():
1656
1629
            from bzrlib.info import describe_layout, describe_format
1657
1630
            try:
2396
2369
 
2397
2370
        if path is None:
2398
2371
            fs_path = '.'
 
2372
            prefix = ''
2399
2373
        else:
2400
2374
            if from_root:
2401
2375
                raise errors.BzrCommandError('cannot specify both --from-root'
2402
2376
                                             ' and PATH')
2403
2377
            fs_path = path
 
2378
            prefix = path
2404
2379
        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
2405
2380
            fs_path)
2406
 
 
2407
 
        # Calculate the prefix to use
2408
 
        prefix = None
2409
2381
        if from_root:
2410
 
            if relpath:
2411
 
                prefix = relpath + '/'
2412
 
        elif fs_path != '.':
2413
 
            prefix = fs_path + '/'
2414
 
 
 
2382
            relpath = u''
 
2383
        elif relpath:
 
2384
            relpath += '/'
2415
2385
        if revision is not None or tree is None:
2416
2386
            tree = _get_one_revision_tree('ls', revision, branch=branch)
2417
2387
 
2425
2395
 
2426
2396
        tree.lock_read()
2427
2397
        try:
2428
 
            for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2429
 
                from_dir=relpath, recursive=recursive):
2430
 
                # Apply additional masking
2431
 
                if not all and not selection[fc]:
2432
 
                    continue
2433
 
                if kind is not None and fkind != kind:
2434
 
                    continue
2435
 
                if apply_view:
2436
 
                    try:
2437
 
                        if relpath:
2438
 
                            fullpath = osutils.pathjoin(relpath, fp)
2439
 
                        else:
2440
 
                            fullpath = fp
2441
 
                        views.check_path_in_view(tree, fullpath)
2442
 
                    except errors.FileOutsideView:
2443
 
                        continue
2444
 
 
2445
 
                # Output the entry
2446
 
                if prefix:
2447
 
                    fp = osutils.pathjoin(prefix, fp)
2448
 
                kindch = entry.kind_character()
2449
 
                outstring = fp + kindch
2450
 
                ui.ui_factory.clear_term()
2451
 
                if verbose:
2452
 
                    outstring = '%-8s %s' % (fc, outstring)
2453
 
                    if show_ids and fid is not None:
2454
 
                        outstring = "%-50s %s" % (outstring, fid)
2455
 
                    self.outf.write(outstring + '\n')
2456
 
                elif null:
2457
 
                    self.outf.write(fp + '\0')
2458
 
                    if show_ids:
2459
 
                        if fid is not None:
2460
 
                            self.outf.write(fid)
2461
 
                        self.outf.write('\0')
2462
 
                    self.outf.flush()
2463
 
                else:
2464
 
                    if show_ids:
 
2398
            for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
 
2399
                if fp.startswith(relpath):
 
2400
                    rp = fp[len(relpath):]
 
2401
                    fp = osutils.pathjoin(prefix, rp)
 
2402
                    if not recursive and '/' in rp:
 
2403
                        continue
 
2404
                    if not all and not selection[fc]:
 
2405
                        continue
 
2406
                    if kind is not None and fkind != kind:
 
2407
                        continue
 
2408
                    if apply_view:
 
2409
                        try:
 
2410
                            views.check_path_in_view(tree, fp)
 
2411
                        except errors.FileOutsideView:
 
2412
                            continue
 
2413
                    kindch = entry.kind_character()
 
2414
                    outstring = fp + kindch
 
2415
                    ui.ui_factory.clear_term()
 
2416
                    if verbose:
 
2417
                        outstring = '%-8s %s' % (fc, outstring)
 
2418
                        if show_ids and fid is not None:
 
2419
                            outstring = "%-50s %s" % (outstring, fid)
 
2420
                        self.outf.write(outstring + '\n')
 
2421
                    elif null:
 
2422
                        self.outf.write(fp + '\0')
 
2423
                        if show_ids:
 
2424
                            if fid is not None:
 
2425
                                self.outf.write(fid)
 
2426
                            self.outf.write('\0')
 
2427
                        self.outf.flush()
 
2428
                    else:
2465
2429
                        if fid is not None:
2466
2430
                            my_id = fid
2467
2431
                        else:
2468
2432
                            my_id = ''
2469
 
                        self.outf.write('%-50s %s\n' % (outstring, my_id))
2470
 
                    else:
2471
 
                        self.outf.write(outstring + '\n')
 
2433
                        if show_ids:
 
2434
                            self.outf.write('%-50s %s\n' % (outstring, my_id))
 
2435
                        else:
 
2436
                            self.outf.write(outstring + '\n')
2472
2437
        finally:
2473
2438
            tree.unlock()
2474
2439
 
2998
2963
    The working tree and branch checks will only give output if a problem is
2999
2964
    detected. The output fields of the repository check are:
3000
2965
 
3001
 
    revisions
3002
 
        This is just the number of revisions checked.  It doesn't
3003
 
        indicate a problem.
3004
 
 
3005
 
    versionedfiles
3006
 
        This is just the number of versionedfiles checked.  It
3007
 
        doesn't indicate a problem.
3008
 
 
3009
 
    unreferenced ancestors
3010
 
        Texts that are ancestors of other texts, but
3011
 
        are not properly referenced by the revision ancestry.  This is a
3012
 
        subtle problem that Bazaar can work around.
3013
 
 
3014
 
    unique file texts
3015
 
        This is the total number of unique file contents
3016
 
        seen in the checked revisions.  It does not indicate a problem.
3017
 
 
3018
 
    repeated file texts
3019
 
        This is the total number of repeated texts seen
3020
 
        in the checked revisions.  Texts can be repeated when their file
3021
 
        entries are modified, but the file contents are not.  It does not
3022
 
        indicate a problem.
 
2966
        revisions: This is just the number of revisions checked.  It doesn't
 
2967
            indicate a problem.
 
2968
        versionedfiles: This is just the number of versionedfiles checked.  It
 
2969
            doesn't indicate a problem.
 
2970
        unreferenced ancestors: Texts that are ancestors of other texts, but
 
2971
            are not properly referenced by the revision ancestry.  This is a
 
2972
            subtle problem that Bazaar can work around.
 
2973
        unique file texts: This is the total number of unique file contents
 
2974
            seen in the checked revisions.  It does not indicate a problem.
 
2975
        repeated file texts: This is the total number of repeated texts seen
 
2976
            in the checked revisions.  Texts can be repeated when their file
 
2977
            entries are modified, but the file contents are not.  It does not
 
2978
            indicate a problem.
3023
2979
 
3024
2980
    If no restrictions are specified, all Bazaar data that is found at the given
3025
2981
    location will be checked.
3604
3560
                if revision is not None and len(revision) > 0:
3605
3561
                    raise errors.BzrCommandError('Cannot use --uncommitted and'
3606
3562
                        ' --revision at the same time.')
3607
 
                merger = self.get_merger_from_uncommitted(tree, location, pb,
3608
 
                                                          cleanups)
 
3563
                location = self._select_branch_location(tree, location)[0]
 
3564
                other_tree, other_path = WorkingTree.open_containing(location)
 
3565
                merger = _mod_merge.Merger.from_uncommitted(tree, other_tree,
 
3566
                    pb)
3609
3567
                allow_pending = False
 
3568
                if other_path != '':
 
3569
                    merger.interesting_files = [other_path]
3610
3570
 
3611
3571
            if merger is None:
3612
3572
                merger, allow_pending = self._get_merger_from_branch(tree,
3725
3685
            allow_pending = True
3726
3686
        return merger, allow_pending
3727
3687
 
3728
 
    def get_merger_from_uncommitted(self, tree, location, pb, cleanups):
3729
 
        """Get a merger for uncommitted changes.
3730
 
 
3731
 
        :param tree: The tree the merger should apply to.
3732
 
        :param location: The location containing uncommitted changes.
3733
 
        :param pb: The progress bar to use for showing progress.
3734
 
        :param cleanups: A list of operations to perform to clean up the
3735
 
            temporary directories, unfinalized objects, etc.
3736
 
        """
3737
 
        location = self._select_branch_location(tree, location)[0]
3738
 
        other_tree, other_path = WorkingTree.open_containing(location)
3739
 
        merger = _mod_merge.Merger.from_uncommitted(tree, other_tree, pb)
3740
 
        if other_path != '':
3741
 
            merger.interesting_files = [other_path]
3742
 
        return merger
3743
 
 
3744
3688
    def _select_branch_location(self, tree, user_location, revision=None,
3745
3689
                                index=None):
3746
3690
        """Select a branch location, according to possible inputs.
4724
4668
        try:
4725
4669
            containing_tree.extract(sub_id)
4726
4670
        except errors.RootNotRich:
4727
 
            raise errors.RichRootUpgradeRequired(containing_tree.branch.base)
 
4671
            raise errors.UpgradeRequired(containing_tree.branch.base)
4728
4672
 
4729
4673
 
4730
4674
class cmd_merge_directive(Command):