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
=== modified file 'breezy/builtins.py'
--- breezy/builtins.py 2018-11-21 03:20:30 +0000
+++ breezy/builtins.py 2018-11-28 20:04:58 +0000
@@ -1923,50 +1923,6 @@
1923 force=(file_deletion_strategy == 'no-backup'))1923 force=(file_deletion_strategy == 'no-backup'))
19241924
19251925
1926class cmd_file_id(Command):
1927 __doc__ = """Print file_id of a particular file or directory.
1928
1929 The file_id is assigned when the file is first added and remains the
1930 same through all revisions where the file exists, even when it is
1931 moved or renamed.
1932 """
1933
1934 hidden = True
1935 _see_also = ['inventory', 'ls']
1936 takes_args = ['filename']
1937
1938 @display_command
1939 def run(self, filename):
1940 tree, relpath = WorkingTree.open_containing(filename)
1941 file_id = tree.path2id(relpath)
1942 if file_id is None:
1943 raise errors.NotVersionedError(filename)
1944 else:
1945 self.outf.write(file_id.decode('utf-8') + '\n')
1946
1947
1948class cmd_file_path(Command):
1949 __doc__ = """Print path of file_ids to a file or directory.
1950
1951 This prints one line for each directory down to the target,
1952 starting at the branch root.
1953 """
1954
1955 hidden = True
1956 takes_args = ['filename']
1957
1958 @display_command
1959 def run(self, filename):
1960 tree, relpath = WorkingTree.open_containing(filename)
1961 fid = tree.path2id(relpath)
1962 if fid is None:
1963 raise errors.NotVersionedError(filename)
1964 segments = osutils.splitpath(relpath)
1965 for pos in range(1, len(segments) + 1):
1966 path = osutils.joinpath(segments[:pos])
1967 self.outf.write("%s\n" % tree.path2id(path))
1968
1969
1970class cmd_reconcile(Command):1926class cmd_reconcile(Command):
1971 __doc__ = """Reconcile brz metadata in a branch.1927 __doc__ = """Reconcile brz metadata in a branch.
19721928
@@ -2486,7 +2442,7 @@
2486class cmd_root(Command):2442class cmd_root(Command):
2487 __doc__ = """Show the tree root directory.2443 __doc__ = """Show the tree root directory.
24882444
2489 The root is the nearest enclosing directory with a .bzr control2445 The root is the nearest enclosing directory with a control
2490 directory."""2446 directory."""
24912447
2492 takes_args = ['filename?']2448 takes_args = ['filename?']
@@ -6878,6 +6834,8 @@
6878 ('cmd_bundle_info', [], 'breezy.bundle.commands'),6834 ('cmd_bundle_info', [], 'breezy.bundle.commands'),
6879 ('cmd_config', [], 'breezy.config'),6835 ('cmd_config', [], 'breezy.config'),
6880 ('cmd_dump_btree', [], 'breezy.bzr.debug_commands'),6836 ('cmd_dump_btree', [], 'breezy.bzr.debug_commands'),
6837 ('cmd_file_id', [], 'breezy.bzr.debug_commands'),
6838 ('cmd_file_path', [], 'breezy.bzr.debug_commands'),
6881 ('cmd_version_info', [], 'breezy.cmd_version_info'),6839 ('cmd_version_info', [], 'breezy.cmd_version_info'),
6882 ('cmd_resolve', ['resolved'], 'breezy.conflicts'),6840 ('cmd_resolve', ['resolved'], 'breezy.conflicts'),
6883 ('cmd_conflicts', [], 'breezy.conflicts'),6841 ('cmd_conflicts', [], 'breezy.conflicts'),
68846842
=== modified file 'breezy/bzr/debug_commands.py'
--- breezy/bzr/debug_commands.py 2018-11-11 04:08:32 +0000
+++ breezy/bzr/debug_commands.py 2018-11-28 20:04:58 +0000
@@ -26,7 +26,11 @@
26 static_tuple,26 static_tuple,
27 transport,27 transport,
28 )28 )
29from ..commands import Command29from ..workingtree import WorkingTree
30from ..commands import (
31 Command,
32 display_command,
33 )
30from ..option import Option34from ..option import Option
31from ..sixish import PY335from ..sixish import PY3
32from . import (36from . import (
@@ -127,3 +131,47 @@
127 else:131 else:
128 as_tuple = (tuple(node[1]), node[2], refs_as_tuples)132 as_tuple = (tuple(node[1]), node[2], refs_as_tuples)
129 self.outf.write('%s\n' % (as_tuple,))133 self.outf.write('%s\n' % (as_tuple,))
134
135
136class cmd_file_id(Command):
137 __doc__ = """Print file_id of a particular file or directory.
138
139 The file_id is assigned when the file is first added and remains the
140 same through all revisions where the file exists, even when it is
141 moved or renamed.
142 """
143
144 hidden = True
145 _see_also = ['inventory', 'ls']
146 takes_args = ['filename']
147
148 @display_command
149 def run(self, filename):
150 tree, relpath = WorkingTree.open_containing(filename)
151 file_id = tree.path2id(relpath)
152 if file_id is None:
153 raise errors.NotVersionedError(filename)
154 else:
155 self.outf.write(file_id.decode('utf-8') + '\n')
156
157
158class cmd_file_path(Command):
159 __doc__ = """Print path of file_ids to a file or directory.
160
161 This prints one line for each directory down to the target,
162 starting at the branch root.
163 """
164
165 hidden = True
166 takes_args = ['filename']
167
168 @display_command
169 def run(self, filename):
170 tree, relpath = WorkingTree.open_containing(filename)
171 fid = tree.path2id(relpath)
172 if fid is None:
173 raise errors.NotVersionedError(filename)
174 segments = osutils.splitpath(relpath)
175 for pos in range(1, len(segments) + 1):
176 path = osutils.joinpath(segments[:pos])
177 self.outf.write("%s\n" % tree.path2id(path))

Subscribers

People subscribed via source and target branches