Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
mercurial-devel
Commits
6991f3014311
Commit
6991f3014311
authored
4 years ago
by
Antoine cezar
Browse files
Options
Downloads
Patches
Plain Diff
rhg: strip copied files metadata from `cat` output
Differential Revision:
https://phab.mercurial-scm.org/D9264
parent
84eb4c833c41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rust/hg-core/src/operations/cat.rs
+14
-1
14 additions, 1 deletion
rust/hg-core/src/operations/cat.rs
tests/test-rhg.t
+16
-0
16 additions, 0 deletions
tests/test-rhg.t
with
30 additions
and
1 deletion
rust/hg-core/src/operations/cat.rs
+
14
−
1
View file @
6991f301
...
...
@@ -16,6 +16,8 @@
use
crate
::
revlog
::
Revision
;
use
crate
::
utils
::
hg_path
::
HgPathBuf
;
const
METADATA_DELIMITER
:
[
u8
;
2
]
=
[
b'\x01'
,
b'\n'
];
/// Kind of error encountered by `CatRev`
#[derive(Debug)]
pub
enum
CatRevErrorKind
{
...
...
@@ -132,7 +134,18 @@
.map_err
(|
_
|
CatRevErrorKind
::
CorruptedRevlog
)
?
;
let
file_rev
=
file_log
.get_node_rev
(
&
file_node
)
?
;
let
data
=
file_log
.get_rev_data
(
file_rev
)
?
;
bytes
.extend
(
data
);
if
data
.starts_with
(
&
METADATA_DELIMITER
)
{
let
end_delimiter_position
=
data
[
METADATA_DELIMITER
.len
()
..
]
.windows
(
METADATA_DELIMITER
.len
())
.position
(|
bytes
|
bytes
==
METADATA_DELIMITER
);
if
let
Some
(
position
)
=
end_delimiter_position
{
let
offset
=
METADATA_DELIMITER
.len
()
*
2
;
bytes
.extend
(
data
[
position
+
offset
..
]
.iter
());
}
}
else
{
bytes
.extend
(
data
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/test-rhg.t
+
16
−
0
View file @
6991f301
...
...
@@ -90,3 +90,19 @@
file1\x00b8e02
f6433738021a065f94175c7cd23db5f05be
(
esc
)
file2
\
x005d9299349fc01ddd25d0070d149b124d8f10411e
(
esc
)
file3
\
x002661d26c649684b482d10f91960cc3db683c38b4
(
esc
)
Cat
files
$
cd
$TESTTMP
$
rm
-
rf
repository
$
hg
init
repository
$
cd
repository
$
echo
"
original content
"
>
original
$
hg
add
original
$
hg
commit
-
m "add original"
original
$
rhg
cat
-
r
0
original
original
content
Cat
copied
file
should
not
display
copy
metadata
$
hg
copy
original
copy_of_original
$
hg
commit
-
m "add copy of original"
$
rhg
cat
-
r
1
copy_of_original
original
content
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment