28
28
from bzrlib.branch import Branch
29
29
from bzrlib.revision import common_ancestor
30
30
from bzrlib.errors import (BzrError, BzrCheckError, BzrCommandError,
31
NotBranchError, DivergedBranches, NotConflicted)
31
NotBranchError, DivergedBranches, NotConflicted,
32
NoSuchFile, NoWorkingTree)
32
33
from bzrlib.option import Option
33
34
from bzrlib.revisionspec import RevisionSpec
34
35
import bzrlib.trace
384
383
location = stored_loc
385
384
br_from = Branch.open(location)
387
br_to.working_tree().pull(br_from, remember, overwrite)
386
br_to.working_tree().pull(br_from, overwrite)
388
387
except DivergedBranches:
389
388
raise BzrCommandError("These branches have diverged."
390
if br_to.get_parent() is None or remember:
391
br_to.set_parent(location)
394
class cmd_push(Command):
395
"""Push this branch into another branch.
397
The remote branch will not have its working tree populated because this
398
is both expensive, and may not be supported on the remote file system.
400
Some smart servers or protocols *may* put the working tree in place.
402
If there is no default push location set, the first push will set it.
403
After that, you can omit the location to use the default. To change the
404
default, use --remember.
406
This command only works on branches that have not diverged. Branches are
407
considered diverged if the branch being pushed to is not an older version
410
If branches have diverged, you can use 'bzr push --overwrite' to replace
411
the other branch completely.
413
If you want to ensure you have the different changes in the other branch,
414
do a merge (see bzr help merge) from the other branch, and commit that
415
before doing a 'push --overwrite'.
417
takes_options = ['remember', 'overwrite',
418
Option('create-prefix',
419
help='Create the path leading up to the branch '
420
'if it does not already exist')]
421
takes_args = ['location?']
423
def run(self, location=None, remember=False, overwrite=False,
424
create_prefix=False):
426
from shutil import rmtree
427
from bzrlib.transport import get_transport
429
br_from = Branch.open_containing('.')[0]
430
stored_loc = br_from.get_push_location()
432
if stored_loc is None:
433
raise BzrCommandError("No push location known or specified.")
435
print "Using saved location: %s" % stored_loc
436
location = stored_loc
438
br_to = Branch.open(location)
439
except NotBranchError:
441
transport = get_transport(location).clone('..')
442
if not create_prefix:
444
transport.mkdir(transport.relpath(location))
446
raise BzrCommandError("Parent directory of %s "
447
"does not exist." % location)
449
current = transport.base
450
needed = [(transport, transport.relpath(location))]
453
transport, relpath = needed[-1]
454
transport.mkdir(relpath)
457
new_transport = transport.clone('..')
458
needed.append((new_transport,
459
new_transport.relpath(transport.base)))
460
if new_transport.base == transport.base:
461
raise BzrCommandError("Could not creeate "
465
br_to = Branch.initialize(location)
467
br_to.pull(br_from, overwrite)
468
except DivergedBranches:
469
raise BzrCommandError("These branches have diverged."
470
" Try a merge then push with overwrite.")
471
if br_from.get_push_location() is None or remember:
472
br_from.set_push_location(location)
393
475
class cmd_branch(Command):
647
730
b, file_list = branch_files(file_list)
648
731
if revision is not None:
649
732
if len(revision) == 1:
650
show_diff(b, revision[0], specific_files=file_list,
651
external_diff_options=diff_options)
733
return show_diff(b, revision[0], specific_files=file_list,
734
external_diff_options=diff_options)
652
735
elif len(revision) == 2:
653
show_diff(b, revision[0], specific_files=file_list,
654
external_diff_options=diff_options,
655
revision2=revision[1])
736
return show_diff(b, revision[0], specific_files=file_list,
737
external_diff_options=diff_options,
738
revision2=revision[1])
657
740
raise BzrCommandError('bzr diff --revision takes exactly one or two revision identifiers')
659
show_diff(b, None, specific_files=file_list,
660
external_diff_options=diff_options)
742
return show_diff(b, None, specific_files=file_list,
743
external_diff_options=diff_options)
665
746
class cmd_deleted(Command):