827
827
tree = WorkingTree.open_containing(dir)[0]
828
828
tree.lock_write()
830
existing_pending_merges = tree.pending_merges()
830
existing_pending_merges = tree.get_parent_ids()[1:]
831
831
last_rev = tree.last_revision()
832
832
if last_rev == tree.branch.last_revision():
833
833
# may be up to date, check master too.
839
839
conflicts = tree.update()
840
840
revno = tree.branch.revision_id_to_revno(tree.last_revision())
841
841
note('Updated to revision %d.' % (revno,))
842
if tree.pending_merges() != existing_pending_merges:
842
if tree.get_parent_ids()[1:] != existing_pending_merges:
843
843
note('Your local commits will now show as pending merges with '
844
844
"'bzr status', and can be committed with 'bzr commit'.")
845
845
if conflicts != 0:
1351
1351
# local dir only
1352
1352
# FIXME ? log the current subdir only RBC 20060203
1353
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)
1354
1359
b = dir.open_branch()
1356
1361
if revision is None:
1359
1364
elif len(revision) == 1:
1360
1365
rev1 = rev2 = revision[0].in_history(b).revno
1361
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.")
1362
1373
if revision[0].spec is None:
1363
1374
# missing begin-range means first revision
1653
1664
if tree is None:
1654
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())
1655
1668
if revision is None:
1656
1669
revision_id = b.last_revision()
2140
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')
2142
2157
if revision is None or len(revision) < 1:
2143
2158
if uncommitted:
2160
2176
assert len(revision) == 2
2161
2177
if None in revision:
2162
2178
raise BzrCommandError(
2163
"Merge doesn't permit that revision specifier.")
2164
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.
2166
base = [branch, revision[0].in_history(other_branch).revno]
2167
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]
2169
2190
if tree.branch.get_parent() is None or remember:
2170
2191
tree.branch.set_parent(other_branch.base)
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")
2750
2821
# command-line interpretation helper for merge-related commands
2751
2822
def merge(other_revision, base_revision,