485
487
print "Using last location: %s" % stored_loc
486
488
location = stored_loc
487
from branch import find_branch, DivergedBranches
488
br_from = find_branch(location)
489
location = pull_loc(br_from)
490
old_revno = br_to.revno()
489
cache_root = tempfile.mkdtemp()
492
br_to.update_revisions(br_from)
493
except DivergedBranches:
494
raise BzrCommandError("These branches have diverged. Try merge.")
496
merge(('.', -1), ('.', old_revno), check_clean=False)
497
if location != stored_loc:
498
br_to.controlfile("x-pull", "wb").write(location + "\n")
491
from branch import find_cached_branch, DivergedBranches
492
br_from = find_cached_branch(location, cache_root)
493
location = pull_loc(br_from)
494
old_revno = br_to.revno()
496
br_to.update_revisions(br_from)
497
except DivergedBranches:
498
raise BzrCommandError("These branches have diverged."
501
merge(('.', -1), ('.', old_revno), check_clean=False)
502
if location != stored_loc:
503
br_to.controlfile("x-pull", "wb").write(location + "\n")
514
521
def run(self, from_location, to_location=None, revision=None):
516
523
from bzrlib.merge import merge
517
from branch import find_branch, DivergedBranches, NoSuchRevision
524
from branch import find_cached_branch, DivergedBranches, NoSuchRevision
518
525
from shutil import rmtree
520
br_from = find_branch(from_location)
522
if e.errno == errno.ENOENT:
523
raise BzrCommandError('Source location "%s" does not exist.' %
528
if to_location is None:
529
to_location = os.path.basename(from_location.rstrip("/\\"))
532
os.mkdir(to_location)
534
if e.errno == errno.EEXIST:
535
raise BzrCommandError('Target directory "%s" already exists.' %
537
if e.errno == errno.ENOENT:
538
raise BzrCommandError('Parent of "%s" does not exist.' %
542
br_to = Branch(to_location, init=True)
545
br_to.update_revisions(br_from, stop_revision=revision)
546
except NoSuchRevision:
548
msg = "The branch %s has no revision %d." % (from_location,
550
raise BzrCommandError(msg)
551
merge((to_location, -1), (to_location, 0), this_dir=to_location,
552
check_clean=False, ignore_zero=True)
553
from_location = pull_loc(br_from)
554
br_to.controlfile("x-pull", "wb").write(from_location + "\n")
526
from meta_store import CachedStore
528
cache_root = tempfile.mkdtemp()
531
br_from = find_cached_branch(from_location, cache_root)
533
if e.errno == errno.ENOENT:
534
raise BzrCommandError('Source location "%s" does not'
535
' exist.' % to_location)
539
if to_location is None:
540
to_location = os.path.basename(from_location.rstrip("/\\"))
543
os.mkdir(to_location)
545
if e.errno == errno.EEXIST:
546
raise BzrCommandError('Target directory "%s" already'
547
' exists.' % to_location)
548
if e.errno == errno.ENOENT:
549
raise BzrCommandError('Parent of "%s" does not exist.' %
553
br_to = Branch(to_location, init=True)
556
br_to.update_revisions(br_from, stop_revision=revision)
557
except NoSuchRevision:
559
msg = "The branch %s has no revision %d." % (from_location,
561
raise BzrCommandError(msg)
562
merge((to_location, -1), (to_location, 0), this_dir=to_location,
563
check_clean=False, ignore_zero=True)
564
from_location = pull_loc(br_from)
565
br_to.controlfile("x-pull", "wb").write(from_location + "\n")
557
570
def pull_loc(branch):