~spiv/ubuntu/lucid/bzr-loom/test-ppa

« back to all changes in this revision

Viewing changes to commands.py

  • Committer: Robert Collins
  • Date: 2008-11-17 00:58:00 UTC
  • mfrom: (86.1.18 loom)
  • Revision ID: robertc@robertcollins.net-20081117005800-284m5e4d2hunwpxd
Merge Aaron test fixes, support for stacking, and disabling of down-thread-with-changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
275
275
 
276
276
class cmd_down_thread(bzrlib.commands.Command):
277
277
    """Move the branch down a thread in the loom.
278
 
    
 
278
 
279
279
    This removes the changes introduced by the current thread from the branch
280
280
    and sets the branch to be the next thread down.
 
281
 
 
282
    Down-thread refuses to operate if there are uncommitted changes, since
 
283
    this is typically a mistake.  Switch can be used for this purpose, instead.
281
284
    """
282
285
 
283
286
    takes_args = ['thread?']
 
287
    _see_also = ['switch']
284
288
 
285
289
    def run(self, thread=None):
286
 
        (tree, path) = workingtree.WorkingTree.open_containing('.')
287
 
        branch.require_loom_branch(tree.branch)
288
 
        tree = LoomTreeDecorator(tree)
289
 
        return tree.down_thread(thread)
 
290
        (wt, path) = workingtree.WorkingTree.open_containing('.')
 
291
        branch.require_loom_branch(wt.branch)
 
292
        tree = LoomTreeDecorator(wt)
 
293
        tree.lock_write()
 
294
        try:
 
295
            basis = wt.basis_tree()
 
296
            basis.lock_read()
 
297
            try:
 
298
                for change in wt.iter_changes(basis):
 
299
                    raise errors.BzrCommandError(
 
300
                        'Working tree has uncommitted changes.')
 
301
            finally:
 
302
                basis.unlock()
 
303
            return tree.down_thread(thread)
 
304
        finally:
 
305
            tree.unlock()
290
306
 
291
307
 
292
308
class cmd_up_thread(bzrlib.commands.Command):
297
313
    that thread.
298
314
    """
299
315
 
300
 
    takes_options = ['merge-type']
 
316
    takes_options = ['merge-type', Option('auto',
 
317
        help='Automatically commit and merge repeatedly.')]
301
318
 
302
 
    def run(self, merge_type=None):
 
319
    def run(self, merge_type=None, auto=False):
303
320
        (tree, path) = workingtree.WorkingTree.open_containing('.')
304
321
        branch.require_loom_branch(tree.branch)
305
322
        tree = LoomTreeDecorator(tree)
306
 
        return tree.up_thread(merge_type)
 
323
        if not auto:
 
324
            return tree.up_thread(merge_type)
 
325
        else:
 
326
            return tree.up_many(merge_type)
307
327
 
308
328
 
309
329
class cmd_export_loom(bzrlib.commands.Command):