/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

  • Committer: Robert Collins
  • Date: 2009-03-27 04:10:25 UTC
  • mfrom: (4208 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4216.
  • Revision ID: robertc@robertcollins.net-20090327041025-rgutx4q03xo4pq6l
Resolve NEWS conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
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
16
16
 
17
17
"""builtin bzr commands"""
18
18
 
41
41
    merge_directive,
42
42
    osutils,
43
43
    reconfigure,
 
44
    rename_map,
44
45
    revision as _mod_revision,
45
46
    symbol_versioning,
46
47
    transport,
1976
1977
 
1977
1978
    :Path filtering:
1978
1979
 
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
1981
 
      directory.
 
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.
1982
1983
 
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).
2009
2010
 
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.)
2014
 
 
2015
2011
    :Other filtering:
2016
2012
 
2017
2013
      The --message option can be used for finding revisions that match a
2032
2028
 
2033
2029
        [ALIASES]
2034
2030
        tip = log -r-1 -n1
2035
 
        top = log -r-10.. --short --forward
 
2031
        top = log -l10 --line
2036
2032
        show = log -v -p -n1 --long
2037
2033
 
2038
2034
      ``bzr tip`` will then show the latest revision while ``bzr top``
2062
2058
      the revnocache plugin. This plugin buffers historical information
2063
2059
      trading disk space for faster speed.
2064
2060
    """
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'
2101
2097
 
2102
2098
    @display_command
2103
 
    def run(self, location=None, timezone='original',
 
2099
    def run(self, file_list=None, timezone='original',
2104
2100
            verbose=False,
2105
2101
            show_ids=False,
2106
2102
            forward=False,
2111
2107
            message=None,
2112
2108
            limit=None,
2113
2109
            show_diff=False):
2114
 
        from bzrlib.log import show_log, _get_fileid_to_log
 
2110
        from bzrlib.log import (
 
2111
            Logger,
 
2112
            make_log_request_dict,
 
2113
            _get_info_for_log_files,
 
2114
            )
2115
2115
        direction = (forward and 'forward') or 'reverse'
2116
2116
 
2117
2117
        if change is not None:
2123
2123
            else:
2124
2124
                revision = change
2125
2125
 
2126
 
        # log everything
2127
 
        file_id = None
2128
 
        if location:
2129
 
            # find the file id to log:
2130
 
 
2131
 
            tree, b, fp = bzrdir.BzrDir.open_containing_tree_or_branch(
2132
 
                location)
2133
 
            if fp != '':
2134
 
                file_id = _get_fileid_to_log(revision, tree, b, fp)
 
2126
        file_ids = []
 
2127
        filter_by_dir = False
 
2128
        if file_list:
 
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,
 
2131
                file_list)
 
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" %
2138
 
                        location)
 
2136
                        relpath)
 
2137
                # If the relpath is the top of the tree, we log everything
 
2138
                if relpath == '':
 
2139
                    file_ids = []
 
2140
                    break
 
2141
                else:
 
2142
                    file_ids.append(file_id)
 
2143
                filter_by_dir = filter_by_dir or (
 
2144
                    kind in ['directory', 'tree-reference'])
2139
2145
        else:
2140
 
            # local dir only
 
2146
            # log everything
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():
2146
2152
                location = '.'
2147
2153
            dir, relpath = bzrdir.BzrDir.open_containing(location)
2148
2154
            b = dir.open_branch()
2149
 
 
2150
 
        b.lock_read()
2151
 
        try:
2152
2155
            rev1, rev2 = _get_revision_range(revision, b, self.name())
 
2156
 
 
2157
        # Decide on the type of delta & diff filtering to use
 
2158
        # TODO: add an --all-files option to make this configurable & consistent
 
2159
        if not verbose:
 
2160
            delta_type = None
 
2161
        else:
 
2162
            delta_type = 'full'
 
2163
        if not show_diff:
 
2164
            diff_type = None
 
2165
        elif file_ids:
 
2166
            diff_type = 'partial'
 
2167
        else:
 
2168
            diff_type = 'full'
 
2169
 
 
2170
        b.lock_read()
 
2171
        try:
 
2172
            # Build the log formatter
2153
2173
            if log_format is None:
2154
2174
                log_format = log.log_formatter_registry.get_default(b)
2155
 
 
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(),
2159
2178
                            levels=levels)
2160
2179
 
2161
 
            show_log(b,
2162
 
                     lf,
2163
 
                     file_id,
2164
 
                     verbose=verbose,
2165
 
                     direction=direction,
2166
 
                     start_revision=rev1,
2167
 
                     end_revision=rev2,
2168
 
                     search=message,
2169
 
                     limit=limit,
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
 
2193
                or delta_type)
 
2194
 
 
2195
            # Build the LogRequest and execute it
 
2196
            if len(file_ids) == 0:
 
2197
                file_ids = None
 
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)
2171
2204
        finally:
2172
2205
            b.unlock()
2173
2206
 
2176
2209
    """Take the input of a revision option and turn it into a revision range.
2177
2210
 
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.
2180
2213
    """
2181
2214
    if revisionspec_list is None:
2182
2215
        rev1 = None
5233
5266
            urlutils.unescape_for_display(to_branch.base, 'utf-8'))
5234
5267
 
5235
5268
 
 
5269
class cmd_guess_renames(Command):
 
5270
    """Guess which files have been have been renamed, based on their content.
 
5271
 
 
5272
    Only versioned files which have been deleted are candidates for rename
 
5273
    detection, and renames to ignored files will not be detected.
 
5274
    """
 
5275
 
 
5276
    def run(self):
 
5277
        work_tree, file_list = tree_files(None, default_branch='.')
 
5278
        work_tree.lock_write()
 
5279
        try:
 
5280
            rename_map.RenameMap.guess_renames(work_tree)
 
5281
        finally:
 
5282
            work_tree.unlock()
 
5283
 
 
5284
 
5236
5285
class cmd_view(Command):
5237
5286
    """Manage filtered views.
5238
5287