~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-29 22:00:43 UTC
  • mfrom: (4776.1.1 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091029220043-u2qbo0ci5867xniz
(jam) Merge lp:bzr/2.0 4696 into lp:bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
2276
2276
 
2277
2277
        file_ids = []
2278
2278
        filter_by_dir = False
2279
 
        if file_list:
2280
 
            # find the file ids to log and check for directory filtering
2281
 
            b, file_info_list, rev1, rev2 = _get_info_for_log_files(revision,
2282
 
                file_list)
2283
 
            for relpath, file_id, kind in file_info_list:
2284
 
                if file_id is None:
2285
 
                    raise errors.BzrCommandError(
2286
 
                        "Path unknown at end or start of revision range: %s" %
2287
 
                        relpath)
2288
 
                # If the relpath is the top of the tree, we log everything
2289
 
                if relpath == '':
2290
 
                    file_ids = []
2291
 
                    break
 
2279
        b = None
 
2280
        try:
 
2281
            if file_list:
 
2282
                # find the file ids to log and check for directory filtering
 
2283
                b, file_info_list, rev1, rev2 = _get_info_for_log_files(
 
2284
                    revision, file_list)
 
2285
                for relpath, file_id, kind in file_info_list:
 
2286
                    if file_id is None:
 
2287
                        raise errors.BzrCommandError(
 
2288
                            "Path unknown at end or start of revision range: %s" %
 
2289
                            relpath)
 
2290
                    # If the relpath is the top of the tree, we log everything
 
2291
                    if relpath == '':
 
2292
                        file_ids = []
 
2293
                        break
 
2294
                    else:
 
2295
                        file_ids.append(file_id)
 
2296
                    filter_by_dir = filter_by_dir or (
 
2297
                        kind in ['directory', 'tree-reference'])
 
2298
            else:
 
2299
                # log everything
 
2300
                # FIXME ? log the current subdir only RBC 20060203
 
2301
                if revision is not None \
 
2302
                        and len(revision) > 0 and revision[0].get_branch():
 
2303
                    location = revision[0].get_branch()
2292
2304
                else:
2293
 
                    file_ids.append(file_id)
2294
 
                filter_by_dir = filter_by_dir or (
2295
 
                    kind in ['directory', 'tree-reference'])
2296
 
        else:
2297
 
            # log everything
2298
 
            # FIXME ? log the current subdir only RBC 20060203
2299
 
            if revision is not None \
2300
 
                    and len(revision) > 0 and revision[0].get_branch():
2301
 
                location = revision[0].get_branch()
2302
 
            else:
2303
 
                location = '.'
2304
 
            dir, relpath = bzrdir.BzrDir.open_containing(location)
2305
 
            b = dir.open_branch()
2306
 
            rev1, rev2 = _get_revision_range(revision, b, self.name())
2307
 
 
2308
 
        # Decide on the type of delta & diff filtering to use
2309
 
        # TODO: add an --all-files option to make this configurable & consistent
2310
 
        if not verbose:
2311
 
            delta_type = None
2312
 
        else:
2313
 
            delta_type = 'full'
2314
 
        if not show_diff:
2315
 
            diff_type = None
2316
 
        elif file_ids:
2317
 
            diff_type = 'partial'
2318
 
        else:
2319
 
            diff_type = 'full'
2320
 
 
2321
 
        b.lock_read()
2322
 
        try:
 
2305
                    location = '.'
 
2306
                dir, relpath = bzrdir.BzrDir.open_containing(location)
 
2307
                b = dir.open_branch()
 
2308
                b.lock_read()
 
2309
                rev1, rev2 = _get_revision_range(revision, b, self.name())
 
2310
 
 
2311
            # Decide on the type of delta & diff filtering to use
 
2312
            # TODO: add an --all-files option to make this configurable & consistent
 
2313
            if not verbose:
 
2314
                delta_type = None
 
2315
            else:
 
2316
                delta_type = 'full'
 
2317
            if not show_diff:
 
2318
                diff_type = None
 
2319
            elif file_ids:
 
2320
                diff_type = 'partial'
 
2321
            else:
 
2322
                diff_type = 'full'
 
2323
 
2323
2324
            # Build the log formatter
2324
2325
            if log_format is None:
2325
2326
                log_format = log.log_formatter_registry.get_default(b)
2355
2356
                diff_type=diff_type, _match_using_deltas=match_using_deltas)
2356
2357
            Logger(b, rqst).show(lf)
2357
2358
        finally:
2358
 
            b.unlock()
 
2359
            if b is not None:
 
2360
                b.unlock()
2359
2361
 
2360
2362
 
2361
2363
def _get_revision_range(revisionspec_list, branch, command_name):
2425
2427
    @display_command
2426
2428
    def run(self, filename):
2427
2429
        tree, relpath = WorkingTree.open_containing(filename)
 
2430
        file_id = tree.path2id(relpath)
2428
2431
        b = tree.branch
2429
 
        file_id = tree.path2id(relpath)
2430
 
        for revno, revision_id, what in log.find_touching_revisions(b, file_id):
2431
 
            self.outf.write("%6d %s\n" % (revno, what))
 
2432
        b.lock_read()
 
2433
        try:
 
2434
            touching_revs = log.find_touching_revisions(b, file_id)
 
2435
            for revno, revision_id, what in touching_revs:
 
2436
                self.outf.write("%6d %s\n" % (revno, what))
 
2437
        finally:
 
2438
            b.unlock()
2432
2439
 
2433
2440
 
2434
2441
class cmd_ls(Command):