~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2008-03-14 16:32:01 UTC
  • mfrom: (3277 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3280.
  • Revision ID: john@arbash-meinel.com-20080314163201-33r5errgr41hzaci
[merge] bzr.dev 3277, cleanup NEWS indentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
687
687
    """
688
688
 
689
689
    _see_also = ['pull', 'update', 'working-trees']
690
 
    takes_options = ['remember', 'overwrite', 'verbose',
 
690
    takes_options = ['remember', 'overwrite', 'verbose', 'revision',
691
691
        Option('create-prefix',
692
692
               help='Create the path leading up to the branch '
693
693
                    'if it does not already exist.'),
707
707
    encoding_type = 'replace'
708
708
 
709
709
    def run(self, location=None, remember=False, overwrite=False,
710
 
            create_prefix=False, verbose=False,
 
710
            create_prefix=False, verbose=False, revision=None,
711
711
            use_existing_dir=False,
712
712
            directory=None):
713
713
        # FIXME: Way too big!  Put this into a function called from the
746
746
            else:
747
747
                # Found a branch, so we must have found a repository
748
748
                repository_to = br_to.repository
 
749
 
 
750
        if revision is not None:
 
751
            if len(revision) == 1:
 
752
                revision_id = revision[0].in_history(br_from).rev_id
 
753
            else:
 
754
                raise errors.BzrCommandError(
 
755
                    'bzr push --revision takes one value.')
 
756
        else:
 
757
            revision_id = br_from.last_revision()
 
758
 
749
759
        push_result = None
750
760
        if verbose:
751
761
            old_rh = []
786
796
            # directory. So we need to create it, along with any work to create
787
797
            # all of the dependent branches, etc.
788
798
            dir_to = br_from.bzrdir.clone_on_transport(to_transport,
789
 
                revision_id=br_from.last_revision())
 
799
                                                       revision_id=revision_id)
790
800
            br_to = dir_to.open_branch()
791
801
            # TODO: Some more useful message about what was copied
792
802
            note('Created new branch.')
804
814
        elif br_to is None:
805
815
            # We have a repository but no branch, copy the revisions, and then
806
816
            # create a branch.
807
 
            last_revision_id = br_from.last_revision()
808
 
            repository_to.fetch(br_from.repository,
809
 
                                revision_id=last_revision_id)
810
 
            br_to = br_from.clone(dir_to, revision_id=last_revision_id)
 
817
            repository_to.fetch(br_from.repository, revision_id=revision_id)
 
818
            br_to = br_from.clone(dir_to, revision_id=revision_id)
811
819
            note('Created new branch.')
812
820
            if br_from.get_push_location() is None or remember:
813
821
                br_from.set_push_location(br_to.base)
825
833
                    warning("This transport does not update the working " 
826
834
                            "tree of: %s. See 'bzr help working-trees' for "
827
835
                            "more information." % br_to.base)
828
 
                    push_result = br_from.push(br_to, overwrite)
 
836
                    push_result = br_from.push(br_to, overwrite,
 
837
                                               stop_revision=revision_id)
829
838
                except errors.NoWorkingTree:
830
 
                    push_result = br_from.push(br_to, overwrite)
 
839
                    push_result = br_from.push(br_to, overwrite,
 
840
                                               stop_revision=revision_id)
831
841
                else:
832
842
                    tree_to.lock_write()
833
843
                    try:
834
 
                        push_result = br_from.push(tree_to.branch, overwrite)
 
844
                        push_result = br_from.push(tree_to.branch, overwrite,
 
845
                                                   stop_revision=revision_id)
835
846
                        tree_to.update()
836
847
                    finally:
837
848
                        tree_to.unlock()
1940
1951
        Ignore .o files under the lib directory::
1941
1952
 
1942
1953
            bzr ignore "RE:lib/.*\.o"
 
1954
 
 
1955
        Ignore everything but the "debian" toplevel directory::
 
1956
 
 
1957
            bzr ignore "RE:(?!debian/).*"
1943
1958
    """
1944
1959
 
1945
1960
    _see_also = ['status', 'ignored']
2409
2424
                try:
2410
2425
                    repo_basis = tree.branch.repository.revision_tree(
2411
2426
                        tree.last_revision())
2412
 
                    if len(list(repo_basis._iter_changes(tree_basis))):
 
2427
                    if len(list(repo_basis.iter_changes(tree_basis))):
2413
2428
                        raise errors.BzrCheckError(
2414
2429
                            "Mismatched basis inventory content.")
2415
2430
                    tree._validate()
3008
3023
        mutter("%s", stored_location)
3009
3024
        if stored_location is None:
3010
3025
            raise errors.BzrCommandError("No location specified or remembered")
3011
 
        display_url = urlutils.unescape_for_display(stored_location,
3012
 
            self.outf.encoding)
3013
 
        self.outf.write("%s remembered location %s\n" % (verb_string,
3014
 
            display_url))
 
3026
        display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
 
3027
        note(u"%s remembered location %s", verb_string, display_url)
3015
3028
        return stored_location
3016
3029
 
3017
3030
 
4027
4040
    generic options are "default", "editor", "mapi", and "xdg-email".
4028
4041
 
4029
4042
    If mail is being sent, a to address is required.  This can be supplied
4030
 
    either on the commandline, or by setting the submit_to configuration
4031
 
    option.
 
4043
    either on the commandline, by setting the submit_to configuration
 
4044
    option in the branch itself or the child_submit_to configuration option 
 
4045
    in the submit branch.
4032
4046
 
4033
4047
    Two formats are currently supported: "4" uses revision bundle format 4 and
4034
4048
    merge directive format 2.  It is significantly faster and smaller than
4113
4127
            if remembered_submit_branch:
4114
4128
                note('Using saved location: %s', submit_branch)
4115
4129
 
 
4130
            if mail_to is None:
 
4131
                submit_config = Branch.open(submit_branch).get_config()
 
4132
                mail_to = submit_config.get_user_option("child_submit_to")
 
4133
 
4116
4134
            stored_public_branch = branch.get_public_branch()
4117
4135
            if public_branch is None:
4118
4136
                public_branch = stored_public_branch
4167
4185
                else:
4168
4186
                    revision = branch.repository.get_revision(revision_id)
4169
4187
                    subject += revision.get_summary()
 
4188
                basename = directive.get_disk_name(branch)
4170
4189
                mail_client.compose_merge_request(mail_to, subject,
4171
 
                                                  outfile.getvalue())
 
4190
                                                  outfile.getvalue(), basename)
4172
4191
        finally:
4173
4192
            if output != '-':
4174
4193
                outfile.close()
4433
4452
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))
4434
4453
 
4435
4454
 
 
4455
class cmd_hooks(Command):
 
4456
    """Show a branch's currently registered hooks.
 
4457
    """
 
4458
 
 
4459
    hidden = True
 
4460
    takes_args = ['path?']
 
4461
 
 
4462
    def run(self, path=None):
 
4463
        if path is None:
 
4464
            path = '.'
 
4465
        branch_hooks = Branch.open(path).hooks
 
4466
        for hook_type in branch_hooks:
 
4467
            hooks = branch_hooks[hook_type]
 
4468
            self.outf.write("%s:\n" % (hook_type,))
 
4469
            if hooks:
 
4470
                for hook in hooks:
 
4471
                    self.outf.write("  %s\n" %
 
4472
                                    (branch_hooks.get_hook_name(hook),))
 
4473
            else:
 
4474
                self.outf.write("  <no hooks installed>\n")
 
4475
 
 
4476
 
4436
4477
def _create_prefix(cur_transport):
4437
4478
    needed = [cur_transport]
4438
4479
    # Recurse upwards until we can create a directory successfully