RFC new template keywords (wcmodified,wcmodifieddate) + sample impl.

Matt Mackall mpm at selenic.com
Tue May 31 10:10:38 CDT 2011


On Tue, 2011-05-31 at 16:24 +1000, Peter Bray wrote:
> On 31/05/11 01:22 AM, Matt Mackall wrote:
> > On Sun, 2011-05-29 at 16:32 +1000, Peter Bray wrote:
> >> Greetings,
> >>
> >> After over three years using Mercurial on half-a-dozen personal
> >> repositories I'm looking at including Mercurial version information in
> >> automated builds for larger projects, a la wiki/VersioningWithMake.
> >> The first project is XML-based documentation with C++ projects to follow.
> >>
> >> This has lead to the following observations (not criticisms) / questions
> >> which my reading has not provided me with decent solutions for:
> >>
> >> - Programmatically determining if the working copy is modified.
> >>
> >>     I have not discovered a simple way to determine if the working
> >>     copy of a repository has been modified. Think shell code like:
> >>     "if hg modified; then ... ", there seem to be many ways to get
> >>     the information, hg st | wc -l, looking for the + in hg id, etc.
> >>     Have I missed something obvious?
> >
> > Both hg id and hg st will miss out on two classes of change:
> >
> > - modified subrepos
> > - changed branch
> >
> > 'hg summary' will notice these on the commit: line.
> 
> Great Point.
> 
> > You seem to be looking for an exit code based method. I don't think we
> > have anything like that but I can imagine adding it to summary.
> 
> That would be an ideal spot.

Ok, what I'm suggesting here is that something like this could work:

hg summary > /dev/null || echo "working copy is dirty"

so that you can get at the dirty bit without grep/sed/etc. I'm not sure
if this is ideal, as summary is reporting a bunch of other things.

Another approach could be:

hg id --isclean || echo 'working copy is dirty'

This might be better, as id is the go-to command for this sort of thing
already. And it should probably be improved to note the other changes
that summary does.

>  I actually started with "hg summary", but
> it did not have a --template argument

Adding templating to non-log commands is a fairly big design
undertaking.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list