1

I just made my first push into a Mercurial repository and now I am trying to see if I can delete a directory from the repository. I deleted that directory from my local file system and tried this command from Ubuntu:

sudo hg push https://alex.genadinik:mypassword@udfr.googlecode.com/hg/ "some comment"

and I got the error that:

hg push: invalid arguments

But that was the command I used to originally push. What did I do wrong here?

Here is what I tried:

$ sudo hg commit -m "removing file"
$ sudo hg push
abort: repository default-push not found!

Why would that happen?

Genadinik
  • 18,153
  • 63
  • 185
  • 284
  • @Genadinik: 'I deleted that directory from my local file system' Did you perform an `hg remove` (or forget), or just a file system delete? – dls Apr 15 '11 at 20:24
  • 1
    What is the "some comment" part supposed to be, in relation to a push command? – Lasse V. Karlsen Apr 15 '11 at 20:43
  • @dls I just removed it from the file system. Didn't realize I had to do hg remove. Is the hg remove supposed to follow the deletion from the file system? – Genadinik Apr 15 '11 at 20:45
  • You need to tell Mercurial to stop tracking the contents of that directory. You do that either by issuing a `hg forget` command, or a `hg remove` command. The latter would delete the contents from the file system as well, but since you did that first, use the forget command. – Lasse V. Karlsen Apr 15 '11 at 20:47
  • Or... you can use the `hg addremove` command to ask Mercurial to "figure it out yourself" – Lasse V. Karlsen Apr 15 '11 at 20:47
  • I just posted the ensuing error in my original question. Any ideas why that might be the case? – Genadinik Apr 15 '11 at 20:51

3 Answers3

3

the process you should follow is:

  1. hg remove or hg forget the files. Mercurial does not track directories, so if you delete all files from a particular directory, the directory itself will cease to exist from a Mercurial standpoint.

    Finally, once a file is tracked, you cannot remove it with a standard rm or del command, nor can you remove it from a file browser. Doing this will cause Mercurial to mark the file as 'missing', which means it's still being tracked.

    Once this is done, you can run an hg status and it should show all the files you just removed with an R prefix.

  2. commit the deletion. Like any other modification, the hg remove/forget is a change that needs to be committed before it can be pushed.

  3. push the new changeset
Community
  • 1
  • 1
dls
  • 4,146
  • 2
  • 24
  • 26
  • I just posted what happened after I tried to push the new changeset. Any ideas on why the new error happened? – Genadinik Apr 15 '11 at 20:52
  • @Genadinik: You are probably missing a default push path. Try adding `[paths] default=/path/or/url/to/repo` to your .hgrc or mercurial.ini file, or specifying the entire push path like you did in your original post. – dls Apr 15 '11 at 20:59
  • in my repository directory I only have a file called .hg - where is the proper place for the .hgrc or the mercurial.ini files to exist? - Thanks! – Genadinik Apr 15 '11 at 21:53
  • @Genadinik `.hg` is actually a directory filled with many magical Mercurial things like the repository history, repo specific settings, etc... You can modify the `.hgrc` file inside of `.hg`, or you can create another file in one of several places. Mercurial will use them both; later settings will overwrite earlier settings. Check out [this link](http://www.selenic.com/mercurial/hgrc.5.html) for information on where to place this file. – dls Apr 15 '11 at 21:59
0

Do you need to specify the repository? Can't you just use 'hg push'? Unless this isn't the repository you initially cloned from? Usually you want to make your comments in the commit as well, not for sure, but I don't think you can in a push. 'hg commit -m "my comments"'

Also, ensure you have committed your changes before you push.

So in your case I would see this as what you should do once you have cloned your initial repository.

rm directory
hg commit -m "my commit message"
hg push

It will prompt you for credentials.

  • 3
    I don't think executing a file system remove (such as `rm`) will work. It will cause Mercurial to mark the files as 'missing', which is defined as 'deleted by non-hg command, but still tracked' in the help text. You would instead have to use `hg forget` or `hg remove`. – dls Apr 15 '11 at 20:35
  • @dls I think you are right. I use the tooling too much. You will have to use the hg forget in order for this to work. Thank you. –  Apr 15 '11 at 20:43
  • The forget command caused the system to remove the files I needed to remove. – Genadinik Apr 15 '11 at 20:47
0

The push command doesn't take a comment argument. You're misremembering what you did. You probably did a commit (which can take a comment with -m) and then push, which takes a URL but not a comment. The error is telling you to get rid of that comment.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169