~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2006-09-17 21:03:04 UTC
  • mfrom: (2018 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2019.
  • Revision ID: robertc@robertcollins.net-20060917210304-3a697132f5fb68ac
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
827
827
        tree = WorkingTree.open_containing(dir)[0]
828
828
        tree.lock_write()
829
829
        try:
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:
1350
1350
        else:
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()
 
1356
            else:
 
1357
                location = '.'
 
1358
            dir, relpath = bzrdir.BzrDir.open_containing(location)
1354
1359
            b = dir.open_branch()
1355
1360
 
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
1364
1375
                rev1 = 1
1652
1663
 
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()
1657
1670
        else:
2137
2150
                else:
2138
2151
                    return 1
2139
2152
 
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')
2141
2156
 
2142
2157
        if revision is None or len(revision) < 1:
2143
2158
            if uncommitted:
2151
2166
            if uncommitted:
2152
2167
                raise BzrCommandError('Cannot use --uncommitted and --revision'
2153
2168
                                      ' at the same time.')
 
2169
            branch = revision[0].get_branch() or branch
2154
2170
            if len(revision) == 1:
2155
2171
                base = [None, None]
2156
2172
                other_branch, path = Branch.open_containing(branch)
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.
 
2185
                    path = path1
2165
2186
 
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]
2168
2189
 
2169
2190
        if tree.branch.get_parent() is None or remember:
2170
2191
            tree.branch.set_parent(other_branch.base)
2746
2767
            pass
2747
2768
        
2748
2769
 
 
2770
class cmd_wait_until_signalled(Command):
 
2771
    """Test helper for test_start_and_stop_bzr_subprocess_send_signal.
 
2772
 
 
2773
    This just prints a line to signal when it is ready, then blocks on stdin.
 
2774
    """
 
2775
 
 
2776
    hidden = True
 
2777
 
 
2778
    def run(self):
 
2779
        sys.stdout.write("running\n")
 
2780
        sys.stdout.flush()
 
2781
        sys.stdin.readline()
 
2782
 
 
2783
 
 
2784
class cmd_serve(Command):
 
2785
    """Run the bzr server.
 
2786
    """
 
2787
    takes_options = [
 
2788
        Option('inet',
 
2789
               help='serve on stdin/out for use from inetd or sshd'),
 
2790
        Option('port',
 
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.',
 
2794
               type=str),
 
2795
        Option('directory',
 
2796
               help='serve contents of directory',
 
2797
               type=unicode),
 
2798
        ]
 
2799
 
 
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)
 
2806
        if inet:
 
2807
            server = smart.SmartStreamServer(sys.stdin, sys.stdout, t)
 
2808
        elif port is not None:
 
2809
            if ':' in port:
 
2810
                host, port = port.split(':')
 
2811
            else:
 
2812
                host = '127.0.0.1'
 
2813
            server = smart.SmartTCPServer(t, host=host, port=int(port))
 
2814
            print 'listening on port: ', server.port
 
2815
            sys.stdout.flush()
 
2816
        else:
 
2817
            raise BzrCommandError("bzr serve requires one of --inet or --port")
 
2818
        server.serve()
 
2819
 
2749
2820
 
2750
2821
# command-line interpretation helper for merge-related commands
2751
2822
def merge(other_revision, base_revision,