/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 breezy/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 03:10:29 UTC
  • mfrom: (7312 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190603031029-b34je03bjulxxdwj
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from breezy import (
34
34
    branch as _mod_branch,
35
35
    bugtracker,
36
 
    bundle,
37
36
    cache_utf8,
38
37
    controldir,
39
38
    directory_service,
46
45
    lazy_regex,
47
46
    log,
48
47
    merge as _mod_merge,
 
48
    mergeable as _mod_mergeable,
49
49
    merge_directive,
50
50
    osutils,
51
51
    reconfigure,
348
348
        Not versioned and not matching an ignore pattern.
349
349
 
350
350
    Additionally for directories, symlinks and files with a changed
351
 
    executable bit, Bazaar indicates their type using a trailing
 
351
    executable bit, Breezy indicates their type using a trailing
352
352
    character: '/', '@' or '*' respectively. These decorations can be
353
353
    disabled using the '--no-classify' option.
354
354
 
454
454
 
455
455
        b = controldir.ControlDir.open_containing_tree_or_branch(directory)[1]
456
456
 
457
 
        revisions = b.repository.revisions
 
457
        revisions = getattr(b.repository, "revisions", None)
458
458
        if revisions is None:
459
459
            raise errors.BzrCommandError(
460
460
                gettext('Repository %r does not support '
461
 
                        'access to raw revision texts'))
 
461
                        'access to raw revision texts') % b.repository)
462
462
 
463
463
        with b.repository.lock_read():
464
464
            # TODO: jam 20060112 should cat-revision always output utf-8?
1210
1210
        possible_transports = []
1211
1211
        if location is not None:
1212
1212
            try:
1213
 
                mergeable = bundle.read_mergeable_from_url(location,
1214
 
                                                           possible_transports=possible_transports)
 
1213
                mergeable = _mod_mergeable.read_mergeable_from_url(
 
1214
                    location, possible_transports=possible_transports)
1215
1215
            except errors.NotABundle:
1216
1216
                mergeable = None
1217
1217
 
1344
1344
            use_existing_dir=False, directory=None, stacked_on=None,
1345
1345
            stacked=False, strict=None, no_tree=False,
1346
1346
            overwrite_tags=False, lossy=False):
 
1347
        from .location import location_to_url
1347
1348
        from .push import _show_push_branch
1348
1349
 
1349
1350
        if overwrite:
1371
1372
                more_warning='Uncommitted changes will not be pushed.')
1372
1373
        # Get the stacked_on branch, if any
1373
1374
        if stacked_on is not None:
 
1375
            stacked_on = location_to_url(stacked_on, 'read')
1374
1376
            stacked_on = urlutils.normalize_url(stacked_on)
1375
1377
        elif stacked:
1376
1378
            parent_url = br_from.get_parent()
1728
1730
    If the tree's branch is bound to a master branch, brz will also update
1729
1731
    the branch from the master.
1730
1732
 
1731
 
    You cannot update just a single file or directory, because each Bazaar
 
1733
    You cannot update just a single file or directory, because each Breezy
1732
1734
    working tree has just a single basis revision.  If you want to restore a
1733
1735
    file that has been removed locally, use 'brz revert' instead of 'brz
1734
1736
    update'.  If you want to restore a file to its state in a previous
1871
1873
class cmd_remove(Command):
1872
1874
    __doc__ = """Remove files or directories.
1873
1875
 
1874
 
    This makes Bazaar stop tracking changes to the specified files. Bazaar will
 
1876
    This makes Breezy stop tracking changes to the specified files. Breezy will
1875
1877
    delete them if they can easily be recovered using revert otherwise they
1876
1878
    will be backed up (adding an extension of the form .~#~). If no options or
1877
 
    parameters are given Bazaar will scan for files that are being tracked by
1878
 
    Bazaar but missing in your tree and stop tracking them for you.
 
1879
    parameters are given Breezy will scan for files that are being tracked by
 
1880
    Breezy but missing in your tree and stop tracking them for you.
1879
1881
    """
1880
1882
    takes_args = ['file*']
1881
1883
    takes_options = ['verbose',
3091
3093
    using this command or directly by using an editor, be sure to commit
3092
3094
    it.
3093
3095
 
3094
 
    Bazaar also supports a global ignore file ~/.bazaar/ignore. On Windows
3095
 
    the global ignore file can be found in the application data directory as
3096
 
    C:\\Documents and Settings\\<user>\\Application Data\\Bazaar\\2.0\\ignore.
 
3096
    Breezy also supports a global ignore file ~/.config/breezy/ignore. On
 
3097
    Windows the global ignore file can be found in the application data
 
3098
    directory as
 
3099
    C:\\Documents and Settings\\<user>\\Application Data\\Breezy\\3.0\\ignore.
3097
3100
    Global ignores are not touched by this command. The global ignore file
3098
3101
    can be edited directly using an editor.
3099
3102
 
3732
3735
    unreferenced ancestors
3733
3736
        Texts that are ancestors of other texts, but
3734
3737
        are not properly referenced by the revision ancestry.  This is a
3735
 
        subtle problem that Bazaar can work around.
 
3738
        subtle problem that Breezy can work around.
3736
3739
 
3737
3740
    unique file texts
3738
3741
        This is the total number of unique file contents
3744
3747
        entries are modified, but the file contents are not.  It does not
3745
3748
        indicate a problem.
3746
3749
 
3747
 
    If no restrictions are specified, all Bazaar data that is found at the given
 
3750
    If no restrictions are specified, all data that is found at the given
3748
3751
    location will be checked.
3749
3752
 
3750
3753
    :Examples:
3786
3789
    __doc__ = """Upgrade a repository, branch or working tree to a newer format.
3787
3790
 
3788
3791
    When the default format has changed after a major new release of
3789
 
    Bazaar, you may be informed during certain operations that you
 
3792
    Bazaar/Breezy, you may be informed during certain operations that you
3790
3793
    should upgrade. Upgrading to a newer format may improve performance
3791
3794
    or make new features available. It may however limit interoperability
3792
 
    with older repositories or with older versions of Bazaar.
 
3795
    with older repositories or with older versions of Bazaar or Breezy.
3793
3796
 
3794
3797
    If you wish to upgrade to a particular format rather than the
3795
3798
    current default, that can be specified using the --format option.
3811
3814
    If the conversion of a branch fails, remaining branches are still
3812
3815
    tried.
3813
3816
 
3814
 
    For more information on upgrades, see the Bazaar Upgrade Guide,
 
3817
    For more information on upgrades, see the Breezy Upgrade Guide,
3815
3818
    https://www.breezy-vcs.org/doc/en/upgrade-guide/.
3816
3819
    """
3817
3820
 
4312
4315
    through OTHER, excluding BASE but including OTHER, will be merged.  If this
4313
4316
    causes some revisions to be skipped, i.e. if the destination branch does
4314
4317
    not already contain revision BASE, such a merge is commonly referred to as
4315
 
    a "cherrypick". Unlike a normal merge, Bazaar does not currently track
 
4318
    a "cherrypick". Unlike a normal merge, Breezy does not currently track
4316
4319
    cherrypicks. The changes look like a normal commit, and the history of the
4317
4320
    changes from the other branch is not stored in the commit.
4318
4321
 
4435
4438
        self.add_cleanup(tree.lock_write().unlock)
4436
4439
        if location is not None:
4437
4440
            try:
4438
 
                mergeable = bundle.read_mergeable_from_url(location,
4439
 
                                                           possible_transports=possible_transports)
 
4441
                mergeable = _mod_mergeable.read_mergeable_from_url(
 
4442
                    location, possible_transports=possible_transports)
4440
4443
            except errors.NotABundle:
4441
4444
                mergeable = None
4442
4445
            else:
5133
5136
 
5134
5137
    --verbose shows the path where each plugin is located.
5135
5138
 
5136
 
    A plugin is an external component for Bazaar that extends the
5137
 
    revision control system, by adding or replacing code in Bazaar.
 
5139
    A plugin is an external component for Breezy that extends the
 
5140
    revision control system, by adding or replacing code in Breezy.
5138
5141
    Plugins can do a variety of things, including overriding commands,
5139
5142
    adding new commands, providing additional network transports and
5140
5143
    customizing log output.
5257
5260
        return self._run(b, revision_id_list, revision)
5258
5261
 
5259
5262
    def _run(self, b, revision_id_list, revision):
 
5263
        from .repository import WriteGroup
5260
5264
        gpg_strategy = gpg.GPGStrategy(b.get_config_stack())
5261
5265
        if revision_id_list is not None:
5262
 
            b.repository.start_write_group()
5263
 
            try:
 
5266
            with WriteGroup(b.repository):
5264
5267
                for revision_id in revision_id_list:
5265
5268
                    revision_id = cache_utf8.encode(revision_id)
5266
5269
                    b.repository.sign_revision(revision_id, gpg_strategy)
5267
 
            except BaseException:
5268
 
                b.repository.abort_write_group()
5269
 
                raise
5270
 
            else:
5271
 
                b.repository.commit_write_group()
5272
5270
        elif revision is not None:
5273
5271
            if len(revision) == 1:
5274
5272
                revno, rev_id = revision[0].in_history(b)
5275
 
                b.repository.start_write_group()
5276
 
                try:
 
5273
                with WriteGroup(b.repository):
5277
5274
                    b.repository.sign_revision(rev_id, gpg_strategy)
5278
 
                except BaseException:
5279
 
                    b.repository.abort_write_group()
5280
 
                    raise
5281
 
                else:
5282
 
                    b.repository.commit_write_group()
5283
5275
            elif len(revision) == 2:
5284
5276
                # are they both on rh- if so we can walk between them
5285
5277
                # might be nice to have a range helper for arbitrary
5291
5283
                if from_revno is None or to_revno is None:
5292
5284
                    raise errors.BzrCommandError(
5293
5285
                        gettext('Cannot sign a range of non-revision-history revisions'))
5294
 
                b.repository.start_write_group()
5295
 
                try:
 
5286
                with WriteGroup(b.repository):
5296
5287
                    for revno in range(from_revno, to_revno + 1):
5297
5288
                        b.repository.sign_revision(b.get_rev_id(revno),
5298
5289
                                                   gpg_strategy)
5299
 
                except BaseException:
5300
 
                    b.repository.abort_write_group()
5301
 
                    raise
5302
 
                else:
5303
 
                    b.repository.commit_write_group()
5304
5290
            else:
5305
5291
                raise errors.BzrCommandError(
5306
5292
                    gettext('Please supply either one revision, or a range.'))
5420
5406
        else:
5421
5407
            self.add_cleanup(b.lock_write().unlock)
5422
5408
        return self._run(b, tree, dry_run, verbose, revision, force,
5423
 
                         local, keep_tags)
 
5409
                         local, keep_tags, location)
5424
5410
 
5425
5411
    def _run(self, b, tree, dry_run, verbose, revision, force, local,
5426
 
             keep_tags):
 
5412
             keep_tags, location):
5427
5413
        from .log import log_formatter, show_log
5428
5414
        from .uncommit import uncommit
5429
5415
 
5477
5463
               last_rev_id, rev_id)
5478
5464
        uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
5479
5465
                 revno=revno, local=local, keep_tags=keep_tags)
5480
 
        self.outf.write(
5481
 
            gettext('You can restore the old tip by running:\n'
5482
 
                    '  brz pull . -r revid:%s\n')
5483
 
            % last_rev_id.decode('utf-8'))
 
5466
        if location != '.':
 
5467
            self.outf.write(
 
5468
                gettext('You can restore the old tip by running:\n'
 
5469
                        '  brz pull -d %s %s -r revid:%s\n')
 
5470
                % (location, location, last_rev_id.decode('utf-8')))
 
5471
        else:
 
5472
            self.outf.write(
 
5473
                gettext('You can restore the old tip by running:\n'
 
5474
                        '  brz pull . -r revid:%s\n')
 
5475
                % last_rev_id.decode('utf-8'))
5484
5476
 
5485
5477
 
5486
5478
class cmd_break_lock(Command):
5498
5490
    :Examples:
5499
5491
        brz break-lock
5500
5492
        brz break-lock brz+ssh://example.com/brz/foo
5501
 
        brz break-lock --conf ~/.bazaar
 
5493
        brz break-lock --conf ~/.config/breezy
5502
5494
    """
5503
5495
 
5504
5496
    takes_args = ['location?']
5789
5781
    branch containing submit_branch in its ancestory without needing access to
5790
5782
    the source branch.
5791
5783
 
5792
 
    If --no-bundle is specified, then Bazaar doesn't send the contents of the
 
5784
    If --no-bundle is specified, then Breezy doesn't send the contents of the
5793
5785
    revisions, but only a structured request to merge from the
5794
5786
    public_location.  In that case the public_branch is needed and it must be
5795
5787
    up-to-date and accessible to the recipient.  The public_branch is always
7009
7001
            grep.versioned_grep(opts)
7010
7002
 
7011
7003
 
 
7004
class cmd_patch(Command):
 
7005
    """Apply a named patch to the current tree.
 
7006
 
 
7007
    """
 
7008
 
 
7009
    takes_args = ['filename?']
 
7010
    takes_options = [Option('strip', type=int, short_name='p',
 
7011
                            help=("Strip the smallest prefix containing num "
 
7012
                                  "leading slashes from filenames.")),
 
7013
                     Option('silent', help='Suppress chatter.')]
 
7014
 
 
7015
    def run(self, filename=None, strip=None, silent=False):
 
7016
        from .patch import patch_tree
 
7017
        wt = WorkingTree.open_containing('.')[0]
 
7018
        if strip is None:
 
7019
            strip = 1
 
7020
        my_file = None
 
7021
        if filename is None:
 
7022
            my_file = getattr(sys.stdin, 'buffer', sys.stdin)
 
7023
        else:
 
7024
            my_file = open(filename, 'rb')
 
7025
        patches = [my_file.read()]
 
7026
        return patch_tree(wt, patches, strip, quiet=is_quiet(), out=self.outf)
 
7027
 
 
7028
 
 
7029
class cmd_resolve_location(Command):
 
7030
    __doc__ = """Expand a location to a full URL.
 
7031
 
 
7032
    :Examples:
 
7033
        Look up a Launchpad URL.
 
7034
 
 
7035
            brz resolve-location lp:brz
 
7036
    """
 
7037
    takes_args = ['location']
 
7038
    hidden = True
 
7039
 
 
7040
    def run(self, location):
 
7041
        from .location import location_to_url
 
7042
        url = location_to_url(location)
 
7043
        display_url = urlutils.unescape_for_display(url, self.outf.encoding)
 
7044
        self.outf.write('%s\n' % display_url)
 
7045
 
 
7046
 
7012
7047
def _register_lazy_builtins():
7013
7048
    # register lazy builtins from other modules; called at startup and should
7014
7049
    # be only called once.