1880
1880
class cmd_log(Command):
1881
"""Show log of a branch, file, or directory.
1883
By default show the log of the branch containing the working directory.
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
1890
Log the current branch::
1898
Log the last 10 revisions of a branch::
1900
bzr log -r -10.. http://server/branch
1881
"""Show historical log for a branch or subset of a branch.
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::
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
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
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.
1906
The following options can be used to control what information is
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
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
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.
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.
1931
:Revision filtering:
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::
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
1941
See ``bzr help revisionspec`` for details on how to specify X and Y.
1942
Some common examples are given below::
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
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.
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
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.
1968
Historical context is also important when interpreting pathnames of
1969
renamed files/directories. Consider the following example:
1971
* revision 1: add tutorial.txt
1972
* revision 2: modify tutorial.txt
1973
* revision 3: rename tutorial.txt to guide.txt; add tutorial.txt
1977
* ``bzr log guide.txt`` will log the file added in revision 1
1979
* ``bzr log tutorial.txt`` will log the new file added in revision 3
1981
* ``bzr log -r2 -p tutorial.txt`` will show the changes made to
1982
the original file in revision 2.
1984
* ``bzr log -r2 -p guide.txt`` will display an error message as there
1985
was no file called guide.txt in revision 2.
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).
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.)
1998
The --message option can be used for finding revisions that match a
1999
regular expression in a commit message.
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.
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.
2012
You may find it useful to add the aliases below to ``bazaar.conf``::
2016
top = log -r-10.. --short --forward
2017
show = log -v -p -n1 --long
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``.
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:
2028
* change your default log format to short (or line)
2029
* add this alias: log = log -n1
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.
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.
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.
1903
# TODO: Make --revision support uuid: and hash: [future tag:] notation.
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.'),
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.',
4910
help='Perform reconfiguration even if local changes'
5041
RegistryOption.from_kwargs(
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.'
5059
Option('bind-to', help='Branch to bind checkout to.', type=str),
5061
help='Perform reconfiguration even if local changes'
4914
5065
def run(self, location=None, target_type=None, bind_to=None, force=False):
4915
5066
directory = bzrdir.BzrDir.open(location)