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