/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
764
764
        # if the source and to_location are the same, 
765
765
        # and there is no working tree,
766
766
        # then reconstitute a branch
767
 
        if (osutils.abspath(to_location) == 
 
767
        if (osutils.abspath(to_location) ==
768
768
            osutils.abspath(branch_location)):
769
769
            try:
770
770
                source.bzrdir.open_workingtree()
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:
1352
1352
        else:
1353
1353
            # local dir only
1354
1354
            # FIXME ? log the current subdir only RBC 20060203 
1355
 
            dir, relpath = bzrdir.BzrDir.open_containing('.')
 
1355
            if revision is not None \
 
1356
                    and len(revision) > 0 and revision[0].get_branch():
 
1357
                location = revision[0].get_branch()
 
1358
            else:
 
1359
                location = '.'
 
1360
            dir, relpath = bzrdir.BzrDir.open_containing(location)
1356
1361
            b = dir.open_branch()
1357
1362
 
1358
1363
        if revision is None:
1361
1366
        elif len(revision) == 1:
1362
1367
            rev1 = rev2 = revision[0].in_history(b).revno
1363
1368
        elif len(revision) == 2:
 
1369
            if revision[1].get_branch() != revision[0].get_branch():
 
1370
                # b is taken from revision[0].get_branch(), and
 
1371
                # show_log will use its revision_history. Having
 
1372
                # different branches will lead to weird behaviors.
 
1373
                raise BzrCommandError(
 
1374
                    "Log doesn't accept two revisions in different branches.")
1364
1375
            if revision[0].spec is None:
1365
1376
                # missing begin-range means first revision
1366
1377
                rev1 = 1
1654
1665
 
1655
1666
        if tree is None:
1656
1667
            b, relpath = Branch.open_containing(filename)
 
1668
        if revision is not None and revision[0].get_branch() is not None:
 
1669
            b = Branch.open(revision[0].get_branch())
1657
1670
        if revision is None:
1658
1671
            revision_id = b.last_revision()
1659
1672
        else:
2139
2152
                else:
2140
2153
                    return 1
2141
2154
 
2142
 
        branch = self._get_remembered_parent(tree, branch, 'Merging from')
 
2155
        if revision is None \
 
2156
                or len(revision) < 1 or revision[0].needs_branch():
 
2157
            branch = self._get_remembered_parent(tree, branch, 'Merging from')
2143
2158
 
2144
2159
        if revision is None or len(revision) < 1:
2145
2160
            if uncommitted:
2153
2168
            if uncommitted:
2154
2169
                raise BzrCommandError('Cannot use --uncommitted and --revision'
2155
2170
                                      ' at the same time.')
 
2171
            branch = revision[0].get_branch() or branch
2156
2172
            if len(revision) == 1:
2157
2173
                base = [None, None]
2158
2174
                other_branch, path = Branch.open_containing(branch)
2162
2178
                assert len(revision) == 2
2163
2179
                if None in revision:
2164
2180
                    raise BzrCommandError(
2165
 
                        "Merge doesn't permit that revision specifier.")
2166
 
                other_branch, path = Branch.open_containing(branch)
 
2181
                        "Merge doesn't permit empty revision specifier.")
 
2182
                base_branch, path = Branch.open_containing(branch)
 
2183
                branch1 = revision[1].get_branch() or branch
 
2184
                other_branch, path1 = Branch.open_containing(branch1)
 
2185
                if revision[0].get_branch() is not None:
 
2186
                    # then path was obtained from it, and is None.
 
2187
                    path = path1
2167
2188
 
2168
 
                base = [branch, revision[0].in_history(other_branch).revno]
2169
 
                other = [branch, revision[1].in_history(other_branch).revno]
 
2189
                base = [branch, revision[0].in_history(base_branch).revno]
 
2190
                other = [branch1, revision[1].in_history(other_branch).revno]
2170
2191
 
2171
2192
        if tree.branch.get_parent() is None or remember:
2172
2193
            tree.branch.set_parent(other_branch.base)
2306
2327
            return 0
2307
2328
 
2308
2329
class cmd_revert(Command):
2309
 
    """Reverse all changes since the last commit.
2310
 
 
2311
 
    Only versioned files are affected.  Specify filenames to revert only 
2312
 
    those files.  By default, any files that are changed will be backed up
2313
 
    first.  Backup files have a '~' appended to their name.
 
2330
    """Revert files to a previous revision.
 
2331
 
 
2332
    Giving a list of files will revert only those files.  Otherwise, all files
 
2333
    will be reverted.  If the revision is not specified with '--revision', the
 
2334
    last committed revision is used.
 
2335
 
 
2336
    To remove only some changes, without reverting to a prior version, use
 
2337
    merge instead.  For example, "merge . --r-2..-3" will remove the changes
 
2338
    introduced by -2, without affecting the changes introduced by -1.  Or
 
2339
    to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
 
2340
    
 
2341
    By default, any files that have been manually changed will be backed up
 
2342
    first.  (Files changed only by merge are not backed up.)  Backup files have
 
2343
    '.~#~' appended to their name, where # is a number.
 
2344
 
 
2345
    When you provide files, you can use their current pathname or the pathname
 
2346
    from the target revision.  So you can use revert to "undelete" a file by
 
2347
    name.  If you name a directory, all the contents of that directory will be
 
2348
    reverted.
2314
2349
    """
2315
2350
    takes_options = ['revision', 'no-backup']
2316
2351
    takes_args = ['file*']
2748
2783
            pass
2749
2784
        
2750
2785
 
 
2786
class cmd_wait_until_signalled(Command):
 
2787
    """Test helper for test_start_and_stop_bzr_subprocess_send_signal.
 
2788
 
 
2789
    This just prints a line to signal when it is ready, then blocks on stdin.
 
2790
    """
 
2791
 
 
2792
    hidden = True
 
2793
 
 
2794
    def run(self):
 
2795
        sys.stdout.write("running\n")
 
2796
        sys.stdout.flush()
 
2797
        sys.stdin.readline()
 
2798
 
 
2799
 
 
2800
class cmd_serve(Command):
 
2801
    """Run the bzr server."""
 
2802
 
 
2803
    aliases = ['server']
 
2804
 
 
2805
    takes_options = [
 
2806
        Option('inet',
 
2807
               help='serve on stdin/out for use from inetd or sshd'),
 
2808
        Option('port',
 
2809
               help='listen for connections on nominated port of the form '
 
2810
                    '[hostname:]portnumber. Passing 0 as the port number will '
 
2811
                    'result in a dynamically allocated port.',
 
2812
               type=str),
 
2813
        Option('directory',
 
2814
               help='serve contents of directory',
 
2815
               type=unicode),
 
2816
        Option('allow-writes',
 
2817
               help='By default the server is a readonly server. Supplying '
 
2818
                    '--allow-writes enables write access to the contents of '
 
2819
                    'the served directory and below. '
 
2820
                ),
 
2821
        ]
 
2822
 
 
2823
    def run(self, port=None, inet=False, directory=None, allow_writes=False):
 
2824
        from bzrlib.transport import smart
 
2825
        from bzrlib.transport import get_transport
 
2826
        if directory is None:
 
2827
            directory = os.getcwd()
 
2828
        url = 'file://' + urlutils.escape(directory)
 
2829
        if not allow_writes:
 
2830
            url = 'readonly+' + url
 
2831
        t = get_transport(url)
 
2832
        if inet:
 
2833
            server = smart.SmartStreamServer(sys.stdin, sys.stdout, t)
 
2834
        elif port is not None:
 
2835
            if ':' in port:
 
2836
                host, port = port.split(':')
 
2837
            else:
 
2838
                host = '127.0.0.1'
 
2839
            server = smart.SmartTCPServer(t, host=host, port=int(port))
 
2840
            print 'listening on port: ', server.port
 
2841
            sys.stdout.flush()
 
2842
        else:
 
2843
            raise BzrCommandError("bzr serve requires one of --inet or --port")
 
2844
        server.serve()
 
2845
 
2751
2846
 
2752
2847
# command-line interpretation helper for merge-related commands
2753
2848
def merge(other_revision, base_revision,
2823
2918
# we do need to load at least some information about them to know of 
2824
2919
# aliases.  ideally we would avoid loading the implementation until the
2825
2920
# details were needed.
 
2921
from bzrlib.cmd_version_info import cmd_version_info
2826
2922
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore
2827
2923
from bzrlib.bundle.commands import cmd_bundle_revisions
2828
2924
from bzrlib.sign_my_commits import cmd_sign_my_commits