/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to cmds.py

Cope with lossy pushes better in `brz propose` texts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    takes_options = [
63
63
            'directory',
64
64
            Option('owner', help='Owner of the new remote branch.', type=str),
65
 
            Option('project', help='Project name for the new remote branch.', type=str),
 
65
            Option('project', help='Project name for the new remote branch.',
 
66
                   type=str),
66
67
            Option('name', help='Name of the new remote branch.', type=str),
67
 
            Option('no-allow-lossy', help='Allow fallback to lossy push, if necessary.'),
 
68
            Option('no-allow-lossy',
 
69
                   help='Allow fallback to lossy push, if necessary.'),
68
70
            Option('overwrite', help="Overwrite existing commits."),
69
71
            ]
70
72
    takes_args = ['submit_branch?']
92
94
        note(gettext("Pushed to %s") % public_url)
93
95
 
94
96
 
95
 
def summarize_unmerged(branch, target):
 
97
def summarize_unmerged(local_branch, remote_branch, target):
96
98
    """Generate a text description of the unmerged revisions in branch.
97
99
 
98
100
    :param branch: The proposed branch
99
101
    :param target: Target branch
100
102
    :return: A string
101
103
    """
102
 
    log_format = _mod_log.log_formatter_registry.get_default(branch)
 
104
    log_format = _mod_log.log_formatter_registry.get_default(local_branch)
103
105
    to_file = StringIO()
104
106
    lf = log_format(to_file=to_file, show_ids=False, show_timezone='original')
105
107
    local_extra = _mod_missing.find_unmerged(
106
 
        branch, target, restrict='local')[0]
 
108
        remote_branch, target, restrict='local')[0]
107
109
 
108
 
    if branch.supports_tags():
109
 
        rev_tag_dict = branch.tags.get_reverse_tag_dict()
 
110
    if remote_branch.supports_tags():
 
111
        rev_tag_dict = remote_branch.tags.get_reverse_tag_dict()
110
112
    else:
111
113
        rev_tag_dict = {}
112
114
 
113
115
    for revision in _mod_missing.iter_log_revisions(
114
 
            local_extra, branch.repository, False, rev_tag_dict):
 
116
            local_extra, local_branch.repository, False, rev_tag_dict):
115
117
        lf.log_revision(revision)
116
118
    return to_file.getvalue()
117
119
 
171
173
        if description is None:
172
174
            body = proposal_builder.get_initial_body()
173
175
            info = proposal_builder.get_infotext()
174
 
            info += "\n\n" + summarize_unmerged(branch, target)
 
176
            info += "\n\n" + summarize_unmerged(branch, remote_branch, target)
175
177
            description = msgeditor.edit_commit_message(
176
178
                info, start_message=body)
177
179
        try:
203
205
        if submit_branch is None:
204
206
            submit_branch = branch.get_parent()
205
207
        if submit_branch is None:
206
 
            raise errors.BzrCommandError(gettext("No target location specified or remembered"))
 
208
            raise errors.BzrCommandError(
 
209
                gettext("No target location specified or remembered"))
207
210
        else:
208
211
            target = _mod_branch.Branch.open(submit_branch)
209
212
        hoster = _mod_propose.get_hoster(branch)
219
222
    takes_args = ['username?']
220
223
 
221
224
    def run(self, username=None):
222
 
        import configparser
223
 
        import os
224
225
        from github import Github, GithubException
225
226
        from breezy.config import AuthenticationConfig
226
227
        authconfig = AuthenticationConfig()