27
27
from bzrlib.commands import Command, display_command
28
28
from bzrlib.branch import Branch
29
29
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError, NotBranchError
30
from bzrlib.errors import DivergedBranches
30
from bzrlib.errors import DivergedBranches, NoSuchFile, NoWorkingTree
31
31
from bzrlib.option import Option
32
32
from bzrlib.revisionspec import RevisionSpec
33
33
import bzrlib.trace
383
381
location = stored_loc
384
382
br_from = Branch.open(location)
386
br_to.working_tree().pull(br_from, remember, overwrite)
384
br_to.working_tree().pull(br_from, overwrite)
387
385
except DivergedBranches:
388
386
raise BzrCommandError("These branches have diverged."
388
if br_to.get_parent() is None or remember:
389
br_to.set_parent(location)
392
class cmd_push(Command):
393
"""Push this branch into another branch.
395
The remote branch will not have its working tree populated because this
396
is both expensive, and may not be supported on the remote file system.
398
Some smart servers or protocols *may* put the working tree in place.
400
If there is no default push location set, the first push will set it.
401
After that, you can omit the location to use the default. To change the
402
default, use --remember.
404
This command only works on branches that have not diverged. Branches are
405
considered diverged if the branch being pushed to is not an older version
408
If branches have diverged, you can use 'bzr push --overwrite' to replace
409
the other branch completely.
411
If you want to ensure you have the different changes in the other branch,
412
do a merge (see bzr help merge) from the other branch, and commit that
413
before doing a 'push --overwrite'.
415
takes_options = ['remember', 'overwrite',
416
Option('create-prefix',
417
help='Create the path leading up to the branch '
418
'if it does not already exist')]
419
takes_args = ['location?']
421
def run(self, location=None, remember=False, overwrite=False,
422
create_prefix=False):
424
from shutil import rmtree
425
from bzrlib.transport import get_transport
427
br_from = Branch.open_containing('.')[0]
428
stored_loc = br_from.get_push_location()
430
if stored_loc is None:
431
raise BzrCommandError("No push location known or specified.")
433
print "Using saved location: %s" % stored_loc
434
location = stored_loc
436
br_to = Branch.open(location)
437
except NotBranchError:
439
transport = get_transport(location).clone('..')
440
if not create_prefix:
442
transport.mkdir(transport.relpath(location))
444
raise BzrCommandError("Parent directory of %s "
445
"does not exist." % location)
447
current = transport.base
448
needed = [(transport, transport.relpath(location))]
451
transport, relpath = needed[-1]
452
transport.mkdir(relpath)
455
new_transport = transport.clone('..')
456
needed.append((new_transport,
457
new_transport.relpath(transport.base)))
458
if new_transport.base == transport.base:
459
raise BzrCommandError("Could not creeate "
463
br_to = Branch.initialize(location)
465
br_to.pull(br_from, overwrite)
466
except DivergedBranches:
467
raise BzrCommandError("These branches have diverged."
468
" Try a merge then push with overwrite.")
469
if br_from.get_push_location() is None or remember:
470
br_from.set_push_location(location)
392
473
class cmd_branch(Command):
646
728
b, file_list = branch_files(file_list)
647
729
if revision is not None:
648
730
if len(revision) == 1:
649
show_diff(b, revision[0], specific_files=file_list,
650
external_diff_options=diff_options)
731
return show_diff(b, revision[0], specific_files=file_list,
732
external_diff_options=diff_options)
651
733
elif len(revision) == 2:
652
show_diff(b, revision[0], specific_files=file_list,
653
external_diff_options=diff_options,
654
revision2=revision[1])
734
return show_diff(b, revision[0], specific_files=file_list,
735
external_diff_options=diff_options,
736
revision2=revision[1])
656
738
raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
658
show_diff(b, None, specific_files=file_list,
659
external_diff_options=diff_options)
740
return show_diff(b, None, specific_files=file_list,
741
external_diff_options=diff_options)
664
744
class cmd_deleted(Command):