简体   繁体   中英

Mercurial: Hg Status - Do you know how to report file name only (no path) on Windows OS?

When I run Hg status I get a listing something like the following:

M proj\Content\Site.css
M proj\Views\DoThing\DoThing.cshtml
M proj\Views\MainThing\MainThing.cshtml
M proj\Views\GetThing\GetThing.cshtml
M proj\Views\ViewThing\Index.cshtml
M proj\Views\Home\Index.cshtml
M proj\Views\Shared\_Layout.cshtml
M proj\js\extra.js

Does anyone know how to run hg status and easily get just the filnames to be listed -- sans the path info? Something like:

  M Site.css
  M DoThing.cshtml
  M MainThing.cshtml
  M GetThing.cshtml
  M Index.cshtml
  M Index.cshtml
  M _Layout.cshtml
  M extra.js

Or, if you have some quick way of piping this through some command-line thing like findstr or something which will easily and quickly strip off the path, let me know.

I need the final format shown. Anyone? Anyone?

If you have Mercurial 3.5 installed (ie the most recent version as of the time of this writing), you can use the experimental status templates. Use hg help status -v to see if there's a --template option. If so, use:

hg status -T '{status} {path|basename}\n{if(copy, "  {copy}\n")}'

This is the normal status output, except that {path} has been replaced with {path|basename} .

If you can use sed

Extract the file path and replace with file name

hg status | sed "s/ .*\\\(.*\)\.\(.*\)/ \1.\2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM