21
from warnings import warn
22
25
from bzrlib.trace import mutter, note
23
from bzrlib.osutils import isdir, quotefn, compact_date, rand_bytes, \
25
sha_file, appendpath, file_kind
27
from bzrlib.errors import BzrError, InvalidRevisionNumber, InvalidRevisionId
26
from bzrlib.osutils import (isdir, quotefn, compact_date, rand_bytes,
27
rename, splitpath, sha_file, appendpath,
29
from bzrlib.errors import (BzrError, InvalidRevisionNumber, InvalidRevisionId,
30
NoSuchRevision, HistoryMissing, NotBranchError,
31
DivergedBranches, LockError, UnlistableStore,
29
33
from bzrlib.textui import show_status
30
from bzrlib.revision import Revision
31
from bzrlib.xml import unpack_xml
34
from bzrlib.revision import Revision, validate_revision_id, is_ancestor
32
35
from bzrlib.delta import compare_trees
33
36
from bzrlib.tree import EmptyTree, RevisionTree
37
from bzrlib.inventory import Inventory
38
from bzrlib.weavestore import WeaveStore
39
from bzrlib.store import copy_all, ImmutableStore
38
BZR_BRANCH_FORMAT = "Bazaar-NG branch, format 0.0.4\n"
44
BZR_BRANCH_FORMAT_4 = "Bazaar-NG branch, format 0.0.4\n"
45
BZR_BRANCH_FORMAT_5 = "Bazaar-NG branch, format 5\n"
39
46
## TODO: Maybe include checks for common corruption of newlines, etc?
42
49
# TODO: Some operations like log might retrieve the same revisions
43
50
# repeatedly to calculate deltas. We could perhaps have a weakref
44
# cache in memory to make this faster.
46
# TODO: please move the revision-string syntax stuff out of the branch
47
# object; it's clutter
50
def find_branch(f, **args):
51
if f and (f.startswith('http://') or f.startswith('https://')):
53
return remotebranch.RemoteBranch(f, **args)
55
return Branch(f, **args)
58
def find_cached_branch(f, cache_root, **args):
59
from remotebranch import RemoteBranch
60
br = find_branch(f, **args)
61
def cacheify(br, store_name):
62
from meta_store import CachedStore
63
cache_path = os.path.join(cache_root, store_name)
65
new_store = CachedStore(getattr(br, store_name), cache_path)
66
setattr(br, store_name, new_store)
68
if isinstance(br, RemoteBranch):
69
cacheify(br, 'inventory_store')
70
cacheify(br, 'text_store')
71
cacheify(br, 'revision_store')
51
# cache in memory to make this faster. In general anything can be
52
# cached in memory between lock and unlock operations.
54
def find_branch(*ignored, **ignored_too):
55
# XXX: leave this here for about one release, then remove it
56
raise NotImplementedError('find_branch() is not supported anymore, '
57
'please use one of the new branch constructors')
75
59
def _relpath(base, path):
76
60
"""Return path relative to base, or raise exception.
148
124
"""Branch holding a history of revisions.
151
Base directory of the branch.
127
Base directory/url of the branch.
131
def __init__(self, *ignored, **ignored_too):
132
raise NotImplementedError('The Branch class is abstract')
135
def open_downlevel(base):
136
"""Open a branch which may be of an old format.
138
Only local branches are supported."""
139
return LocalBranch(base, find_root=False, relax_version_check=True)
143
"""Open an existing branch, rooted at 'base' (url)"""
144
if base and (base.startswith('http://') or base.startswith('https://')):
145
from bzrlib.remotebranch import RemoteBranch
146
return RemoteBranch(base, find_root=False)
148
return LocalBranch(base, find_root=False)
151
def open_containing(url):
152
"""Open an existing branch which contains url.
154
This probes for a branch at url, and searches upwards from there.
156
if url and (url.startswith('http://') or url.startswith('https://')):
157
from bzrlib.remotebranch import RemoteBranch
158
return RemoteBranch(url)
160
return LocalBranch(url)
163
def initialize(base):
164
"""Create a new branch, rooted at 'base' (url)"""
165
if base and (base.startswith('http://') or base.startswith('https://')):
166
from bzrlib.remotebranch import RemoteBranch
167
return RemoteBranch(base, init=True)
169
return LocalBranch(base, init=True)
171
def setup_caching(self, cache_root):
172
"""Subclasses that care about caching should override this, and set
173
up cached stores located under cache_root.
177
class LocalBranch(Branch):
178
"""A branch stored in the actual filesystem.
180
Note that it's "local" in the context of the filesystem; it doesn't
181
really matter if it's on an nfs/smb/afs/coda/... share, as long as
182
it's writable, and can be accessed via the normal filesystem API.
154
185
None, or 'r' or 'w'
161
192
Lock object from bzrlib.lock.
194
# We actually expect this class to be somewhat short-lived; part of its
195
# purpose is to try to isolate what bits of the branch logic are tied to
196
# filesystem access, so that in a later step, we can extricate them to
197
# a separarte ("storage") class.
164
198
_lock_mode = None
165
199
_lock_count = None
201
_inventory_weave = None
168
203
# Map some sort of prefix into a namespace
169
204
# stuff like "revno:10", "revid:", etc.
170
205
# This should match a prefix with a function which accepts
171
206
REVISION_NAMESPACES = {}
173
def __init__(self, base, init=False, find_root=True):
208
def push_stores(self, branch_to):
209
"""Copy the content of this branches store to branch_to."""
210
if (self._branch_format != branch_to._branch_format
211
or self._branch_format != 4):
212
from bzrlib.fetch import greedy_fetch
213
mutter("falling back to fetch logic to push between %s(%s) and %s(%s)",
214
self, self._branch_format, branch_to, branch_to._branch_format)
215
greedy_fetch(to_branch=branch_to, from_branch=self,
216
revision=self.last_revision())
219
store_pairs = ((self.text_store, branch_to.text_store),
220
(self.inventory_store, branch_to.inventory_store),
221
(self.revision_store, branch_to.revision_store))
223
for from_store, to_store in store_pairs:
224
copy_all(from_store, to_store)
225
except UnlistableStore:
226
raise UnlistableBranch(from_store)
228
def __init__(self, base, init=False, find_root=True,
229
relax_version_check=False):
174
230
"""Create new branch object at a particular location.
176
base -- Base directory for the branch.
232
base -- Base directory for the branch. May be a file:// url.
178
234
init -- If True, create new control files in a previously
179
235
unversioned directory. If False, the branch must already
182
238
find_root -- If true and init is false, find the root of the
183
239
existing branch containing base.
241
relax_version_check -- If true, the usual check for the branch
242
version is not applied. This is intended only for
243
upgrade/recovery type use; it's not guaranteed that
244
all operations will work on old format branches.
185
246
In the test suite, creation of new trees is tested using the
186
247
`ScratchBranch` class.
188
from bzrlib.store import ImmutableStore
190
250
self.base = os.path.realpath(base)
191
251
self._make_control()
193
253
self.base = find_branch_root(base)
255
if base.startswith("file://"):
195
257
self.base = os.path.realpath(base)
196
258
if not isdir(self.controlfilename('.')):
197
from errors import NotBranchError
198
raise NotBranchError("not a bzr branch: %s" % quotefn(base),
199
['use "bzr init" to initialize a new working tree',
200
'current bzr can only operate from top-of-tree'])
203
self.text_store = ImmutableStore(self.controlfilename('text-store'))
204
self.revision_store = ImmutableStore(self.controlfilename('revision-store'))
205
self.inventory_store = ImmutableStore(self.controlfilename('inventory-store'))
259
raise NotBranchError('not a bzr branch: %s' % quotefn(base),
260
['use "bzr init" to initialize a '
262
self._check_format(relax_version_check)
263
cfn = self.controlfilename
264
if self._branch_format == 4:
265
self.inventory_store = ImmutableStore(cfn('inventory-store'))
266
self.text_store = ImmutableStore(cfn('text-store'))
267
elif self._branch_format == 5:
268
self.control_weaves = WeaveStore(cfn([]))
269
self.weave_store = WeaveStore(cfn('weaves'))
271
# FIXME: Unify with make_control_files
272
self.control_weaves.put_empty_weave('inventory')
273
self.control_weaves.put_empty_weave('ancestry')
274
self.revision_store = ImmutableStore(cfn('revision-store'))
208
277
def __str__(self):
301
368
raise BzrError("invalid controlfile mode %r" % mode)
303
370
def _make_control(self):
304
from bzrlib.inventory import Inventory
305
from bzrlib.xml import pack_xml
307
371
os.mkdir(self.controlfilename([]))
308
372
self.controlfile('README', 'w').write(
309
373
"This is a Bazaar-NG control directory.\n"
310
374
"Do not change any files in this directory.\n")
311
self.controlfile('branch-format', 'w').write(BZR_BRANCH_FORMAT)
312
for d in ('text-store', 'inventory-store', 'revision-store'):
375
self.controlfile('branch-format', 'w').write(BZR_BRANCH_FORMAT_5)
376
for d in ('text-store', 'revision-store',
313
378
os.mkdir(self.controlfilename(d))
314
for f in ('revision-history', 'merged-patches',
315
'pending-merged-patches', 'branch-name',
379
for f in ('revision-history',
317
382
'pending-merges'):
318
383
self.controlfile(f, 'w').write('')
321
386
# if we want per-tree root ids then this is the place to set
322
387
# them; they're not needed for now and so ommitted for
324
pack_xml(Inventory(), self.controlfile('inventory','w'))
326
def _check_format(self):
389
f = self.controlfile('inventory','w')
390
bzrlib.xml5.serializer_v5.write_inventory(Inventory(), f)
393
def _check_format(self, relax_version_check):
327
394
"""Check this branch format is supported.
329
The current tool only supports the current unstable format.
396
The format level is stored, as an integer, in
397
self._branch_format for code that needs to check it later.
331
399
In the future, we might need different in-memory Branch
332
400
classes to support downlevel branches. But not yet.
334
# This ignores newlines so that we can open branches created
335
# on Windows from Linux and so on. I think it might be better
336
# to always make all internal files in unix format.
337
fmt = self.controlfile('branch-format', 'r').read()
338
fmt.replace('\r\n', '')
339
if fmt != BZR_BRANCH_FORMAT:
403
fmt = self.controlfile('branch-format', 'r').read()
405
if e.errno == errno.ENOENT:
406
raise NotBranchError(self.base)
410
if fmt == BZR_BRANCH_FORMAT_5:
411
self._branch_format = 5
412
elif fmt == BZR_BRANCH_FORMAT_4:
413
self._branch_format = 4
415
if (not relax_version_check
416
and self._branch_format != 5):
340
417
raise BzrError('sorry, branch format %r not supported' % fmt,
341
418
['use a different bzr version',
342
419
'or remove the .bzr directory and "bzr init" again'])
633
715
return compare_trees(old_tree, new_tree)
637
718
def get_revision_sha1(self, revision_id):
638
719
"""Hash the stored value of a revision, and return it."""
639
# In the future, revision entries will be signed. At that
640
# point, it is probably best *not* to include the signature
641
# in the revision hash. Because that lets you re-sign
642
# the revision, (add signatures/remove signatures) and still
643
# have all hash pointers stay consistent.
644
# But for now, just hash the contents.
645
return bzrlib.osutils.sha_file(self.get_revision_xml(revision_id))
648
def get_inventory(self, inventory_id):
649
"""Get Inventory object by hash.
651
TODO: Perhaps for this and similar methods, take a revision
652
parameter which can be either an integer revno or a
654
from bzrlib.inventory import Inventory
655
from bzrlib.xml import unpack_xml
657
return unpack_xml(Inventory, self.get_inventory_xml(inventory_id))
660
def get_inventory_xml(self, inventory_id):
720
return bzrlib.osutils.sha_file(self.get_revision_xml_file(revision_id))
723
def _get_ancestry_weave(self):
724
return self.control_weaves.get_weave('ancestry')
727
def get_ancestry(self, revision_id):
728
"""Return a list of revision-ids integrated by a revision.
731
if revision_id is None:
733
w = self._get_ancestry_weave()
734
return [None] + [l[:-1] for l in w.get_iter(w.lookup(revision_id))]
737
def get_inventory_weave(self):
738
return self.control_weaves.get_weave('inventory')
741
def get_inventory(self, revision_id):
742
"""Get Inventory object by hash."""
743
xml = self.get_inventory_xml(revision_id)
744
return bzrlib.xml5.serializer_v5.read_inventory_from_string(xml)
747
def get_inventory_xml(self, revision_id):
661
748
"""Get inventory XML as a file object."""
662
return self.inventory_store[inventory_id]
665
def get_inventory_sha1(self, inventory_id):
750
assert isinstance(revision_id, basestring), type(revision_id)
751
iw = self.get_inventory_weave()
752
return iw.get_text(iw.lookup(revision_id))
754
raise bzrlib.errors.HistoryMissing(self, 'inventory', revision_id)
757
def get_inventory_sha1(self, revision_id):
666
758
"""Return the sha1 hash of the inventory entry
668
return sha_file(self.get_inventory_xml(inventory_id))
760
return self.get_revision(revision_id).inventory_sha1
671
763
def get_revision_inventory(self, revision_id):
672
764
"""Return inventory of a past revision."""
673
# bzr 0.0.6 imposes the constraint that the inventory_id
765
# TODO: Unify this with get_inventory()
766
# bzr 0.0.6 and later imposes the constraint that the inventory_id
674
767
# must be the same as its revision, so this is trivial.
675
768
if revision_id == None:
676
from bzrlib.inventory import Inventory
677
769
return Inventory(self.get_root_id())
679
771
return self.get_inventory(revision_id)
682
774
def revision_history(self):
683
"""Return sequence of revision hashes on to this branch.
685
>>> ScratchBranch().revision_history()
775
"""Return sequence of revision hashes on to this branch."""
690
778
return [l.rstrip('\r\n') for l in
696
784
def common_ancestor(self, other, self_revno=None, other_revno=None):
786
>>> from bzrlib.commit import commit
699
787
>>> sb = ScratchBranch(files=['foo', 'foo~'])
700
788
>>> sb.common_ancestor(sb) == (None, None)
702
>>> commit.commit(sb, "Committing first revision", verbose=False)
790
>>> commit(sb, "Committing first revision", verbose=False)
703
791
>>> sb.common_ancestor(sb)[0]
705
793
>>> clone = sb.clone()
706
>>> commit.commit(sb, "Committing second revision", verbose=False)
794
>>> commit(sb, "Committing second revision", verbose=False)
707
795
>>> sb.common_ancestor(sb)[0]
709
797
>>> sb.common_ancestor(clone)[0]
711
>>> commit.commit(clone, "Committing divergent second revision",
799
>>> commit(clone, "Committing divergent second revision",
712
800
... verbose=False)
713
801
>>> sb.common_ancestor(clone)[0]
796
888
if stop_revision is None:
797
889
stop_revision = other_len
798
elif stop_revision > other_len:
799
raise bzrlib.errors.NoSuchRevision(self, stop_revision)
891
assert isinstance(stop_revision, int)
892
if stop_revision > other_len:
893
raise bzrlib.errors.NoSuchRevision(self, stop_revision)
801
894
return other_history[self_len:stop_revision]
804
896
def update_revisions(self, other, stop_revision=None):
805
"""Pull in all new revisions from other branch.
897
"""Pull in new perfect-fit revisions."""
807
898
from bzrlib.fetch import greedy_fetch
809
pb = bzrlib.ui.ui_factory.progress_bar()
810
pb.update('comparing histories')
812
revision_ids = self.missing_revisions(other, stop_revision)
814
if len(revision_ids) > 0:
815
count = greedy_fetch(self, other, revision_ids[-1], pb)[0]
818
self.append_revision(*revision_ids)
819
## note("Added %d revisions." % count)
822
def install_revisions(self, other, revision_ids, pb):
823
if hasattr(other.revision_store, "prefetch"):
824
other.revision_store.prefetch(revision_ids)
825
if hasattr(other.inventory_store, "prefetch"):
826
inventory_ids = [other.get_revision(r).inventory_id
827
for r in revision_ids]
828
other.inventory_store.prefetch(inventory_ids)
831
pb = bzrlib.ui.ui_factory.progress_bar()
838
for i, rev_id in enumerate(revision_ids):
839
pb.update('fetching revision', i+1, len(revision_ids))
841
rev = other.get_revision(rev_id)
842
except bzrlib.errors.NoSuchRevision:
846
revisions.append(rev)
847
inv = other.get_inventory(str(rev.inventory_id))
848
for key, entry in inv.iter_entries():
849
if entry.text_id is None:
851
if entry.text_id not in self.text_store:
852
needed_texts.add(entry.text_id)
856
count, cp_fail = self.text_store.copy_multi(other.text_store,
858
#print "Added %d texts." % count
859
inventory_ids = [ f.inventory_id for f in revisions ]
860
count, cp_fail = self.inventory_store.copy_multi(other.inventory_store,
862
#print "Added %d inventories." % count
863
revision_ids = [ f.revision_id for f in revisions]
865
count, cp_fail = self.revision_store.copy_multi(other.revision_store,
868
assert len(cp_fail) == 0
869
return count, failures
899
from bzrlib.revision import get_intervening_revisions
900
if stop_revision is None:
901
stop_revision = other.last_revision()
902
greedy_fetch(to_branch=self, from_branch=other,
903
revision=stop_revision)
904
pullable_revs = self.missing_revisions(
905
other, other.revision_id_to_revno(stop_revision))
907
greedy_fetch(to_branch=self,
909
revision=pullable_revs[-1])
910
self.append_revision(*pullable_revs)
872
913
def commit(self, *args, **kw):
873
from bzrlib.commit import commit
874
commit(self, *args, **kw)
877
def lookup_revision(self, revision):
878
"""Return the revision identifier for a given revision information."""
879
revno, info = self._get_revision_info(revision)
914
from bzrlib.commit import Commit
915
Commit().commit(self, *args, **kw)
883
917
def revision_id_to_revno(self, revision_id):
884
918
"""Given a revision id, return its revno"""
919
if revision_id is None:
885
921
history = self.revision_history()
887
923
return history.index(revision_id) + 1
888
924
except ValueError:
889
925
raise bzrlib.errors.NoSuchRevision(self, revision_id)
892
def get_revision_info(self, revision):
893
"""Return (revno, revision id) for revision identifier.
895
revision can be an integer, in which case it is assumed to be revno (though
896
this will translate negative values into positive ones)
897
revision can also be a string, in which case it is parsed for something like
898
'date:' or 'revid:' etc.
900
revno, rev_id = self._get_revision_info(revision)
902
raise bzrlib.errors.NoSuchRevision(self, revision)
905
927
def get_rev_id(self, revno, history=None):
906
928
"""Find the revision id of the specified revno."""
912
934
raise bzrlib.errors.NoSuchRevision(self, revno)
913
935
return history[revno - 1]
915
def _get_revision_info(self, revision):
916
"""Return (revno, revision id) for revision specifier.
918
revision can be an integer, in which case it is assumed to be revno
919
(though this will translate negative values into positive ones)
920
revision can also be a string, in which case it is parsed for something
921
like 'date:' or 'revid:' etc.
923
A revid is always returned. If it is None, the specifier referred to
924
the null revision. If the revid does not occur in the revision
925
history, revno will be None.
931
try:# Convert to int if possible
932
revision = int(revision)
935
revs = self.revision_history()
936
if isinstance(revision, int):
938
revno = len(revs) + revision + 1
941
rev_id = self.get_rev_id(revno, revs)
942
elif isinstance(revision, basestring):
943
for prefix, func in Branch.REVISION_NAMESPACES.iteritems():
944
if revision.startswith(prefix):
945
result = func(self, revs, revision)
947
revno, rev_id = result
950
rev_id = self.get_rev_id(revno, revs)
953
raise BzrError('No namespace registered for string: %r' %
956
raise TypeError('Unhandled revision type %s' % revision)
960
raise bzrlib.errors.NoSuchRevision(self, revision)
963
def _namespace_revno(self, revs, revision):
964
"""Lookup a revision by revision number"""
965
assert revision.startswith('revno:')
967
return (int(revision[6:]),)
970
REVISION_NAMESPACES['revno:'] = _namespace_revno
972
def _namespace_revid(self, revs, revision):
973
assert revision.startswith('revid:')
974
rev_id = revision[len('revid:'):]
976
return revs.index(rev_id) + 1, rev_id
979
REVISION_NAMESPACES['revid:'] = _namespace_revid
981
def _namespace_last(self, revs, revision):
982
assert revision.startswith('last:')
984
offset = int(revision[5:])
989
raise BzrError('You must supply a positive value for --revision last:XXX')
990
return (len(revs) - offset + 1,)
991
REVISION_NAMESPACES['last:'] = _namespace_last
993
def _namespace_tag(self, revs, revision):
994
assert revision.startswith('tag:')
995
raise BzrError('tag: namespace registered, but not implemented.')
996
REVISION_NAMESPACES['tag:'] = _namespace_tag
998
def _namespace_date(self, revs, revision):
999
assert revision.startswith('date:')
1001
# Spec for date revisions:
1003
# value can be 'yesterday', 'today', 'tomorrow' or a YYYY-MM-DD string.
1004
# it can also start with a '+/-/='. '+' says match the first
1005
# entry after the given date. '-' is match the first entry before the date
1006
# '=' is match the first entry after, but still on the given date.
1008
# +2005-05-12 says find the first matching entry after May 12th, 2005 at 0:00
1009
# -2005-05-12 says find the first matching entry before May 12th, 2005 at 0:00
1010
# =2005-05-12 says find the first match after May 12th, 2005 at 0:00 but before
1011
# May 13th, 2005 at 0:00
1013
# So the proper way of saying 'give me all entries for today' is:
1014
# -r {date:+today}:{date:-tomorrow}
1015
# The default is '=' when not supplied
1018
if val[:1] in ('+', '-', '='):
1019
match_style = val[:1]
1022
today = datetime.datetime.today().replace(hour=0,minute=0,second=0,microsecond=0)
1023
if val.lower() == 'yesterday':
1024
dt = today - datetime.timedelta(days=1)
1025
elif val.lower() == 'today':
1027
elif val.lower() == 'tomorrow':
1028
dt = today + datetime.timedelta(days=1)
1031
# This should be done outside the function to avoid recompiling it.
1032
_date_re = re.compile(
1033
r'(?P<date>(?P<year>\d\d\d\d)-(?P<month>\d\d)-(?P<day>\d\d))?'
1035
r'(?P<time>(?P<hour>\d\d):(?P<minute>\d\d)(:(?P<second>\d\d))?)?'
1037
m = _date_re.match(val)
1038
if not m or (not m.group('date') and not m.group('time')):
1039
raise BzrError('Invalid revision date %r' % revision)
1042
year, month, day = int(m.group('year')), int(m.group('month')), int(m.group('day'))
1044
year, month, day = today.year, today.month, today.day
1046
hour = int(m.group('hour'))
1047
minute = int(m.group('minute'))
1048
if m.group('second'):
1049
second = int(m.group('second'))
1053
hour, minute, second = 0,0,0
1055
dt = datetime.datetime(year=year, month=month, day=day,
1056
hour=hour, minute=minute, second=second)
1060
if match_style == '-':
1062
elif match_style == '=':
1063
last = dt + datetime.timedelta(days=1)
1066
for i in range(len(revs)-1, -1, -1):
1067
r = self.get_revision(revs[i])
1068
# TODO: Handle timezone.
1069
dt = datetime.datetime.fromtimestamp(r.timestamp)
1070
if first >= dt and (last is None or dt >= last):
1073
for i in range(len(revs)):
1074
r = self.get_revision(revs[i])
1075
# TODO: Handle timezone.
1076
dt = datetime.datetime.fromtimestamp(r.timestamp)
1077
if first <= dt and (last is None or dt <= last):
1079
REVISION_NAMESPACES['date:'] = _namespace_date
1081
937
def revision_tree(self, revision_id):
1082
938
"""Return Tree for a revision on this branch.
1491
1346
return gen_file_id('TREE_ROOT')
1494
def pull_loc(branch):
1495
# TODO: Should perhaps just make attribute be 'base' in
1496
# RemoteBranch and Branch?
1497
if hasattr(branch, "baseurl"):
1498
return branch.baseurl
1503
def copy_branch(branch_from, to_location, revision=None):
1504
"""Copy branch_from into the existing directory to_location.
1507
If not None, only revisions up to this point will be copied.
1508
The head of the new branch will be that revision.
1511
The name of a local directory that exists but is empty.
1513
from bzrlib.merge import merge
1514
from bzrlib.branch import Branch
1516
assert isinstance(branch_from, Branch)
1517
assert isinstance(to_location, basestring)
1519
br_to = Branch(to_location, init=True)
1520
br_to.set_root_id(branch_from.get_root_id())
1521
if revision is None:
1522
revno = branch_from.revno()
1524
revno, rev_id = branch_from.get_revision_info(revision)
1525
br_to.update_revisions(branch_from, stop_revision=revno)
1526
merge((to_location, -1), (to_location, 0), this_dir=to_location,
1527
check_clean=False, ignore_zero=True)
1529
from_location = pull_loc(branch_from)
1530
br_to.set_parent(pull_loc(branch_from))