2

I'm in this situation:

First of all I just started to use mercurial. I've a server where there's a my django project.

I want to clone repository from the project dir on server in my local computer.

I've done this:

user@host> cd myproject
user@host> hg init
user@host> hg add
user@host> hg commit -m "Added initial files."

I've cloned the repo with hg clone ssh://user@host//path/to/project. And it's ok, on my computer I've all files that I've on the server.

Now, I want to edit settings.py for setting local environment (database engine and other stuff), but I don't want to update the settings.py on the server. And after the edit, hg status returns me M settings.py. Even if I set echo 'settings.py' > .hgignore in my local repo, it doesn't work. The same for the directories static, media and the database my_database in the working directory. How can I set mercurial for NOT update and commit in the server?

I want to work either on my computer and on the server and get all two repo always synchronized.

Could someone kindly explain me what should I do? I'm a bit confused.

Thank you!

Fred Collins
  • 5,004
  • 14
  • 62
  • 111
  • I can figure out settings.py, but why don't you want static/media synced? – Eli Bendersky May 26 '11 at 03:09
  • Because in static there's `django.contrib.auth` static files (admin panel with css, js) and in media there are avatar images, site images and other stuff. Only media/css and media/js contains my files that I want to be synced. – Fred Collins May 26 '11 at 20:56

3 Answers3

3

It doesn't answer your question directly, but I've found a good way to manage local settings is by putting them in a separate file (ignored by your SCM) and loading them in settings.py.

For example, put this at the bottom of settings.py:

 try:
   import settings_local
 except ImportError:
   pass  # Ignore when file doesn't exist

Anything in settings_local.py will override the values in settings.py.

EDIT:

More directly to your question, see this answer under Mercurial ignore file. It looks like ignoring an already-versioned file isn't supported. I have done it with Subversion before, so I can see why you are trying it. The other answers have some workarounds.

Community
  • 1
  • 1
Tim Yates
  • 5,151
  • 2
  • 29
  • 29
2

First, if settings.py is already committed, then ignoring it won't change that. You'd need to first

$ hg remove settings.py
$ echo 'glob:settings.py' > .hgignore

(Just appending the filename to .hgignore doesn't do anything, that I know of, but I know there are different formats for this. Anyway, be aware of that, as well.)

harpo
  • 41,820
  • 13
  • 96
  • 131
1

I can answer one part of your question:

If a file matches a pattern in the ignore file (.hgignore), it is NOT ignored if it is already being tracked by mercurial. This explains why edits to your settings.py are NOT ignored; it's because settings.py is already being tracked. When you did the command hg add, that added all the files into your repository; that is, mercurial started tracking them all (except any that were being ignored at the time).

Marek P
  • 445
  • 3
  • 12