/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 r4029

Show diffs side-by-side

added added

removed removed

Lines of Context:
1878
1878
 
1879
1879
 
1880
1880
class cmd_log(Command):
1881
 
    """Show log of a branch, file, or directory.
1882
 
 
1883
 
    By default show the log of the branch containing the working directory.
1884
 
 
1885
 
    To request a range of logs, you can use the command -r begin..end
1886
 
    -r revision requests a specific revision, -r ..end or -r begin.. are
1887
 
    also valid.
1888
 
 
1889
 
    :Examples:
1890
 
        Log the current branch::
1891
 
 
1892
 
            bzr log
1893
 
 
1894
 
        Log a file::
1895
 
 
1896
 
            bzr log foo.c
1897
 
 
1898
 
        Log the last 10 revisions of a branch::
1899
 
 
1900
 
            bzr log -r -10.. http://server/branch
 
1881
    """Show historical log for a branch or subset of a branch.
 
1882
 
 
1883
    log is bzr's default tool for exploring the history of a branch.
 
1884
    The branch to use is taken from the first parameter. If no parameters
 
1885
    are given, the branch containing the working directory is logged.
 
1886
    Here are some simple examples::
 
1887
 
 
1888
      bzr log                       log the current branch
 
1889
      bzr log foo.py                log a file in its branch
 
1890
      bzr log http://server/branch  log a branch on a server
 
1891
 
 
1892
    The filtering, ordering and information shown for each revision can
 
1893
    be controlled as explained below. By default, all revisions are
 
1894
    shown sorted (topologically) so that newer revisions appear before
 
1895
    older ones and descendants always appear before ancestors. If displayed,
 
1896
    merged revisions are shown indented under the revision in which they
 
1897
    were merged.
 
1898
 
 
1899
    :Output control:
 
1900
 
 
1901
      The log format controls how information about each revision is
 
1902
      displayed. The standard log formats are called ``long``, ``short``
 
1903
      and ``line``. The default is long. See ``bzr help log-formats``
 
1904
      for more details on log formats.
 
1905
 
 
1906
      The following options can be used to control what information is
 
1907
      displayed::
 
1908
  
 
1909
        -l N        display a maximum of N revisions
 
1910
        -n N        display N levels of revisions (0 for all, 1 for collapsed)
 
1911
        -v          display a status summary (delta) for each revision
 
1912
        -p          display a diff (patch) for each revision
 
1913
        --show-ids  display revision-ids (and file-ids), not just revnos
 
1914
  
 
1915
      Note that the default number of levels to display is a function of the
 
1916
      log format. If the -n option is not used, ``short`` and ``line`` show
 
1917
      just the top level (mainline) while ``long`` shows all levels of merged
 
1918
      revisions.
 
1919
  
 
1920
      Status summaries are shown using status flags like A, M, etc. To see
 
1921
      the changes explained using words like ``added`` and ``modified``
 
1922
      instead, use the -vv option.
 
1923
  
 
1924
    :Ordering control:
 
1925
  
 
1926
      To display revisions from oldest to newest, use the --forward option.
 
1927
      In most cases, using this option will have little impact on the total
 
1928
      time taken to produce a log, though --forward does not incrementally
 
1929
      display revisions like --reverse does when it can.
 
1930
  
 
1931
    :Revision filtering:
 
1932
  
 
1933
      The -r option can be used to specify what revision or range of revisions
 
1934
      to filter against. The various forms are shown below::
 
1935
  
 
1936
        -rX      display revision X
 
1937
        -rX..    display revision X and later
 
1938
        -r..Y    display up to and including revision Y
 
1939
        -rX..Y   display from X to Y inclusive
 
1940
  
 
1941
      See ``bzr help revisionspec`` for details on how to specify X and Y.
 
1942
      Some common examples are given below::
 
1943
  
 
1944
        -r-1                show just the tip
 
1945
        -r-10..             show the last 10 mainline revisions
 
1946
        -rsubmit:..         show what's new on this branch
 
1947
        -rancestor:path..   show changes since the common ancestor of this
 
1948
                            branch and the one at location path
 
1949
        -rdate:yesterday..  show changes since yesterday
 
1950
  
 
1951
      When logging a range of revisions using -rX..Y, log starts at
 
1952
      revision Y and searches back in history through the primary
 
1953
      ("left-hand") parents until it finds X. When logging just the
 
1954
      top level (using -n1), an error is reported if X is not found
 
1955
      along the way. If multi-level logging is used (-n0), X may be
 
1956
      a nested merge revision and the log will be truncated accordingly.
 
1957
 
 
1958
    :Path filtering:
 
1959
  
 
1960
      If a parameter is given and it's not a branch, the log will be filtered
 
1961
      to show only those revisions that changed the nominated file or
 
1962
      directory.
 
1963
  
 
1964
      Filenames are interpreted within their historical context. To log a
 
1965
      deleted file, specify a revision range so that the file existed at
 
1966
      the end or start of the range.
 
1967
  
 
1968
      Historical context is also important when interpreting pathnames of
 
1969
      renamed files/directories. Consider the following example:
 
1970
  
 
1971
      * revision 1: add tutorial.txt
 
1972
      * revision 2: modify tutorial.txt
 
1973
      * revision 3: rename tutorial.txt to guide.txt; add tutorial.txt
 
1974
  
 
1975
      In this case:
 
1976
  
 
1977
      * ``bzr log guide.txt`` will log the file added in revision 1
 
1978
  
 
1979
      * ``bzr log tutorial.txt`` will log the new file added in revision 3
 
1980
  
 
1981
      * ``bzr log -r2 -p tutorial.txt`` will show the changes made to
 
1982
        the original file in revision 2.
 
1983
  
 
1984
      * ``bzr log -r2 -p guide.txt`` will display an error message as there
 
1985
        was no file called guide.txt in revision 2.
 
1986
  
 
1987
      Renames are always followed by log. By design, there is no need to
 
1988
      explicitly ask for this (and no way to stop logging a file back
 
1989
      until it was last renamed).
 
1990
  
 
1991
      Note: If the path is a directory, only revisions that directly changed
 
1992
      that directory object are currently shown. This is considered a bug.
 
1993
      (Support for filtering against multiple files and for files within a
 
1994
      directory is under development.)
 
1995
  
 
1996
    :Other filtering:
 
1997
  
 
1998
      The --message option can be used for finding revisions that match a
 
1999
      regular expression in a commit message.
 
2000
  
 
2001
    :Tips & tricks:
 
2002
  
 
2003
      GUI tools and IDEs are often better at exploring history than command
 
2004
      line tools. You may prefer qlog or glog from the QBzr and Bzr-Gtk packages
 
2005
      respectively for example. (TortoiseBzr uses qlog for displaying logs.) See
 
2006
      http://bazaar-vcs.org/BzrPlugins and http://bazaar-vcs.org/IDEIntegration.
 
2007
  
 
2008
      Web interfaces are often better at exploring history than command line
 
2009
      tools, particularly for branches on servers. You may prefer Loggerhead
 
2010
      or one of its alternatives. See http://bazaar-vcs.org/WebInterface.
 
2011
  
 
2012
      You may find it useful to add the aliases below to ``bazaar.conf``::
 
2013
  
 
2014
        [ALIASES]
 
2015
        tip = log -r-1 -n1
 
2016
        top = log -r-10.. --short --forward
 
2017
        show = log -v -p -n1 --long
 
2018
  
 
2019
      ``bzr tip`` will then show the latest revision while ``bzr top``
 
2020
      will show the last 10 mainline revisions. To see the details of a
 
2021
      particular revision X,  ``bzr show -rX``.
 
2022
  
 
2023
      As many GUI tools and Web interfaces do, you may prefer viewing
 
2024
      history collapsed initially. If you are interested in looking deeper
 
2025
      into a particular merge X, use ``bzr log -n0 -rX``. If you like
 
2026
      working this way, you may wish to either:
 
2027
  
 
2028
      * change your default log format to short (or line)
 
2029
      * add this alias: log = log -n1
 
2030
  
 
2031
      ``bzr log -v`` on a branch with lots of history is currently
 
2032
      very slow. A fix for this issue is currently under development.
 
2033
      With or without that fix, it is recommended that a revision range
 
2034
      be given when using the -v option.
 
2035
  
 
2036
      bzr has a generic full-text matching plugin, bzr-search, that can be
 
2037
      used to find revisions matching user names, commit messages, etc.
 
2038
      Among other features, this plugin can find all revisions containing
 
2039
      a list of words but not others.
 
2040
  
 
2041
      When exploring non-mainline history on large projects with deep
 
2042
      history, the performance of log can be greatly improved by installing
 
2043
      the revnocache plugin. This plugin buffers historical information
 
2044
      trading disk space for faster speed.
1901
2045
    """
1902
 
 
1903
 
    # TODO: Make --revision support uuid: and hash: [future tag:] notation.
1904
 
 
1905
2046
    takes_args = ['location?']
 
2047
    _see_also = ['log-formats', 'revisionspec']
1906
2048
    takes_options = [
1907
2049
            Option('forward',
1908
2050
                   help='Show from oldest to newest.'),
2968
3110
                     ]
2969
3111
    encoding_type = 'replace'
2970
3112
 
 
3113
    def __init__(self):
 
3114
        Command.__init__(self)
 
3115
        self.additional_selftest_args = {}
 
3116
 
2971
3117
    def run(self, testspecs_list=None, verbose=False, one=False,
2972
3118
            transport=None, benchmark=None,
2973
3119
            lsprof_timed=None, cache_dir=None,
3005
3151
            test_suite_factory = None
3006
3152
            benchfile = None
3007
3153
        try:
3008
 
            result = selftest(verbose=verbose,
3009
 
                              pattern=pattern,
3010
 
                              stop_on_failure=one,
3011
 
                              transport=transport,
3012
 
                              test_suite_factory=test_suite_factory,
3013
 
                              lsprof_timed=lsprof_timed,
3014
 
                              bench_history=benchfile,
3015
 
                              matching_tests_first=first,
3016
 
                              list_only=list_only,
3017
 
                              random_seed=randomize,
3018
 
                              exclude_pattern=exclude,
3019
 
                              strict=strict,
3020
 
                              load_list=load_list,
3021
 
                              debug_flags=debugflag,
3022
 
                              starting_with=starting_with,
3023
 
                              )
 
3154
            selftest_kwargs = {"verbose": verbose,
 
3155
                              "pattern": pattern,
 
3156
                              "stop_on_failure": one,
 
3157
                              "transport": transport,
 
3158
                              "test_suite_factory": test_suite_factory,
 
3159
                              "lsprof_timed": lsprof_timed,
 
3160
                              "bench_history": benchfile,
 
3161
                              "matching_tests_first": first,
 
3162
                              "list_only": list_only,
 
3163
                              "random_seed": randomize,
 
3164
                              "exclude_pattern": exclude,
 
3165
                              "strict": strict,
 
3166
                              "load_list": load_list,
 
3167
                              "debug_flags": debugflag,
 
3168
                              "starting_with": starting_with
 
3169
                              }
 
3170
            selftest_kwargs.update(self.additional_selftest_args)
 
3171
            result = selftest(**selftest_kwargs)
3024
3172
        finally:
3025
3173
            if benchfile is not None:
3026
3174
                benchfile.close()
4889
5037
 
4890
5038
    _see_also = ['branches', 'checkouts', 'standalone-trees', 'working-trees']
4891
5039
    takes_args = ['location?']
4892
 
    takes_options = [RegistryOption.from_kwargs('target_type',
4893
 
                     title='Target type',
4894
 
                     help='The type to reconfigure the directory to.',
4895
 
                     value_switches=True, enum_switch=False,
4896
 
                     branch='Reconfigure to be an unbound branch '
4897
 
                        'with no working tree.',
4898
 
                     tree='Reconfigure to be an unbound branch '
4899
 
                        'with a working tree.',
4900
 
                     checkout='Reconfigure to be a bound branch '
4901
 
                        'with a working tree.',
4902
 
                     lightweight_checkout='Reconfigure to be a lightweight'
4903
 
                     ' checkout (with no local history).',
4904
 
                     standalone='Reconfigure to be a standalone branch '
4905
 
                        '(i.e. stop using shared repository).',
4906
 
                     use_shared='Reconfigure to use a shared repository.'),
4907
 
                     Option('bind-to', help='Branch to bind checkout to.',
4908
 
                            type=str),
4909
 
                     Option('force',
4910
 
                        help='Perform reconfiguration even if local changes'
4911
 
                        ' will be lost.')
4912
 
                     ]
 
5040
    takes_options = [
 
5041
        RegistryOption.from_kwargs(
 
5042
            'target_type',
 
5043
            title='Target type',
 
5044
            help='The type to reconfigure the directory to.',
 
5045
            value_switches=True, enum_switch=False,
 
5046
            branch='Reconfigure to be an unbound branch with no working tree.',
 
5047
            tree='Reconfigure to be an unbound branch with a working tree.',
 
5048
            checkout='Reconfigure to be a bound branch with a working tree.',
 
5049
            lightweight_checkout='Reconfigure to be a lightweight'
 
5050
                ' checkout (with no local history).',
 
5051
            standalone='Reconfigure to be a standalone branch '
 
5052
                '(i.e. stop using shared repository).',
 
5053
            use_shared='Reconfigure to use a shared repository.',
 
5054
            with_trees='Reconfigure repository to create '
 
5055
                'working trees on branches by default.',
 
5056
            with_no_trees='Reconfigure repository to not create '
 
5057
                'working trees on branches by default.'
 
5058
            ),
 
5059
        Option('bind-to', help='Branch to bind checkout to.', type=str),
 
5060
        Option('force',
 
5061
               help='Perform reconfiguration even if local changes'
 
5062
               ' will be lost.')
 
5063
        ]
4913
5064
 
4914
5065
    def run(self, location=None, target_type=None, bind_to=None, force=False):
4915
5066
        directory = bzrdir.BzrDir.open(location)
4920
5071
        elif target_type == 'tree':
4921
5072
            reconfiguration = reconfigure.Reconfigure.to_tree(directory)
4922
5073
        elif target_type == 'checkout':
4923
 
            reconfiguration = reconfigure.Reconfigure.to_checkout(directory,
4924
 
                                                                  bind_to)
 
5074
            reconfiguration = reconfigure.Reconfigure.to_checkout(
 
5075
                directory, bind_to)
4925
5076
        elif target_type == 'lightweight-checkout':
4926
5077
            reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
4927
5078
                directory, bind_to)
4929
5080
            reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
4930
5081
        elif target_type == 'standalone':
4931
5082
            reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
 
5083
        elif target_type == 'with-trees':
 
5084
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
 
5085
                directory, True)
 
5086
        elif target_type == 'with-no-trees':
 
5087
            reconfiguration = reconfigure.Reconfigure.set_repository_trees(
 
5088
                directory, False)
4932
5089
        reconfiguration.apply(force)
4933
5090
 
4934
5091
 
5165
5322
 
5166
5323
    Shelve allows you to temporarily put changes you've made "on the shelf",
5167
5324
    ie. out of the way, until a later time when you can bring them back from
5168
 
    the shelf with the 'unshelve' command.
 
5325
    the shelf with the 'unshelve' command.  The changes are stored alongside
 
5326
    your working tree, and so they aren't propagated along with your branch nor
 
5327
    will they survive its deletion.
5169
5328
 
5170
5329
    If shelve --list is specified, previously-shelved changes are listed.
5171
5330
 
5233
5392
    """Restore shelved changes.
5234
5393
 
5235
5394
    By default, the most recently shelved changes are restored. However if you
5236
 
    specify a patch by name those changes will be restored instead.  This
5237
 
    works best when the changes don't depend on each other.
 
5395
    specify a shelf by id those changes will be restored instead.  This works
 
5396
    best when the changes don't depend on each other.
5238
5397
    """
5239
5398
 
5240
5399
    takes_args = ['shelf_id?']