107
107
format = bzrdir.BzrDirMetaFormat1()
108
108
format.repository_format = repository.RepositoryFormatKnit1()
110
if typestring == "experimental-knit2":
111
format = bzrdir.BzrDirMetaFormat1()
112
format.repository_format = repository.RepositoryFormatKnit2()
110
114
msg = "Unknown bzr format %s. Current formats are: default, knit,\n" \
111
115
"metaweave and weave" % typestring
112
116
raise BzrCommandError(msg)
760
764
# if the source and to_location are the same,
761
765
# and there is no working tree,
762
766
# then reconstitute a branch
763
if (osutils.abspath(to_location) ==
767
if (osutils.abspath(to_location) ==
764
768
osutils.abspath(branch_location)):
766
770
source.bzrdir.open_workingtree()
823
827
tree = WorkingTree.open_containing(dir)[0]
824
828
tree.lock_write()
826
existing_pending_merges = tree.pending_merges()
830
existing_pending_merges = tree.get_parent_ids()[1:]
827
831
last_rev = tree.last_revision()
828
832
if last_rev == tree.branch.last_revision():
829
833
# may be up to date, check master too.
835
839
conflicts = tree.update()
836
840
revno = tree.branch.revision_id_to_revno(tree.last_revision())
837
841
note('Updated to revision %d.' % (revno,))
838
if tree.pending_merges() != existing_pending_merges:
842
if tree.get_parent_ids()[1:] != existing_pending_merges:
839
843
note('Your local commits will now show as pending merges with '
840
844
"'bzr status', and can be committed with 'bzr commit'.")
841
845
if conflicts != 0:
911
915
def run(self, filename):
912
916
tree, relpath = WorkingTree.open_containing(filename)
913
917
i = tree.inventory.path2id(relpath)
915
919
raise BzrError("%r is not a versioned file" % filename)
917
921
self.outf.write(i + '\n')
932
936
tree, relpath = WorkingTree.open_containing(filename)
933
937
inv = tree.inventory
934
938
fid = inv.path2id(relpath)
936
940
raise BzrError("%r is not a versioned file" % filename)
937
941
for fip in inv.get_idpath(fid):
938
942
self.outf.write(fip + '\n')
996
1000
last_revision = wt.last_revision()
998
1002
revision_ids = b.repository.get_ancestry(last_revision)
999
assert revision_ids[0] == None
1003
assert revision_ids[0] is None
1000
1004
revision_ids.pop(0)
1001
1005
for revision_id in revision_ids:
1002
1006
self.outf.write(revision_id + '\n')
1347
1351
# local dir only
1348
1352
# FIXME ? log the current subdir only RBC 20060203
1349
dir, relpath = bzrdir.BzrDir.open_containing('.')
1353
if revision is not None \
1354
and len(revision) > 0 and revision[0].get_branch():
1355
location = revision[0].get_branch()
1358
dir, relpath = bzrdir.BzrDir.open_containing(location)
1350
1359
b = dir.open_branch()
1352
1361
if revision is None:
1355
1364
elif len(revision) == 1:
1356
1365
rev1 = rev2 = revision[0].in_history(b).revno
1357
1366
elif len(revision) == 2:
1367
if revision[1].get_branch() != revision[0].get_branch():
1368
# b is taken from revision[0].get_branch(), and
1369
# show_log will use its revision_history. Having
1370
# different branches will lead to weird behaviors.
1371
raise BzrCommandError(
1372
"Log doesn't accept two revisions in different branches.")
1358
1373
if revision[0].spec is None:
1359
1374
# missing begin-range means first revision
1375
1390
if rev1 > rev2:
1376
1391
(rev2, rev1) = (rev1, rev2)
1378
if (log_format == None):
1393
if (log_format is None):
1379
1394
default = b.get_config().log_format()
1380
1395
log_format = get_log_format(long=long, short=short, line=line,
1381
1396
default=default)
1649
1664
if tree is None:
1650
1665
b, relpath = Branch.open_containing(filename)
1666
if revision is not None and revision[0].get_branch() is not None:
1667
b = Branch.open(revision[0].get_branch())
1651
1668
if revision is None:
1652
1669
revision_id = b.last_revision()
2136
branch = self._get_remembered_parent(tree, branch, 'Merging from')
2153
if revision is None \
2154
or len(revision) < 1 or revision[0].needs_branch():
2155
branch = self._get_remembered_parent(tree, branch, 'Merging from')
2138
2157
if revision is None or len(revision) < 1:
2139
2158
if uncommitted:
2156
2176
assert len(revision) == 2
2157
2177
if None in revision:
2158
2178
raise BzrCommandError(
2159
"Merge doesn't permit that revision specifier.")
2160
other_branch, path = Branch.open_containing(branch)
2179
"Merge doesn't permit empty revision specifier.")
2180
base_branch, path = Branch.open_containing(branch)
2181
branch1 = revision[1].get_branch() or branch
2182
other_branch, path1 = Branch.open_containing(branch1)
2183
if revision[0].get_branch() is not None:
2184
# then path was obtained from it, and is None.
2162
base = [branch, revision[0].in_history(other_branch).revno]
2163
other = [branch, revision[1].in_history(other_branch).revno]
2187
base = [branch, revision[0].in_history(base_branch).revno]
2188
other = [branch1, revision[1].in_history(other_branch).revno]
2165
2190
if tree.branch.get_parent() is None or remember:
2166
2191
tree.branch.set_parent(other_branch.base)
2425
2450
remote_branch.lock_read()
2427
2452
local_extra, remote_extra = find_unmerged(local_branch, remote_branch)
2428
if (log_format == None):
2453
if (log_format is None):
2429
2454
default = local_branch.get_config().log_format()
2430
2455
log_format = get_log_format(long=long, short=short,
2431
2456
line=line, default=default)
2479
2504
import bzrlib.plugin
2480
2505
from inspect import getdoc
2481
2506
for name, plugin in bzrlib.plugin.all_plugins().items():
2482
if hasattr(plugin, '__path__'):
2507
if getattr(plugin, '__path__', None) is not None:
2483
2508
print plugin.__path__[0]
2484
elif hasattr(plugin, '__file__'):
2509
elif getattr(plugin, '__file__', None) is not None:
2485
2510
print plugin.__file__
2489
2514
d = getdoc(plugin)
2770
class cmd_wait_until_signalled(Command):
2771
"""Test helper for test_start_and_stop_bzr_subprocess_send_signal.
2773
This just prints a line to signal when it is ready, then blocks on stdin.
2779
sys.stdout.write("running\n")
2781
sys.stdin.readline()
2784
class cmd_serve(Command):
2785
"""Run the bzr server.
2789
help='serve on stdin/out for use from inetd or sshd'),
2791
help='listen for connections on nominated port of the form '
2792
'[hostname:]portnumber. Passing 0 as the port number will '
2793
'result in a dynamically allocated port.',
2796
help='serve contents of directory',
2800
def run(self, port=None, inet=False, directory=None):
2801
from bzrlib.transport import smart
2802
from bzrlib.transport import get_transport
2803
if directory is None:
2804
directory = os.getcwd()
2805
t = get_transport(directory)
2807
server = smart.SmartStreamServer(sys.stdin, sys.stdout, t)
2808
elif port is not None:
2810
host, port = port.split(':')
2813
server = smart.SmartTCPServer(t, host=host, port=int(port))
2814
print 'listening on port: ', server.port
2817
raise BzrCommandError("bzr serve requires one of --inet or --port")
2746
2821
# command-line interpretation helper for merge-related commands
2747
2822
def merge(other_revision, base_revision,