Merge lp:~oddbloke/bzr/183559-switch-r into lp:bzr
- 183559-switch-r
- Merge into bzr.dev
Status: | Rejected | ||||
---|---|---|---|---|---|
Rejected by: | Andrew Bennetts | ||||
Proposed branch: | lp:~oddbloke/bzr/183559-switch-r | ||||
Merge into: | lp:bzr | ||||
Diff against target: |
434 lines (+309/-1) 5 files modified
NEWS (+200/-0) bzrlib/builtins.py (+35/-1) bzrlib/switch.py (+25/-0) bzrlib/tests/blackbox/test_switch.py (+32/-0) bzrlib/tests/test_switch.py (+17/-0) |
||||
To merge this branch: | bzr merge lp:~oddbloke/bzr/183559-switch-r | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrew Bennetts | Disapprove | ||
John A Meinel | Needs Fixing | ||
Review via email: mp+16827@code.launchpad.net |
Commit message
Description of the change
Martin Pool (mbp) wrote : | # |
John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin Pool wrote:
> Martin Pool has proposed merging lp:~daniel-thewatkins/bzr/183559-switch-r into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> #183559 bzr switch should have a -r option
> https:/
>
>
> Fix for https:/
>
> I haven't read it yet but it would be good for someone to review it and if necessary pick it up.
>
1) Lots of conflicts. Looks like it was done back in 1.12 or so. A lot
of stuff doesn't line up. Probably mostly shallow
2)
=== modified file 'bzrlib/
- --- bzrlib/builtins.py 2009-12-23 05:42:33 +0000
+++ bzrlib/builtins.py 2010-01-05 03:39:25 +0000
@@ -5493,22 +5493,42 @@
that of the master.
"""
- - takes_args = ['to_location']
+ takes_args = ['to_location?']
takes_options = [Option('force',
+<<<<<<< TREE
before'
+=======
+ help='Switch even if local commits will be lost.'),
+ 'revision'
+>>>>>>> MERGE-SOURCE
^- This looks like he made it so "bzr switch -r XXX" changes the local
tree to a different rev. Which sounds like overlap with the new "bzr
update -r" functionality.
I would probably pick one and stick with it, rather than having 2 ways
to do it.
TBH switch comes to mind faster than update, though I think update fits
SVN usage better.
The rest of the code just passing down a revision_id to switch, and
having it use that RevisionTree rather than just the
to_branch.
review: needs_fixing
I'm not setting this to WIP yet, as maybe the patch-pilot wants to pick
it up?
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAkt
9lQAn0Rxvuw4TIs
=po4T
-----END PGP SIGNATURE-----
Andrew Bennetts (spiv) wrote : | # |
Sure, I'll pick it up.
Andrew Bennetts (spiv) wrote : | # |
Daniel, I just noticed you haven't signed the Canonical's contributor's agreement... would you mind doing so? <http://
I've put an updated version of this up for review at <https:/
(Marking "Disapprove/
Updating diff...
An updated diff will be available in a few minutes. Reload to see the changes.
Preview Diff
1 | === modified file 'NEWS' | |||
2 | --- NEWS 2010-01-04 05:40:01 +0000 | |||
3 | +++ NEWS 2010-01-05 03:39:25 +0000 | |||
4 | @@ -1,5 +1,6 @@ | |||
5 | 1 | #################### | 1 | #################### |
6 | 2 | Bazaar Release Notes | 2 | Bazaar Release Notes |
7 | 3 | <<<<<<< TREE | ||
8 | 3 | #################### | 4 | #################### |
9 | 4 | 5 | ||
10 | 5 | .. contents:: List of Releases | 6 | .. contents:: List of Releases |
11 | @@ -3360,6 +3361,205 @@ | |||
12 | 3360 | 3361 | ||
13 | 3361 | :Codename: "Eyes up!" | 3362 | :Codename: "Eyes up!" |
14 | 3362 | :Released: 2009-01-19 | 3363 | :Released: 2009-01-19 |
15 | 3364 | ======= | ||
16 | 3365 | -------------------- | ||
17 | 3366 | |||
18 | 3367 | .. contents:: | ||
19 | 3368 | |||
20 | 3369 | IN DEVELOPMENT | ||
21 | 3370 | -------------- | ||
22 | 3371 | |||
23 | 3372 | COMPATIBILITY BREAKS: | ||
24 | 3373 | |||
25 | 3374 | * By default, ``bzr status`` after a merge now shows just the pending | ||
26 | 3375 | merge tip revisions. This improves the signal-to-noise ratio after | ||
27 | 3376 | merging from trunk and completes much faster. To see all merged | ||
28 | 3377 | revisions, use the new ``-v`` flag. (Ian Clatworthy) | ||
29 | 3378 | |||
30 | 3379 | * ``bzr log --line`` now shows any tags after the date and before | ||
31 | 3380 | the commit message. If you have scripts which parse the output | ||
32 | 3381 | from this command, you may need to adjust them accordingly. | ||
33 | 3382 | (Ian Clatworthy) | ||
34 | 3383 | |||
35 | 3384 | * ``bzr log --short`` now shows any additional revision properties | ||
36 | 3385 | after the date and before the commit message. Scripts that parse | ||
37 | 3386 | output of the log command in this situation may need to adjust. | ||
38 | 3387 | (Neil Martinsen-Burrell) | ||
39 | 3388 | |||
40 | 3389 | * The experimental formats ``1.12-preview`` and ``1.12-preview-rich-root`` | ||
41 | 3390 | have been renamed ``development-wt5`` and ``development-wt5-rich-root`` | ||
42 | 3391 | respectively, given they are not ready for release in 1.12. | ||
43 | 3392 | (Ian Clatworthy) | ||
44 | 3393 | |||
45 | 3394 | NEW FEATURES: | ||
46 | 3395 | |||
47 | 3396 | * Add support for filtering `bzr missing` on revisions. Remote revisions | ||
48 | 3397 | can be filtered using `bzr missing -r -20..-10` and local revisions can | ||
49 | 3398 | be filtered using `bzr missing --my-revision -20..-10`. | ||
50 | 3399 | (Marius Kruger) | ||
51 | 3400 | |||
52 | 3401 | * ``bzr log -p`` displays the patch diff for each revision. | ||
53 | 3402 | When logging a file, the diff only includes changes to that file. | ||
54 | 3403 | (Ian Clatworthy, #202331, #227335) | ||
55 | 3404 | |||
56 | 3405 | * ``bzr log`` supports a new option called ``-n N`` or ``--level N``. | ||
57 | 3406 | A value of 0 (zero) means "show all nested merge revisions" while | ||
58 | 3407 | a value of 1 (one) means "show just the top level". Values above | ||
59 | 3408 | 1 can be used to see a limited amount of nesting. That can be | ||
60 | 3409 | useful for seeing the level or two below PQM submits for example. | ||
61 | 3410 | To force the ``--short`` and ``--line`` formats to display all nested | ||
62 | 3411 | merge revisions just like ``--long`` does by default, use a command | ||
63 | 3412 | like ``bzr log --short -n0``. To display just the mainline using | ||
64 | 3413 | ``--long`` format, ``bzr log --long -n1``. | ||
65 | 3414 | (Ian Clatworthy) | ||
66 | 3415 | |||
67 | 3416 | IMPROVEMENTS: | ||
68 | 3417 | |||
69 | 3418 | * ``bzr add`` more clearly communicates success vs failure. | ||
70 | 3419 | (Daniel Watkins) | ||
71 | 3420 | |||
72 | 3421 | * ``bzr init`` will now print a little less verbose output. | ||
73 | 3422 | (Marius Kruger) | ||
74 | 3423 | |||
75 | 3424 | * ``bzr log`` is now much faster in many use cases, particularly | ||
76 | 3425 | at incrementally displaying results and filtering by a | ||
77 | 3426 | revision range. (Ian Clatworthy) | ||
78 | 3427 | |||
79 | 3428 | * ``bzr log --short`` and ``bzr log --line`` now show tags, if any, | ||
80 | 3429 | for each revision. The tags are shown comma-separated inside | ||
81 | 3430 | ``{}``. For short format, the tags appear at the end of line | ||
82 | 3431 | before the optional ``[merge]`` indicator. For line format, | ||
83 | 3432 | the tags appear after the date. (Ian Clatworthy) | ||
84 | 3433 | |||
85 | 3434 | * ``bzr switch`` now takes a ``--revision`` option, to allow switching to a | ||
86 | 3435 | specific revision of a branch. (Daniel Watkins, #183559) | ||
87 | 3436 | |||
88 | 3437 | * Progress bars now show the rate of activity for some sftp | ||
89 | 3438 | operations, and they are drawn different. (Martin Pool, #172741) | ||
90 | 3439 | |||
91 | 3440 | * Progress bars now show the rate of activity for urllib and pycurl based | ||
92 | 3441 | http client implementations. The operations are tracked at the socket | ||
93 | 3442 | level for better precision. | ||
94 | 3443 | (Vincent Ladeuil) | ||
95 | 3444 | |||
96 | 3445 | * Rule-based preferences can now accept multiple patterns for a set of | ||
97 | 3446 | rules. (Marius Kruger) | ||
98 | 3447 | |||
99 | 3448 | * The ``ancestor:`` revision spec will now default to referring to the | ||
100 | 3449 | parent of the branch if no other location is given. | ||
101 | 3450 | (Daniel Watkins, #198417) | ||
102 | 3451 | |||
103 | 3452 | * The debugger started as a result of setting ``$BZR_PDB`` works | ||
104 | 3453 | around a bug in ``pdb``, http://bugs.python.org/issue4150. The bug | ||
105 | 3454 | can cause truncated tracebacks in Python versions before 2.6. | ||
106 | 3455 | (Andrew Bennetts) | ||
107 | 3456 | |||
108 | 3457 | * VirtualVersionedFiles now implements | ||
109 | 3458 | ``iter_lines_added_or_present_in_keys``. This allows the creation of | ||
110 | 3459 | new branches based on stacked bzr-svn branches. (#311997) | ||
111 | 3460 | |||
112 | 3461 | BUG FIXES: | ||
113 | 3462 | |||
114 | 3463 | * ``bzr annotate --show-ids`` doesn't give a backtrace on empty files | ||
115 | 3464 | anymore. | ||
116 | 3465 | (Anne Mohsen, Vincent Ladeuil, #314525) | ||
117 | 3466 | |||
118 | 3467 | * ``bzr log FILE`` now correctly shows mainline revisions merging | ||
119 | 3468 | a change to FILE when the ``--short`` and ``--line`` log formats | ||
120 | 3469 | are used. (Ian Clatworthy, #317417) | ||
121 | 3470 | |||
122 | 3471 | * ``bzr log -rX..Y FILE`` now shows the history of FILE provided | ||
123 | 3472 | it existed in Y or X, even if the file has since been deleted or | ||
124 | 3473 | renamed. If no range is given, the current/basis tree and | ||
125 | 3474 | initial tree are searched in that order. More generally, log | ||
126 | 3475 | now interprets filenames in their historical context. | ||
127 | 3476 | (Ian Clatworthy, #175520) | ||
128 | 3477 | |||
129 | 3478 | * ``bzr status`` now reports nonexistent files and continues, then | ||
130 | 3479 | errors (with code 3) at the end. (Karl Fogel, #306394) | ||
131 | 3480 | |||
132 | 3481 | * Don't require the present compression base in knits to be the same | ||
133 | 3482 | when adding records in knits. (Jelmer Vernooij, #307394) | ||
134 | 3483 | |||
135 | 3484 | * Fix a problem with CIFS client/server lag on Windows colliding with | ||
136 | 3485 | an invariant-per-process algorithm for generating AtomicFile names | ||
137 | 3486 | (Adrian Wilkins, #304023) | ||
138 | 3487 | |||
139 | 3488 | * Many socket operations now handle EINTR by retrying the operation. | ||
140 | 3489 | Previously EINTR was treated as an unrecoverable failure. There is | ||
141 | 3490 | a new ``until_no_eintr`` helper function in ``bzrlib.osutils``. | ||
142 | 3491 | (Andrew Bennetts) | ||
143 | 3492 | |||
144 | 3493 | * Support symlinks with non-ascii characters in the symlink filename. | ||
145 | 3494 | (Jelmer Vernooij, #319323) | ||
146 | 3495 | |||
147 | 3496 | * There was a bug in how we handled resolving when a file is deleted | ||
148 | 3497 | in one branch, and modified in the other. If there was a criss-cross | ||
149 | 3498 | merge, we would cause the deletion to conflict a second time. | ||
150 | 3499 | (Vincent Ladeuil, John Arbash Meinel) | ||
151 | 3500 | |||
152 | 3501 | * There was another bug in how we chose the correct intermediate LCA in | ||
153 | 3502 | criss-cross merges leading to several kind of changes be incorrectly | ||
154 | 3503 | handled. | ||
155 | 3504 | (John Arbash Meinel, Vincent Ladeuil) | ||
156 | 3505 | |||
157 | 3506 | * Unshelve now handles deleted paths without crashing. (Robert Collins) | ||
158 | 3507 | |||
159 | 3508 | DOCUMENTATION: | ||
160 | 3509 | |||
161 | 3510 | * Improved plugin developer documentation. (Martin Pool) | ||
162 | 3511 | |||
163 | 3512 | API CHANGES: | ||
164 | 3513 | |||
165 | 3514 | * ``ProgressBarStack`` is deprecated; instead use | ||
166 | 3515 | ``ui_factory.nested_progress_bar`` to create new progress bars. | ||
167 | 3516 | |||
168 | 3517 | * ForeignVcsMapping() now requires a ForeignVcs object as first | ||
169 | 3518 | argument. (Jelmer Vernooij) | ||
170 | 3519 | |||
171 | 3520 | * ForeignVcsMapping.show_foreign_revid() has been moved to | ||
172 | 3521 | ForeignVcs. (Jelmer Vernooij) | ||
173 | 3522 | |||
174 | 3523 | * Revision specifiers are now registered in | ||
175 | 3524 | ``bzrlib.revisionspec.revspec_registry``, and the old list of | ||
176 | 3525 | revisionspec classes (``bzrlib.revisionspec.SPEC_TYPES``) has been | ||
177 | 3526 | deprecated. (Jelmer Vernooij, #321183) | ||
178 | 3527 | |||
179 | 3528 | * The progress and UI classes have changed; the main APIs remain the | ||
180 | 3529 | same but code that provides a new UI or progress bar class may | ||
181 | 3530 | need to be updated. (Martin Pool) | ||
182 | 3531 | |||
183 | 3532 | TESTING: | ||
184 | 3533 | |||
185 | 3534 | INTERNALS: | ||
186 | 3535 | |||
187 | 3536 | * Default User Interface (UI) is CLIUIFactory when bzr runs in a dumb | ||
188 | 3537 | terminal. It is sometimes desirable do override this default by forcing | ||
189 | 3538 | bzr to use TextUIFactory. This can be achieved by setting the | ||
190 | 3539 | BZR_USE_TEXT_UI environment variable (emacs shells, as opposed to | ||
191 | 3540 | compile buffers, are such an example). | ||
192 | 3541 | (Vincent Ladeuil) | ||
193 | 3542 | |||
194 | 3543 | * New API ``Branch.iter_merge_sorted_revisions()`` that iterates over | ||
195 | 3544 | ``(revision_id, depth, revno, end_of_merge)`` tuples. | ||
196 | 3545 | (Ian Clatworthy) | ||
197 | 3546 | |||
198 | 3547 | * New ``Branch.dotted_revno_to_revision_id()`` and | ||
199 | 3548 | ``Branch.revision_id_to_dotted_revno()`` APIs that pick the most | ||
200 | 3549 | efficient way of doing the mapping. | ||
201 | 3550 | (Ian Clatworthy) | ||
202 | 3551 | |||
203 | 3552 | * Refactor cmd_serve so that it's a little easier to build commands that | ||
204 | 3553 | extend it, and perhaps even a bit easier to read. (Jonathan Lange) | ||
205 | 3554 | |||
206 | 3555 | * ``TreeDelta.show()`` now accepts a ``filter`` parameter allowing log | ||
207 | 3556 | formatters to retrict the output. | ||
208 | 3557 | (Vincent Ladeuil) | ||
209 | 3558 | |||
210 | 3559 | |||
211 | 3560 | bzr 1.11 "Eyes up!" 2009-01-19 | ||
212 | 3561 | ------------------------------ | ||
213 | 3562 | >>>>>>> MERGE-SOURCE | ||
214 | 3363 | 3563 | ||
215 | 3364 | This first monthly release of Bazaar for 2009 improves Bazaar's operation | 3564 | This first monthly release of Bazaar for 2009 improves Bazaar's operation |
216 | 3365 | in Windows, Mac OS X, and other situations where file names are matched | 3565 | in Windows, Mac OS X, and other situations where file names are matched |
217 | 3366 | 3566 | ||
218 | === modified file 'bzrlib/builtins.py' | |||
219 | --- bzrlib/builtins.py 2009-12-23 05:42:33 +0000 | |||
220 | +++ bzrlib/builtins.py 2010-01-05 03:39:25 +0000 | |||
221 | @@ -5493,22 +5493,42 @@ | |||
222 | 5493 | that of the master. | 5493 | that of the master. |
223 | 5494 | """ | 5494 | """ |
224 | 5495 | 5495 | ||
226 | 5496 | takes_args = ['to_location'] | 5496 | takes_args = ['to_location?'] |
227 | 5497 | takes_options = [Option('force', | 5497 | takes_options = [Option('force', |
228 | 5498 | <<<<<<< TREE | ||
229 | 5498 | help='Switch even if local commits will be lost.'), | 5499 | help='Switch even if local commits will be lost.'), |
230 | 5499 | Option('create-branch', short_name='b', | 5500 | Option('create-branch', short_name='b', |
231 | 5500 | help='Create the target branch from this one before' | 5501 | help='Create the target branch from this one before' |
232 | 5501 | ' switching to it.'), | 5502 | ' switching to it.'), |
233 | 5503 | ======= | ||
234 | 5504 | help='Switch even if local commits will be lost.'), | ||
235 | 5505 | 'revision' | ||
236 | 5506 | >>>>>>> MERGE-SOURCE | ||
237 | 5502 | ] | 5507 | ] |
238 | 5503 | 5508 | ||
239 | 5509 | <<<<<<< TREE | ||
240 | 5504 | def run(self, to_location, force=False, create_branch=False): | 5510 | def run(self, to_location, force=False, create_branch=False): |
241 | 5511 | ======= | ||
242 | 5512 | def run(self, to_location=None, force=False, revision=None): | ||
243 | 5513 | >>>>>>> MERGE-SOURCE | ||
244 | 5505 | from bzrlib import switch | 5514 | from bzrlib import switch |
245 | 5506 | tree_location = '.' | 5515 | tree_location = '.' |
246 | 5516 | revision = _get_one_revision('switch', revision) | ||
247 | 5507 | control_dir = bzrdir.BzrDir.open_containing(tree_location)[0] | 5517 | control_dir = bzrdir.BzrDir.open_containing(tree_location)[0] |
248 | 5518 | <<<<<<< TREE | ||
249 | 5519 | ======= | ||
250 | 5520 | branch = control_dir.open_branch() | ||
251 | 5521 | if to_location is None: | ||
252 | 5522 | if revision is None: | ||
253 | 5523 | raise errors.BzrCommandError('You must supply either a' | ||
254 | 5524 | ' revision or a location') | ||
255 | 5525 | to_location = '.' | ||
256 | 5526 | >>>>>>> MERGE-SOURCE | ||
257 | 5508 | try: | 5527 | try: |
258 | 5509 | branch = control_dir.open_branch() | 5528 | branch = control_dir.open_branch() |
259 | 5510 | had_explicit_nick = branch.get_config().has_explicit_nickname() | 5529 | had_explicit_nick = branch.get_config().has_explicit_nickname() |
260 | 5511 | except errors.NotBranchError: | 5530 | except errors.NotBranchError: |
261 | 5531 | <<<<<<< TREE | ||
262 | 5512 | branch = None | 5532 | branch = None |
263 | 5513 | had_explicit_nick = False | 5533 | had_explicit_nick = False |
264 | 5514 | if create_branch: | 5534 | if create_branch: |
265 | @@ -5540,6 +5560,20 @@ | |||
266 | 5540 | urlutils.join(this_url, '..', to_location)) | 5560 | urlutils.join(this_url, '..', to_location)) |
267 | 5541 | switch.switch(control_dir, to_branch, force) | 5561 | switch.switch(control_dir, to_branch, force) |
268 | 5542 | if had_explicit_nick: | 5562 | if had_explicit_nick: |
269 | 5563 | ======= | ||
270 | 5564 | this_branch = control_dir.open_branch() | ||
271 | 5565 | # This may be a heavy checkout, where we want the master branch | ||
272 | 5566 | this_url = this_branch.get_bound_location() | ||
273 | 5567 | # If not, use a local sibling | ||
274 | 5568 | if this_url is None: | ||
275 | 5569 | this_url = this_branch.base | ||
276 | 5570 | to_branch = Branch.open( | ||
277 | 5571 | urlutils.join(this_url, '..', to_location)) | ||
278 | 5572 | if revision is not None: | ||
279 | 5573 | revision = revision.as_revision_id(to_branch) | ||
280 | 5574 | switch.switch(control_dir, to_branch, force, revision) | ||
281 | 5575 | if branch.get_config().has_explicit_nickname(): | ||
282 | 5576 | >>>>>>> MERGE-SOURCE | ||
283 | 5543 | branch = control_dir.open_branch() #get the new branch! | 5577 | branch = control_dir.open_branch() #get the new branch! |
284 | 5544 | branch.nick = to_branch.nick | 5578 | branch.nick = to_branch.nick |
285 | 5545 | note('Switched to branch: %s', | 5579 | note('Switched to branch: %s', |
286 | 5546 | 5580 | ||
287 | === modified file 'bzrlib/switch.py' | |||
288 | --- bzrlib/switch.py 2009-06-19 21:16:31 +0000 | |||
289 | +++ bzrlib/switch.py 2010-01-05 03:39:25 +0000 | |||
290 | @@ -22,7 +22,11 @@ | |||
291 | 22 | from bzrlib.trace import note | 22 | from bzrlib.trace import note |
292 | 23 | 23 | ||
293 | 24 | 24 | ||
294 | 25 | <<<<<<< TREE | ||
295 | 25 | def switch(control_dir, to_branch, force=False, quiet=False): | 26 | def switch(control_dir, to_branch, force=False, quiet=False): |
296 | 27 | ======= | ||
297 | 28 | def switch(control_dir, to_branch, force=False, revision_id=None): | ||
298 | 29 | >>>>>>> MERGE-SOURCE | ||
299 | 26 | """Switch the branch associated with a checkout. | 30 | """Switch the branch associated with a checkout. |
300 | 27 | 31 | ||
301 | 28 | :param control_dir: BzrDir of the checkout to change | 32 | :param control_dir: BzrDir of the checkout to change |
302 | @@ -36,7 +40,11 @@ | |||
303 | 36 | source_repository = to_branch.repository | 40 | source_repository = to_branch.repository |
304 | 37 | _set_branch_location(control_dir, to_branch, force) | 41 | _set_branch_location(control_dir, to_branch, force) |
305 | 38 | tree = control_dir.open_workingtree() | 42 | tree = control_dir.open_workingtree() |
306 | 43 | <<<<<<< TREE | ||
307 | 39 | _update(tree, source_repository, quiet) | 44 | _update(tree, source_repository, quiet) |
308 | 45 | ======= | ||
309 | 46 | _update(tree, source_repository, revision_id) | ||
310 | 47 | >>>>>>> MERGE-SOURCE | ||
311 | 40 | 48 | ||
312 | 41 | 49 | ||
313 | 42 | def _check_pending_merges(control, force=False): | 50 | def _check_pending_merges(control, force=False): |
314 | @@ -118,7 +126,11 @@ | |||
315 | 118 | return False | 126 | return False |
316 | 119 | 127 | ||
317 | 120 | 128 | ||
318 | 129 | <<<<<<< TREE | ||
319 | 121 | def _update(tree, source_repository, quiet=False): | 130 | def _update(tree, source_repository, quiet=False): |
320 | 131 | ======= | ||
321 | 132 | def _update(tree, source_repository, revision_id=None): | ||
322 | 133 | >>>>>>> MERGE-SOURCE | ||
323 | 122 | """Update a working tree to the latest revision of its branch. | 134 | """Update a working tree to the latest revision of its branch. |
324 | 123 | 135 | ||
325 | 124 | :param tree: the working tree | 136 | :param tree: the working tree |
326 | @@ -127,14 +139,27 @@ | |||
327 | 127 | tree.lock_tree_write() | 139 | tree.lock_tree_write() |
328 | 128 | try: | 140 | try: |
329 | 129 | to_branch = tree.branch | 141 | to_branch = tree.branch |
330 | 142 | <<<<<<< TREE | ||
331 | 130 | if tree.last_revision() == to_branch.last_revision(): | 143 | if tree.last_revision() == to_branch.last_revision(): |
332 | 131 | if not quiet: | 144 | if not quiet: |
333 | 132 | note("Tree is up to date at revision %d.", to_branch.revno()) | 145 | note("Tree is up to date at revision %d.", to_branch.revno()) |
334 | 146 | ======= | ||
335 | 147 | if revision_id is None: | ||
336 | 148 | revision_id = to_branch.last_revision() | ||
337 | 149 | if tree.last_revision() == revision_id: | ||
338 | 150 | note("Tree is up to date at revision %d.", to_branch.revno()) | ||
339 | 151 | >>>>>>> MERGE-SOURCE | ||
340 | 133 | return | 152 | return |
341 | 134 | base_tree = source_repository.revision_tree(tree.last_revision()) | 153 | base_tree = source_repository.revision_tree(tree.last_revision()) |
342 | 154 | <<<<<<< TREE | ||
343 | 135 | merge.Merge3Merger(tree, tree, base_tree, to_branch.basis_tree()) | 155 | merge.Merge3Merger(tree, tree, base_tree, to_branch.basis_tree()) |
344 | 136 | tree.set_last_revision(to_branch.last_revision()) | 156 | tree.set_last_revision(to_branch.last_revision()) |
345 | 137 | if not quiet: | 157 | if not quiet: |
346 | 138 | note('Updated to revision %d.' % to_branch.revno()) | 158 | note('Updated to revision %d.' % to_branch.revno()) |
347 | 159 | ======= | ||
348 | 160 | merge.Merge3Merger(tree, tree, base_tree, to_branch.repository.revision_tree(revision_id)) | ||
349 | 161 | tree.set_last_revision(revision_id) | ||
350 | 162 | note('Updated to revision %d.' % to_branch.revno()) | ||
351 | 163 | >>>>>>> MERGE-SOURCE | ||
352 | 139 | finally: | 164 | finally: |
353 | 140 | tree.unlock() | 165 | tree.unlock() |
354 | 141 | 166 | ||
355 | === modified file 'bzrlib/tests/blackbox/test_switch.py' | |||
356 | --- bzrlib/tests/blackbox/test_switch.py 2009-12-11 17:04:09 +0000 | |||
357 | +++ bzrlib/tests/blackbox/test_switch.py 2010-01-05 03:39:25 +0000 | |||
358 | @@ -27,6 +27,15 @@ | |||
359 | 27 | 27 | ||
360 | 28 | class TestSwitch(ExternalBase): | 28 | class TestSwitch(ExternalBase): |
361 | 29 | 29 | ||
362 | 30 | def _create_sample_tree(self): | ||
363 | 31 | tree = self.make_branch_and_tree('branch-1') | ||
364 | 32 | self.build_tree(['branch-1/file-1', 'branch-1/file-2']) | ||
365 | 33 | tree.add('file-1') | ||
366 | 34 | tree.commit('rev1') | ||
367 | 35 | tree.add('file-2') | ||
368 | 36 | tree.commit('rev2') | ||
369 | 37 | return tree | ||
370 | 38 | |||
371 | 30 | def test_switch_up_to_date_light_checkout(self): | 39 | def test_switch_up_to_date_light_checkout(self): |
372 | 31 | self.make_branch_and_tree('branch') | 40 | self.make_branch_and_tree('branch') |
373 | 32 | self.run_bzr('branch branch branch2') | 41 | self.run_bzr('branch branch branch2') |
374 | @@ -134,6 +143,7 @@ | |||
375 | 134 | self.run_bzr(['switch', 'branchb'], working_dir='heavyco/a') | 143 | self.run_bzr(['switch', 'branchb'], working_dir='heavyco/a') |
376 | 135 | self.assertEqual(branchb_id, checkout.last_revision()) | 144 | self.assertEqual(branchb_id, checkout.last_revision()) |
377 | 136 | self.assertEqual(tree2.branch.base, checkout.branch.get_bound_location()) | 145 | self.assertEqual(tree2.branch.base, checkout.branch.get_bound_location()) |
378 | 146 | <<<<<<< TREE | ||
379 | 137 | 147 | ||
380 | 138 | def prepare_lightweight_switch(self): | 148 | def prepare_lightweight_switch(self): |
381 | 139 | branch = self.make_branch('branch') | 149 | branch = self.make_branch('branch') |
382 | @@ -197,3 +207,25 @@ | |||
383 | 197 | tree = WorkingTree.open('tree') | 207 | tree = WorkingTree.open('tree') |
384 | 198 | self.assertEndsWith(tree.branch.base, 'foo-branch2/') | 208 | self.assertEndsWith(tree.branch.base, 'foo-branch2/') |
385 | 199 | 209 | ||
386 | 210 | ======= | ||
387 | 211 | |||
388 | 212 | def test_switch_revision(self): | ||
389 | 213 | tree = self._create_sample_tree() | ||
390 | 214 | checkout = tree.branch.create_checkout('checkout', lightweight=True) | ||
391 | 215 | self.run_bzr(['switch', 'branch-1', '-r1'], working_dir='checkout') | ||
392 | 216 | self.failUnlessExists('checkout/file-1') | ||
393 | 217 | self.failIfExists('checkout/file-2') | ||
394 | 218 | |||
395 | 219 | def test_switch_only_revision(self): | ||
396 | 220 | tree = self._create_sample_tree() | ||
397 | 221 | checkout = tree.branch.create_checkout('checkout', lightweight=True) | ||
398 | 222 | self.failUnlessExists('checkout/file-1') | ||
399 | 223 | self.failUnlessExists('checkout/file-2') | ||
400 | 224 | self.run_bzr(['switch', '-r1'], working_dir='checkout') | ||
401 | 225 | self.failUnlessExists('checkout/file-1') | ||
402 | 226 | self.failIfExists('checkout/file-2') | ||
403 | 227 | # Check that we don't accept a range | ||
404 | 228 | self.run_bzr_error( | ||
405 | 229 | ['bzr switch --revision takes exactly one revision identifier'], | ||
406 | 230 | ['switch', '-r0..2'], working_dir='checkout') | ||
407 | 231 | >>>>>>> MERGE-SOURCE | ||
408 | 200 | 232 | ||
409 | === modified file 'bzrlib/tests/test_switch.py' | |||
410 | --- bzrlib/tests/test_switch.py 2009-05-07 05:08:46 +0000 | |||
411 | +++ bzrlib/tests/test_switch.py 2010-01-05 03:39:25 +0000 | |||
412 | @@ -100,6 +100,23 @@ | |||
413 | 100 | self.assertContainsRe(str(err), | 100 | self.assertContainsRe(str(err), |
414 | 101 | "Pending merges must be committed or reverted before using switch") | 101 | "Pending merges must be committed or reverted before using switch") |
415 | 102 | 102 | ||
416 | 103 | def test_switch_with_revision(self): | ||
417 | 104 | """Test switch when a revision is given.""" | ||
418 | 105 | # Create a tree with 2 revisions | ||
419 | 106 | tree = self.make_branch_and_tree('branch-1') | ||
420 | 107 | self.build_tree(['branch-1/file-1']) | ||
421 | 108 | tree.add('file-1') | ||
422 | 109 | tree.commit(rev_id='rev1', message='rev1') | ||
423 | 110 | self.build_tree(['branch-1/file-2']) | ||
424 | 111 | tree.add('file-2') | ||
425 | 112 | tree.commit(rev_id='rev2', message='rev2') | ||
426 | 113 | # Check it out and switch to revision 1 | ||
427 | 114 | checkout = tree.branch.create_checkout('checkout', | ||
428 | 115 | lightweight=self.lightweight) | ||
429 | 116 | switch.switch(checkout.bzrdir, tree.branch, revision_id="rev1") | ||
430 | 117 | self.failUnlessExists('checkout/file-1') | ||
431 | 118 | self.failIfExists('checkout/file-2') | ||
432 | 119 | |||
433 | 103 | 120 | ||
434 | 104 | class TestSwitchHeavyweight(TestSwitch): | 121 | class TestSwitchHeavyweight(TestSwitch): |
435 | 105 | 122 |
Fix for https:/ /bugs.edge. launchpad. net/bzr/ +bug/183559 adding "switch -r".
I haven't read it yet but it would be good for someone to review it and if necessary pick it up.