Merge lp:~jelmer/brz/cat-no-file-id into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/cat-no-file-id
Merge into: lp:brz
Diff against target: 69 lines (+21/-21)
1 file modified
breezy/builtins.py (+21/-21)
To merge this branch: bzr merge lp:~jelmer/brz/cat-no-file-id
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+358951@code.launchpad.net

Commit message

Avoid using file ids in cat; use find_previous_path instead.

Description of the change

Avoid using file ids in cat; use find_previous_path instead.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Looks reasonable, see inline comment about comment comment.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/builtins.py'
--- breezy/builtins.py 2018-11-16 18:35:30 +0000
+++ breezy/builtins.py 2018-11-18 12:07:59 +0000
@@ -54,6 +54,7 @@
54 symbol_versioning,54 symbol_versioning,
55 timestamp,55 timestamp,
56 transport,56 transport,
57 tree as _mod_tree,
57 ui,58 ui,
58 urlutils,59 urlutils,
59 views,60 views,
@@ -3432,38 +3433,37 @@
3432 rev_tree = _get_one_revision_tree('cat', revision, branch=b)3433 rev_tree = _get_one_revision_tree('cat', revision, branch=b)
3433 self.add_cleanup(rev_tree.lock_read().unlock)3434 self.add_cleanup(rev_tree.lock_read().unlock)
34343435
3435 old_file_id = rev_tree.path2id(relpath)
3436
3437 # TODO: Split out this code to something that generically finds the
3438 # best id for a path across one or more trees; it's like
3439 # find_ids_across_trees but restricted to find just one. -- mbp
3440 # 20110705.
3441 if name_from_revision:3436 if name_from_revision:
3442 # Try in revision if requested3437 # Try in revision if requested
3443 if old_file_id is None:3438 if not rev_tree.is_versioned(relpath):
3444 raise errors.BzrCommandError(gettext(3439 raise errors.BzrCommandError(gettext(
3445 "{0!r} is not present in revision {1}").format(3440 "{0!r} is not present in revision {1}").format(
3446 filename, rev_tree.get_revision_id()))3441 filename, rev_tree.get_revision_id()))
3447 else:3442 rev_tree_path = relpath
3448 actual_file_id = old_file_id
3449 else:3443 else:
3450 cur_file_id = tree.path2id(relpath)3444 try:
3451 if cur_file_id is not None and rev_tree.has_id(cur_file_id):3445 rev_tree_path = _mod_tree.find_previous_path(
3452 actual_file_id = cur_file_id3446 tree, rev_tree, relpath)
3453 elif old_file_id is not None:3447 except errors.NoSuchFile:
3454 actual_file_id = old_file_id3448 rev_tree_path = None
3455 else:3449
3456 raise errors.BzrCommandError(gettext(3450 if rev_tree_path is None:
3457 "{0!r} is not present in revision {1}").format(3451 # Path didn't exist in working tree
3458 filename, rev_tree.get_revision_id()))3452 if not rev_tree.is_versioned(relpath):
3459 relpath = rev_tree.id2path(actual_file_id)3453 raise errors.BzrCommandError(gettext(
3454 "{0!r} is not present in revision {1}").format(
3455 filename, rev_tree.get_revision_id()))
3456 else:
3457 # Fall back to the same path in the basis tree, if present.
3458 rev_tree_path = relpath
3459
3460 if filtered:3460 if filtered:
3461 from .filter_tree import ContentFilterTree3461 from .filter_tree import ContentFilterTree
3462 filter_tree = ContentFilterTree(3462 filter_tree = ContentFilterTree(
3463 rev_tree, rev_tree._content_filter_stack)3463 rev_tree, rev_tree._content_filter_stack)
3464 fileobj = filter_tree.get_file(relpath)3464 fileobj = filter_tree.get_file(rev_tree_path)
3465 else:3465 else:
3466 fileobj = rev_tree.get_file(relpath)3466 fileobj = rev_tree.get_file(rev_tree_path)
3467 shutil.copyfileobj(fileobj, self.outf)3467 shutil.copyfileobj(fileobj, self.outf)
3468 self.cleanup_now()3468 self.cleanup_now()
34693469

Subscribers

People subscribed via source and target branches