1821
1821
class cmd_log(Command):
1822
"""Show log of a branch, file, or directory.
1824
By default show the log of the branch containing the working directory.
1826
To request a range of logs, you can use the command -r begin..end
1827
-r revision requests a specific revision, -r ..end or -r begin.. are
1831
Log the current branch::
1839
Log the last 10 revisions of a branch::
1841
bzr log -r -10.. http://server/branch
1822
"""Show historical log for a branch or subset of a branch.
1824
log is bzr's default tool for exploring the history of a branch.
1825
The branch to use is taken from the first parameter. If no parameters
1826
are given, the branch containing the working directory is logged.
1827
Here are some simple examples::
1829
bzr log log the current branch
1830
bzr log foo.py log a file in its branch
1831
bzr log http://server/branch log a branch on a server
1833
The filtering, ordering and information shown for each revision can
1834
be controlled as explained below. By default, all revisions are
1835
shown sorted (topologically) so that newer revisions appear before
1836
older ones and descendants always appear before ancestors. If displayed,
1837
merged revisions are shown indented under the revision in which they
1842
The log format controls how information about each revision is
1843
displayed. The standard log formats are called ``long``, ``short``
1844
and ``line``. The default is long. See ``bzr help log-formats``
1845
for more details on log formats.
1847
The following options can be used to control what information is
1850
-l N display a maximum of N revisions
1851
-n N display N levels of revisions (0 for all, 1 for collapsed)
1852
-v display a status summary (delta) for each revision
1853
-p display a diff (patch) for each revision
1854
--show-ids display revision-ids (and file-ids), not just revnos
1856
Note that the default number of levels to display is a function of the
1857
log format. If the -n option is not used, ``short`` and ``line`` show
1858
just the top level (mainline) while ``long`` shows all levels of merged
1861
Status summaries are shown using status flags like A, M, etc. To see
1862
the changes explained using words like ``added`` and ``modified``
1863
instead, use the -vv option.
1867
To display revisions from oldest to newest, use the --forward option.
1868
In most cases, using this option will have little impact on the total
1869
time taken to produce a log, though --forward does not incrementally
1870
display revisions like --reverse does when it can.
1872
:Revision filtering:
1874
The -r option can be used to specify what revision or range of revisions
1875
to filter against. The various forms are shown below::
1877
-rX display revision X
1878
-rX.. display revision X and later
1879
-r..Y display up to and including revision Y
1880
-rX..Y display from X to Y inclusive
1882
See ``bzr help revisionspec`` for details on how to specify X and Y.
1883
Some common examples are given below::
1885
-r-1 show just the tip
1886
-r-10.. show the last 10 mainline revisions
1887
-rsubmit:.. show what's new on this branch
1888
-rancestor:path.. show changes since the common ancestor of this
1889
branch and the one at location path
1890
-rdate:yesterday.. show changes since yesterday
1892
When logging a range of revisions using -rX..Y, log starts at
1893
revision Y and searches back in history through the primary
1894
("left-hand") parents until it finds X. When logging just the
1895
top level (using -n1), an error is reported if X is not found
1896
along the way. If multi-level logging is used (-n0), X may be
1897
a nested merge revision and the log will be truncated accordingly.
1901
If a parameter is given and it's not a branch, the log will be filtered
1902
to show only those revisions that changed the nominated file or
1905
Filenames are interpreted within their historical context. To log a
1906
deleted file, specify a revision range so that the file existed at
1907
the end or start of the range.
1909
Historical context is also important when interpreting pathnames of
1910
renamed files/directories. Consider the following example:
1912
* revision 1: add tutorial.txt
1913
* revision 2: modify tutorial.txt
1914
* revision 3: rename tutorial.txt to guide.txt; add tutorial.txt
1918
* ``bzr log guide.txt`` will log the file added in revision 1
1920
* ``bzr log tutorial.txt`` will log the new file added in revision 3
1922
* ``bzr log -r2 -p tutorial.txt`` will show the changes made to
1923
the original file in revision 2.
1925
* ``bzr log -r2 -p guide.txt`` will display an error message as there
1926
was no file called guide.txt in revision 2.
1928
Renames are always followed by log. By design, there is no need to
1929
explicitly ask for this (and no way to stop logging a file back
1930
until it was last renamed).
1932
Note: If the path is a directory, only revisions that directly changed
1933
that directory object are currently shown. This is considered a bug.
1934
(Support for filtering against multiple files and for files within a
1935
directory is under development.)
1939
The --message option can be used for finding revisions that match a
1940
regular expression in a commit message.
1944
GUI tools and IDEs are often better at exploring history than command
1945
line tools. You may prefer qlog or glog from the QBzr and Bzr-Gtk packages
1946
respectively for example. (TortoiseBzr uses qlog for displaying logs.) See
1947
http://bazaar-vcs.org/BzrPlugins and http://bazaar-vcs.org/IDEIntegration.
1949
Web interfaces are often better at exploring history than command line
1950
tools, particularly for branches on servers. You may prefer Loggerhead
1951
or one of its alternatives. See http://bazaar-vcs.org/WebInterface.
1953
You may find it useful to add the aliases below to ``bazaar.conf``::
1957
top = log -r-10.. --short --forward
1958
show = log -v -p -n1 --long
1960
``bzr tip`` will then show the latest revision while ``bzr top``
1961
will show the last 10 mainline revisions. To see the details of a
1962
particular revision X, ``bzr show -rX``.
1964
As many GUI tools and Web interfaces do, you may prefer viewing
1965
history collapsed initially. If you are interested in looking deeper
1966
into a particular merge X, use ``bzr log -n0 -rX``. If you like
1967
working this way, you may wish to either:
1969
* change your default log format to short (or line)
1970
* add this alias: log = log -n1
1972
``bzr log -v`` on a branch with lots of history is currently
1973
very slow. A fix for this issue is currently under development.
1974
With or without that fix, it is recommended that a revision range
1975
be given when using the -v option.
1977
bzr has a generic full-text matching plugin, bzr-search, that can be
1978
used to find revisions matching user names, commit messages, etc.
1979
Among other features, this plugin can find all revisions containing
1980
a list of words but not others.
1982
When exploring non-mainline history on large projects with deep
1983
history, the performance of log can be greatly improved by installing
1984
the revnocache plugin. This plugin buffers historical information
1985
trading disk space for faster speed.
1844
# TODO: Make --revision support uuid: and hash: [future tag:] notation.
1846
1987
takes_args = ['location?']
1988
_see_also = ['log-formats', 'revisionspec']
1847
1989
takes_options = [
1848
1990
Option('forward',
1849
1991
help='Show from oldest to newest.'),