track empty directory convention?

17 views
Skip to first unread message

Mihamina Rakotomandimby

unread,
Sep 22, 2011, 10:33:12 AM9/22/11
to Mercurial
HI all,

What is the convention for tracking empty dirs?
Many docs on the web are talking about putting an .hgignore in the dir.

Is it just a wide usage or something mentionned somewhere officially?

I'm training some trainnes to good habits & practice, I need to know the
Hg official way to do things.

Thank you.

--
RMA.
_______________________________________________
Mercurial mailing list
Merc...@selenic.com
http://selenic.com/mailman/listinfo/mercurial

Martin Geisler

unread,
Sep 22, 2011, 11:12:14 AM9/22/11
to Mihamina Rakotomandimby, Mercurial
Mihamina Rakotomandimby <miha...@rktmb.org> writes:

> HI all,
>
> What is the convention for tracking empty dirs? Many docs on the web
> are talking about putting an .hgignore in the dir.
>
> Is it just a wide usage or something mentionned somewhere officially?
>
> I'm training some trainnes to good habits & practice, I need to know
> the Hg official way to do things.

I've never seen a guide that suggests putting a '.hgignore' file into an
empty directory -- but I've seen several guides that suggest '.keep' as
the filename.

But really, the most official way to do this is to stop tracking empty
directories: let the build system create them as needed instead.

--
Martin Geisler

aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/

Benoît Allard

unread,
Sep 22, 2011, 11:14:44 AM9/22/11
to Mihamina Rakotomandimby, Mercurial
On 9/22/2011 4:33 PM, Mihamina Rakotomandimby wrote:
> HI all,
>
> What is the convention for tracking empty dirs?
> Many docs on the web are talking about putting an .hgignore in the dir.
>
> Is it just a wide usage or something mentionned somewhere officially?
>
> I'm training some trainnes to good habits & practice, I need to know the
> Hg official way to do things.
>

The official way is to teach your Makefile to create them when they are
needed ... I doubt the .hgignore trick is mentioned somewhere as this
file has a special meaning, but only at the root of the repository ...

Regards,
Benoit

Mihamina Rakotomandimby

unread,
Sep 22, 2011, 11:16:25 AM9/22/11
to Mercurial
On 09/22/2011 06:12 PM, Martin Geisler wrote:
> I've never seen a guide that suggests putting a '.hgignore' file into an
> empty directory -- but I've seen several guides that suggest '.keep' as
> the filename.

If I search (Google) on "mercurial track empty directory", I find
several resultats advising creating such a file.
--
RMA.

Martin Geisler

unread,
Sep 22, 2011, 12:44:31 PM9/22/11
to Mihamina Rakotomandimby, Mercurial
Mihamina Rakotomandimby <miha...@rktmb.org> writes:

> On 09/22/2011 06:12 PM, Martin Geisler wrote:
>> I've never seen a guide that suggests putting a '.hgignore' file into an
>> empty directory -- but I've seen several guides that suggest '.keep' as
>> the filename.
>
> If I search (Google) on "mercurial track empty directory", I find
> several resultats advising creating such a file.

Okay, that's surprising since that particular filename is used for the
file in which you list ignore patterns. I find

http://hgbook.red-bean.com/read/mercurial-in-daily-use.html
http://mercurial.selenic.com/wiki/FAQ
http://mercurial.selenic.com/bts/issue521
http://der-design.com/mercurial/track-emtpy-directories-scm
http://stackoverflow.com/questions/4805098/how-to-commit-empty-folders-to-a-mercurial-repository

but they don't mention '.hgignore' in relation to empty directories.

--
Martin Geisler

Mercurial links: http://mercurial.ch/

Matt Mackall

unread,
Sep 22, 2011, 4:16:08 PM9/22/11
to Martin Geisler, Mercurial

This is actually standard advice in Git-land, which has
per-directory .gitignore files and also doesn't track empty directories.
So it's not at all surprising that someone would incorrectly translate
that advice to Mercurial.

But any file that makes an empty directory non-empty will work.

--
Mathematics is the supreme nostalgia of our time.

Jason Harris

unread,
Sep 22, 2011, 5:16:29 PM9/22/11
to Matt Mackall, Mercurial

On Sep 23, 2011, at 8:16 AM, Matt Mackall wrote:

> On Thu, 2011-09-22 at 18:44 +0200, Martin Geisler wrote:
>> Mihamina Rakotomandimby <miha...@rktmb.org> writes:
>>
>>> On 09/22/2011 06:12 PM, Martin Geisler wrote:
>>>> I've never seen a guide that suggests putting a '.hgignore' file into an
>>>> empty directory -- but I've seen several guides that suggest '.keep' as
>>>> the filename.
>>>
>>> If I search (Google) on "mercurial track empty directory", I find
>>> several resultats advising creating such a file.
>>
>> Okay, that's surprising since that particular filename is used for the
>> file in which you list ignore patterns. I find
>>
>> http://hgbook.red-bean.com/read/mercurial-in-daily-use.html
>> http://mercurial.selenic.com/wiki/FAQ
>> http://mercurial.selenic.com/bts/issue521
>> http://der-design.com/mercurial/track-emtpy-directories-scm
>> http://stackoverflow.com/questions/4805098/how-to-commit-empty-folders-to-a-mercurial-repository
>>
>> but they don't mention '.hgignore' in relation to empty directories.
>
> This is actually standard advice in Git-land, which has
> per-directory .gitignore files and also doesn't track empty directories.
> So it's not at all surprising that someone would incorrectly translate
> that advice to Mercurial.
>
> But any file that makes an empty directory non-empty will work.

I have thought about adding this sort of functionality to MacHg so people can add empty directories. (A number of users have requested this of MacHg.) In fact for users that don't really know much about Mercurial it's one of the first problems they stumble across...

It would be handy if there was a convention that was "the-standard" which was decreed by you / the community. That way GUI clients could automatically use this convention.

I of course could use .hidden, but it might be nice to have hg in the name like .hghidden, or .hgdummyfile, or something like that...

Cheers,
Jas

Harvey Chapman

unread,
Sep 22, 2011, 5:23:04 PM9/22/11
to mercurial
On Sep 22, 2011, at 5:16 PM, Jason Harris wrote:

> I of course could use .hidden, but it might be nice to have hg in the name like .hghidden, or .hgdummyfile, or something like that…

I've seen and used .empty. I think the file should not reference mercurial in any way.

Arne Babenhauserheide

unread,
Sep 23, 2011, 1:42:02 AM9/23/11
to merc...@selenic.com
Am Freitag, 23. September 2011, 09:16:29 schrieb Jason Harris:
> It would be handy if there was a convention that was "the-standard" which
> was decreed by you / the community. That way GUI clients could
> automatically use this convention.

I know .keep; it is also used in my Gentoo GNU/Linux installation for empty
configuration directories.

Best wishes,
Arne
--
Ein Würfel System - einfach saubere Regeln:

- http://1w6.org

signature.asc

Didly

unread,
Sep 23, 2011, 4:31:38 AM9/23/11
to Arne Babenhauserheide, merc...@selenic.com
On Fri, Sep 23, 2011 at 7:42 AM, Arne Babenhauserheide <arne...@web.de> wrote:
> Am Freitag, 23. September 2011, 09:16:29 schrieb Jason Harris:
>> It would be handy if there was a convention that was "the-standard" which
>> was decreed by you / the community. That way GUI clients could
>> automatically use this convention.
>
> I know .keep; it is also used in my Gentoo GNU/Linux installation for empty
> configuration directories.

Personally I really don't like "littering" the source tree with .keep
files just to overcome one of the few limitations of Mercurial.

A solution that I'd very much prefer is to have a single .hgkeep or
.hgempty file on the top of the repository, containing a list of
folders that must exist on a given revision. This file could be read
by an extension which would make create the folders as needed on
update.

This .hgkeep file would be version controlled, thus properly tracking
your empty folders in your history.

A long time ago, before I started contributing to TortoiseHg I wrote
such an extension, which I called "hgremap". It was not limited to
creating empty folders, but it could also automatically copy (what I
called "remap") any version controlled file into some other location
in the repository. This could be useful for example, to have some file
templates tracked by mercurial, while the actual files used for your
build are not (so that you can modify them locally).

You can find this extension in BitBucket at:
https://bitbucket.org/AngelEzquerra/hg-remap-extension. The extension
is not very polished but it should work, or at least is worked for me
when I needed it. Maybe it could prove useful as an starting point for
someone else...

Cheers,

Angel

Arne Babenhauserheide

unread,
Sep 23, 2011, 6:44:40 AM9/23/11
to Didly, merc...@selenic.com
Am Freitag, 23. September 2011, 10:31:38 schrieb Didly:
> You can find this extension in BitBucket at:
> https://bitbucket.org/AngelEzquerra/hg-remap-extension. The extension
> is not very polished but it should work, or at least is worked for me
> when I needed it. Maybe it could prove useful as an starting point for
> someone else...

That’s nice. Did you put it into the hg wiki?

Best wishes,
Arne
--
Ich hab' nichts zu verbergen – hab ich gedacht:

- http://draketo.de/licht/lieder/ich-hab-nichts-zu-verbergen

signature.asc

Didly

unread,
Sep 23, 2011, 7:43:06 AM9/23/11
to Arne Babenhauserheide, merc...@selenic.com
On Fri, Sep 23, 2011 at 12:44 PM, Arne Babenhauserheide <arne...@web.de> wrote:
> Am Freitag, 23. September 2011, 10:31:38 schrieb Didly:
>> You can find this extension in BitBucket at:
>> https://bitbucket.org/AngelEzquerra/hg-remap-extension. The extension
>> is not very polished but it should work, or at least is worked for me
>> when I needed it. Maybe it could prove useful as an starting point for
>> someone else...
>
> That’s nice. Did you put it into the hg wiki?
>
> Best wishes,
> Arne

No, I didn't . I didn't feel that it was polished enough... Maybe I
should look into it and see if I can polish it a bit...

Arne Babenhauserheide

unread,
Sep 23, 2011, 1:21:12 PM9/23/11
to Didly, merc...@selenic.com
Am Freitag, 23. September 2011, 13:43:06 schrieb Didly:
> On Fri, Sep 23, 2011 at 12:44 PM, Arne Babenhauserheide <arne...@web.de>
wrote:
> > Am Freitag, 23. September 2011, 10:31:38 schrieb Didly:
> >> You can find this extension in BitBucket at:
> >> https://bitbucket.org/AngelEzquerra/hg-remap-extension. The extension
> >> is not very polished but it should work, or at least is worked for me
> >> when I needed it. Maybe it could prove useful as an starting point for
> >> someone else...
> >
> > That’s nice. Did you put it into the hg wiki?

> No, I didn't . I didn't feel that it was polished enough... Maybe I


> should look into it and see if I can polish it a bit...

Please do!

I wanted to do something to fix the no-track-dirs for years, but never got
around to implementing it. And now that we get large file support in core, it
might be time to enable simple tracking of directories.

Best wishes,
Arne
--
A man in the streets faces a knife.
Two policemen are there it once. They raise a sign:

“Illegal Scene! Noone may watch this!”

The man gets robbed and stabbed and bleeds to death.
The police had to hold the sign.

…Welcome to Europe, citizen. Censorship is beautiful.

( http://draketo.de/stichwort/censorship )


signature.asc

Haszlakiewicz, Eric

unread,
Sep 28, 2011, 2:42:37 PM9/28/11
to Didly, Arne Babenhauserheide, merc...@selenic.com
> -----Original Message-----
> From: mercuria...@selenic.com [mailto:mercurial-
>
> On Fri, Sep 23, 2011 at 7:42 AM, Arne Babenhauserheide
> <arne...@web.de> wrote:
> Personally I really don't like "littering" the source tree with .keep
> files just to overcome one of the few limitations of Mercurial.
>
> A solution that I'd very much prefer is to have a single .hgkeep or
> .hgempty file on the top of the repository, containing a list of
> folders that must exist on a given revision. This file could be read
> by an extension which would make create the folders as needed on
> update.

ugh, that's a little gross. Of course, extend this just a bit so "hg add somedir" and "hg rm somedir" operate on it, put the file in the .hg/ directory, and you've essentially taught mercurial real support for tracking directories. :)

eric

Reply all
Reply to author
Forward
0 new messages