Merge lp:~jelmer/brz/bzr-debug-commands 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/bzr-debug-commands
Merge into: lp:brz
Prerequisite: lp:~jelmer/brz/python3.7
Diff against target: 137 lines (+52/-46)
2 files modified
breezy/builtins.py (+3/-45)
breezy/bzr/debug_commands.py (+49/-1)
To merge this branch: bzr merge lp:~jelmer/brz/bzr-debug-commands
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+359781@code.launchpad.net

Commit message

Move file-id and file-path commands (specific to file ids) to breezy.bzr.debug_commands.

Description of the change

Move file-id and file-path commands (specific to file ids) to breezy.bzr.debug_commands.

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

Looks good. What happens if you run one of these on a non-fid format?

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> Looks good. What happens if you run one of these on a non-fid format?
You still get a file id, though it's not particularly meaningful. You'd e.g. get "git:blah" for file "blah"

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/builtins.py'
2--- breezy/builtins.py 2018-11-21 03:20:30 +0000
3+++ breezy/builtins.py 2018-11-28 20:04:58 +0000
4@@ -1923,50 +1923,6 @@
5 force=(file_deletion_strategy == 'no-backup'))
6
7
8-class cmd_file_id(Command):
9- __doc__ = """Print file_id of a particular file or directory.
10-
11- The file_id is assigned when the file is first added and remains the
12- same through all revisions where the file exists, even when it is
13- moved or renamed.
14- """
15-
16- hidden = True
17- _see_also = ['inventory', 'ls']
18- takes_args = ['filename']
19-
20- @display_command
21- def run(self, filename):
22- tree, relpath = WorkingTree.open_containing(filename)
23- file_id = tree.path2id(relpath)
24- if file_id is None:
25- raise errors.NotVersionedError(filename)
26- else:
27- self.outf.write(file_id.decode('utf-8') + '\n')
28-
29-
30-class cmd_file_path(Command):
31- __doc__ = """Print path of file_ids to a file or directory.
32-
33- This prints one line for each directory down to the target,
34- starting at the branch root.
35- """
36-
37- hidden = True
38- takes_args = ['filename']
39-
40- @display_command
41- def run(self, filename):
42- tree, relpath = WorkingTree.open_containing(filename)
43- fid = tree.path2id(relpath)
44- if fid is None:
45- raise errors.NotVersionedError(filename)
46- segments = osutils.splitpath(relpath)
47- for pos in range(1, len(segments) + 1):
48- path = osutils.joinpath(segments[:pos])
49- self.outf.write("%s\n" % tree.path2id(path))
50-
51-
52 class cmd_reconcile(Command):
53 __doc__ = """Reconcile brz metadata in a branch.
54
55@@ -2486,7 +2442,7 @@
56 class cmd_root(Command):
57 __doc__ = """Show the tree root directory.
58
59- The root is the nearest enclosing directory with a .bzr control
60+ The root is the nearest enclosing directory with a control
61 directory."""
62
63 takes_args = ['filename?']
64@@ -6878,6 +6834,8 @@
65 ('cmd_bundle_info', [], 'breezy.bundle.commands'),
66 ('cmd_config', [], 'breezy.config'),
67 ('cmd_dump_btree', [], 'breezy.bzr.debug_commands'),
68+ ('cmd_file_id', [], 'breezy.bzr.debug_commands'),
69+ ('cmd_file_path', [], 'breezy.bzr.debug_commands'),
70 ('cmd_version_info', [], 'breezy.cmd_version_info'),
71 ('cmd_resolve', ['resolved'], 'breezy.conflicts'),
72 ('cmd_conflicts', [], 'breezy.conflicts'),
73
74=== modified file 'breezy/bzr/debug_commands.py'
75--- breezy/bzr/debug_commands.py 2018-11-11 04:08:32 +0000
76+++ breezy/bzr/debug_commands.py 2018-11-28 20:04:58 +0000
77@@ -26,7 +26,11 @@
78 static_tuple,
79 transport,
80 )
81-from ..commands import Command
82+from ..workingtree import WorkingTree
83+from ..commands import (
84+ Command,
85+ display_command,
86+ )
87 from ..option import Option
88 from ..sixish import PY3
89 from . import (
90@@ -127,3 +131,47 @@
91 else:
92 as_tuple = (tuple(node[1]), node[2], refs_as_tuples)
93 self.outf.write('%s\n' % (as_tuple,))
94+
95+
96+class cmd_file_id(Command):
97+ __doc__ = """Print file_id of a particular file or directory.
98+
99+ The file_id is assigned when the file is first added and remains the
100+ same through all revisions where the file exists, even when it is
101+ moved or renamed.
102+ """
103+
104+ hidden = True
105+ _see_also = ['inventory', 'ls']
106+ takes_args = ['filename']
107+
108+ @display_command
109+ def run(self, filename):
110+ tree, relpath = WorkingTree.open_containing(filename)
111+ file_id = tree.path2id(relpath)
112+ if file_id is None:
113+ raise errors.NotVersionedError(filename)
114+ else:
115+ self.outf.write(file_id.decode('utf-8') + '\n')
116+
117+
118+class cmd_file_path(Command):
119+ __doc__ = """Print path of file_ids to a file or directory.
120+
121+ This prints one line for each directory down to the target,
122+ starting at the branch root.
123+ """
124+
125+ hidden = True
126+ takes_args = ['filename']
127+
128+ @display_command
129+ def run(self, filename):
130+ tree, relpath = WorkingTree.open_containing(filename)
131+ fid = tree.path2id(relpath)
132+ if fid is None:
133+ raise errors.NotVersionedError(filename)
134+ segments = osutils.splitpath(relpath)
135+ for pos in range(1, len(segments) + 1):
136+ path = osutils.joinpath(segments[:pos])
137+ self.outf.write("%s\n" % tree.path2id(path))

Subscribers

People subscribed via source and target branches