13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""builtin bzr commands"""
1977
1978
:Path filtering:
1979
If a parameter is given and it's not a branch, the log will be filtered
1980
to show only those revisions that changed the nominated file or
1980
If parameters are given and the first one is not a branch, the log
1981
will be filtered to show only those revisions that changed the
1982
nominated files or directories.
1983
1984
Filenames are interpreted within their historical context. To log a
1984
1985
deleted file, specify a revision range so that the file existed at
2007
2008
explicitly ask for this (and no way to stop logging a file back
2008
2009
until it was last renamed).
2010
Note: If the path is a directory, only revisions that directly changed
2011
that directory object are currently shown. This is considered a bug.
2012
(Support for filtering against multiple files and for files within a
2013
directory is under development.)
2015
2011
:Other filtering:
2017
2013
The --message option can be used for finding revisions that match a
2062
2058
the revnocache plugin. This plugin buffers historical information
2063
2059
trading disk space for faster speed.
2065
takes_args = ['location?']
2061
takes_args = ['file*']
2066
2062
_see_also = ['log-formats', 'revisionspec']
2067
2063
takes_options = [
2068
2064
Option('forward',
2100
2096
encoding_type = 'replace'
2102
2098
@display_command
2103
def run(self, location=None, timezone='original',
2099
def run(self, file_list=None, timezone='original',
2105
2101
show_ids=False,
2124
2124
revision = change
2129
# find the file id to log:
2131
tree, b, fp = bzrdir.BzrDir.open_containing_tree_or_branch(
2134
file_id = _get_fileid_to_log(revision, tree, b, fp)
2127
filter_by_dir = False
2129
# find the file ids to log and check for directory filtering
2130
b, file_info_list, rev1, rev2 = _get_info_for_log_files(revision,
2132
for relpath, file_id, kind in file_info_list:
2135
2133
if file_id is None:
2136
2134
raise errors.BzrCommandError(
2137
2135
"Path unknown at end or start of revision range: %s" %
2137
# If the relpath is the top of the tree, we log everything
2142
file_ids.append(file_id)
2143
filter_by_dir = filter_by_dir or (
2144
kind in ['directory', 'tree-reference'])
2141
2147
# FIXME ? log the current subdir only RBC 20060203
2142
2148
if revision is not None \
2143
2149
and len(revision) > 0 and revision[0].get_branch():
2147
2153
dir, relpath = bzrdir.BzrDir.open_containing(location)
2148
2154
b = dir.open_branch()
2152
2155
rev1, rev2 = _get_revision_range(revision, b, self.name())
2157
# Decide on the type of delta & diff filtering to use
2158
# TODO: add an --all-files option to make this configurable & consistent
2166
diff_type = 'partial'
2172
# Build the log formatter
2153
2173
if log_format is None:
2154
2174
log_format = log.log_formatter_registry.get_default(b)
2156
2175
lf = log_format(show_ids=show_ids, to_file=self.outf,
2157
2176
show_timezone=timezone,
2158
2177
delta_format=get_verbosity_level(),
2165
direction=direction,
2166
start_revision=rev1,
2170
show_diff=show_diff)
2180
# Choose the algorithm for doing the logging. It's annoying
2181
# having multiple code paths like this but necessary until
2182
# the underlying repository format is faster at generating
2183
# deltas or can provide everything we need from the indices.
2184
# The default algorithm - match-using-deltas - works for
2185
# multiple files and directories and is faster for small
2186
# amounts of history (200 revisions say). However, it's too
2187
# slow for logging a single file in a repository with deep
2188
# history, i.e. > 10K revisions. In the spirit of "do no
2189
# evil when adding features", we continue to use the
2190
# original algorithm - per-file-graph - for the "single
2191
# file that isn't a directory without showing a delta" case.
2192
match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2195
# Build the LogRequest and execute it
2196
if len(file_ids) == 0:
2198
rqst = make_log_request_dict(
2199
direction=direction, specific_fileids=file_ids,
2200
start_revision=rev1, end_revision=rev2, limit=limit,
2201
message_search=message, delta_type=delta_type,
2202
diff_type=diff_type, _match_using_deltas=match_using_deltas)
2203
Logger(b, rqst).show(lf)
2176
2209
"""Take the input of a revision option and turn it into a revision range.
2178
2211
It returns RevisionInfo objects which can be used to obtain the rev_id's
2179
of the desired revisons. It does some user input validations.
2212
of the desired revisions. It does some user input validations.
2181
2214
if revisionspec_list is None:
5233
5266
urlutils.unescape_for_display(to_branch.base, 'utf-8'))
5269
class cmd_guess_renames(Command):
5270
"""Guess which files have been have been renamed, based on their content.
5272
Only versioned files which have been deleted are candidates for rename
5273
detection, and renames to ignored files will not be detected.
5277
work_tree, file_list = tree_files(None, default_branch='.')
5278
work_tree.lock_write()
5280
rename_map.RenameMap.guess_renames(work_tree)
5236
5285
class cmd_view(Command):
5237
5286
"""Manage filtered views.