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
707c5888
Commit
707c5888
authored
3 years ago
by
Pulkit Goyal
Browse files
Options
Downloads
Patches
Plain Diff
rhg: add relative paths support in `rhg status`
Differential Revision:
https://phab.mercurial-scm.org/D11614
parent
9ecf802b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rust/rhg/src/commands/status.rs
+37
-14
37 additions, 14 deletions
rust/rhg/src/commands/status.rs
with
37 additions
and
14 deletions
rust/rhg/src/commands/status.rs
+
37
−
14
View file @
707c5888
...
...
@@ -6,6 +6,7 @@
// GNU General Public License version 2 or any later version.
use
crate
::
error
::
CommandError
;
use
crate
::
ui
::
Ui
;
use
crate
::
ui
::{
Ui
,
UiError
};
use
crate
::
utils
::
path_utils
::
relativize_paths
;
use
clap
::{
Arg
,
SubCommand
};
use
hg
;
...
...
@@ -10,5 +11,6 @@
use
clap
::{
Arg
,
SubCommand
};
use
hg
;
use
hg
::
config
::
Config
;
use
hg
::
errors
::
HgError
;
use
hg
::
manifest
::
Manifest
;
use
hg
::
matchers
::
AlwaysMatcher
;
...
...
@@ -16,6 +18,7 @@
use
hg
::
utils
::
hg_path
::{
hg_path_to_os_string
,
HgPath
};
use
hg
::{
HgPathCow
,
StatusOptions
};
use
log
::{
info
,
warn
};
use
std
::
borrow
::
Cow
;
pub
const
HELP_TEXT
:
&
str
=
"
Show changed files in the working directory
...
...
@@ -146,6 +149,7 @@
}
let
ui
=
invocation
.ui
;
let
config
=
invocation
.config
;
let
args
=
invocation
.subcommand_args
;
let
display_states
=
if
args
.is_present
(
"all"
)
{
// TODO when implementing `--quiet`: it excludes clean files
...
...
@@ -225,6 +229,6 @@
}
}
if
display_states
.modified
{
display_status_paths
(
ui
,
&
mut
ds_status
.modified
,
b"M"
)
?
;
display_status_paths
(
ui
,
repo
,
config
,
&
mut
ds_status
.modified
,
b"M"
)
?
;
}
if
display_states
.added
{
...
...
@@ -229,5 +233,5 @@
}
if
display_states
.added
{
display_status_paths
(
ui
,
&
mut
ds_status
.added
,
b"A"
)
?
;
display_status_paths
(
ui
,
repo
,
config
,
&
mut
ds_status
.added
,
b"A"
)
?
;
}
if
display_states
.removed
{
...
...
@@ -232,5 +236,5 @@
}
if
display_states
.removed
{
display_status_paths
(
ui
,
&
mut
ds_status
.removed
,
b"R"
)
?
;
display_status_paths
(
ui
,
repo
,
config
,
&
mut
ds_status
.removed
,
b"R"
)
?
;
}
if
display_states
.deleted
{
...
...
@@ -235,5 +239,5 @@
}
if
display_states
.deleted
{
display_status_paths
(
ui
,
&
mut
ds_status
.deleted
,
b"!"
)
?
;
display_status_paths
(
ui
,
repo
,
config
,
&
mut
ds_status
.deleted
,
b"!"
)
?
;
}
if
display_states
.unknown
{
...
...
@@ -238,5 +242,5 @@
}
if
display_states
.unknown
{
display_status_paths
(
ui
,
&
mut
ds_status
.unknown
,
b"?"
)
?
;
display_status_paths
(
ui
,
repo
,
config
,
&
mut
ds_status
.unknown
,
b"?"
)
?
;
}
if
display_states
.ignored
{
...
...
@@ -241,5 +245,5 @@
}
if
display_states
.ignored
{
display_status_paths
(
ui
,
&
mut
ds_status
.ignored
,
b"I"
)
?
;
display_status_paths
(
ui
,
repo
,
config
,
&
mut
ds_status
.ignored
,
b"I"
)
?
;
}
if
display_states
.clean
{
...
...
@@ -244,6 +248,6 @@
}
if
display_states
.clean
{
display_status_paths
(
ui
,
&
mut
ds_status
.clean
,
b"C"
)
?
;
display_status_paths
(
ui
,
repo
,
config
,
&
mut
ds_status
.clean
,
b"C"
)
?
;
}
Ok
(())
}
...
...
@@ -252,7 +256,9 @@
// harcode HgPathBuf, but probably not really useful at this point
fn
display_status_paths
(
ui
:
&
Ui
,
repo
:
&
Repo
,
config
:
&
Config
,
paths
:
&
mut
[
HgPathCow
],
status_prefix
:
&
[
u8
],
)
->
Result
<
(),
CommandError
>
{
paths
.sort_unstable
();
...
...
@@ -255,13 +261,30 @@
paths
:
&
mut
[
HgPathCow
],
status_prefix
:
&
[
u8
],
)
->
Result
<
(),
CommandError
>
{
paths
.sort_unstable
();
for
path
in
paths
{
// Same TODO as in commands::root
let
bytes
:
&
[
u8
]
=
path
.as_bytes
();
// TODO optim, probably lots of unneeded copies here, especially
// if out stream is buffered
ui
.write_stdout
(
&
[
status_prefix
,
b" "
,
bytes
,
b"
\n
"
]
.concat
())
?
;
let
mut
relative
:
bool
=
config
.get_bool
(
b"ui"
,
b"relative-paths"
)
.unwrap_or
(
false
);
relative
=
config
.get_bool
(
b"commands"
,
b"status.relative"
)
.unwrap_or
(
relative
);
if
relative
{
relativize_paths
(
repo
,
paths
,
|
path
:
Cow
<
[
u8
]
>
|
->
Result
<
(),
UiError
>
{
ui
.write_stdout
(
&
[
status_prefix
,
b" "
,
path
.as_ref
(),
b"
\n
"
]
.concat
(),
)
},
)
?
;
}
else
{
for
path
in
paths
{
// Same TODO as in commands::root
let
bytes
:
&
[
u8
]
=
path
.as_bytes
();
// TODO optim, probably lots of unneeded copies here, especially
// if out stream is buffered
ui
.write_stdout
(
&
[
status_prefix
,
b" "
,
bytes
,
b"
\n
"
]
.concat
())
?
;
}
}
Ok
(())
}
...
...
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