/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 bzrlib/bundle/commands.py

  • Committer: Aaron Bentley
  • Date: 2006-06-26 18:01:07 UTC
  • mto: This revision was merged to the branch mainline in revision 1823.
  • Revision ID: abentley@panoramicfeedback.com-20060626180107-ec9e2e851569e2d8
Clean up bundle revision specification

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    You can apply it to another tree using 'bzr merge'.
67
67
 
68
68
    bzr bundle-revisions
69
 
        - Bundle for the last commit
 
69
        - Generate a bundle relative to a remembered location
70
70
    bzr bundle-revisions BASE
71
71
        - Bundle to apply the current tree into BASE
72
72
    bzr bundle-revisions --revision A
73
 
        - Bundle for revision A
 
73
        - Bundle to apply revision A to remembered location 
74
74
    bzr bundle-revisions --revision A..B
75
75
        - Bundle to transform A into B
76
 
    bzr bundle-revisions --revision A..B BASE
77
 
        - Bundle to transform revision A of BASE into revision B
78
 
          of the local tree
79
76
    """
80
77
    takes_options = ['verbose', 'revision', 'remember',
81
78
                     Option("output", help="write bundle to specified file",
88
85
        from bzrlib.bundle.serializer import write_bundle
89
86
 
90
87
        target_branch = Branch.open_containing(u'.')[0]
91
 
        submit_branch = target_branch.get_submit_branch()
92
88
 
93
89
        if base is None:
94
90
            base_specified = False
95
 
            base = submit_branch
96
91
        else:
97
92
            base_specified = True
98
93
 
99
 
        if base is None:
100
 
            base = target_branch.get_parent()
101
 
        if base is None:
102
 
            raise errors.BzrCommandError("No base branch known or"
103
 
                                         " specified.")
104
 
        elif not base_specified:
105
 
            note('Using saved location: %s' % base)
106
 
        base_branch = Branch.open(base)
107
 
 
108
 
        # We don't want to lock the same branch across
109
 
        # 2 different branches
110
 
        if target_branch.base == base_branch.base:
111
 
            base_branch = target_branch 
112
 
        if submit_branch is None or remember:
113
 
            if base_specified:
114
 
                target_branch.set_submit_branch(base_branch.base)
115
 
            elif remember:
116
 
                raise errors.BzrCommandError('--remember requires a branch to'
117
 
                                             ' be specified.')
118
 
 
119
 
        base_revision = None
120
94
        if revision is None:
121
95
            target_revision = target_branch.last_revision()
122
 
        elif len(revision) == 1:
123
 
            target_revision = revision[0].in_history(target_branch).rev_id
124
 
            if base_branch is not None:
125
 
                base_revision = base_branch.last_revision()
126
 
        elif len(revision) == 2:
127
 
            target_revision = revision[1].in_history(target_branch).rev_id
128
 
            if base_branch is not None:
129
 
                base_revision = revision[0].in_history(base_branch).rev_id
130
 
            else:
 
96
        elif len(revision) < 3:
 
97
            target_revision = revision[-1].in_history(target_branch).rev_id
 
98
            if len(revision) == 2:
 
99
                if base_specified:
 
100
                    raise errors.BzrCommandError('Cannot specify base as well'
 
101
                                                 ' as two revision arguments.')
131
102
                base_revision = revision[0].in_history(target_branch).rev_id
132
103
        else:
133
104
            raise errors.BzrCommandError('--revision takes 1 or 2 parameters')
134
105
 
135
 
        if revision is None or len(revision) == 1:
136
 
            if base_branch is not None:
137
 
                target_branch.repository.fetch(base_branch.repository, 
138
 
                                               base_branch.last_revision())
139
 
                base_revision = common_ancestor(base_branch.last_revision(),
140
 
                                                target_revision,
141
 
                                                target_branch.repository)
142
 
                if base_revision is None:
143
 
                    base_revision = NULL_REVISION
144
 
 
145
 
        if base_revision is None:
146
 
            rev = target_branch.repository.get_revision(target_revision)
147
 
            if rev.parent_ids:
148
 
                base_revision = rev.parent_ids[0]
149
 
            else:
150
 
                base_revision = NULL_REVISION
151
 
 
152
 
        if base_branch is not None:
 
106
        if revision is None or len(revision) < 2:
 
107
            submit_branch = target_branch.get_submit_branch()
 
108
            if base is None:
 
109
                base = submit_branch
 
110
            if base is None:
 
111
                base = target_branch.get_parent()
 
112
            if base is None:
 
113
                raise errors.BzrCommandError("No base branch known or"
 
114
                                             " specified.")
 
115
            elif not base_specified:
 
116
                note('Using saved location: %s' % base)
 
117
            base_branch = Branch.open(base)
 
118
 
 
119
            # We don't want to lock the same branch across
 
120
            # 2 different branches
 
121
            if target_branch.base == base_branch.base:
 
122
                base_branch = target_branch 
 
123
            if submit_branch is None or remember:
 
124
                if base_specified:
 
125
                    target_branch.set_submit_branch(base_branch.base)
 
126
                elif remember:
 
127
                    raise errors.BzrCommandError('--remember requires a branch'
 
128
                                                 ' to be specified.')
153
129
            target_branch.repository.fetch(base_branch.repository, 
154
 
                                           revision_id=base_revision)
155
 
            del base_branch
 
130
                                           base_branch.last_revision())
 
131
            base_revision = common_ancestor(base_branch.last_revision(),
 
132
                                            target_revision,
 
133
                                            target_branch.repository)
 
134
 
156
135
 
157
136
        if output is not None:
158
137
            fileobj = file(output, 'wb')