I have a folder(b) inside another folder(a) which was already pushed into a repository, and i want to push folder(b) to the bitbucket using macHg but I want it to push it so in bitbucket it looks like a new folder, right now when i pushed it it just made a new head it didn't put the whole folder in there. How can I push the whole folder so on bitbucket would look like
Folder A
Folder B
file
If you run hg status, what do you get? You should get output like this:
zck#zck-desktop:~/my-test$ hg status
? a/b/file
The question mark means that mercurial doesn't know about a/b/file yet. So let's tell it to track the file. This is just a local command, nothing will hit the remote server yet.
zck#zck-desktop:~/my-test$ hg add a/b/file
zck#zck-desktop:~/my-test$ hg status
A a/b/file
The A means that the file was just added. Now we just need to commit (which is another local command).
zck#zck-desktop:~/my-test$ hg commit -m "added a/b/file, with contents in it?"
Finally, we need to push the changeset up to the remote server. This is the only command we've done that touches the remote server.
zck#zck-desktop:~/my-test$ hg push
Related
I want to understand how mercurial works on the server side. So I do some local experiment and can't understand what is going wrong.
I make two directories /server and /client then go to /server, make new directory /server/repository, go to /repository and call hg init.By this I have an hg repository.
Then I go to /client and call hg clone file://path_to_server/server/repository. It clones empty repository to the /client folder. Then I create new file and put it under hg control doing hg add file, commit it and push. I expect a file in the /server/repository/ but it's still empty.Maybe my expectations so naive and behaviour I expect is incorect. It also might be really doubtful thing - moving files locally by pushing from /client to /server without any command in /server/repo/ folder. In this case I hope anybody explain why that doesn't word this way and what should I do.
You need to hg update on the server repository.
The working directory (which is the set of files you see in the filesystem) is not automatically updated when new changesets arrive either from pulling or pushing changes from another repo.
Good Luck!
Following is the scenario: I have a remote Mercurial repository at ssh://remotehost//dir/repo and I am able to clone it to a local host "pandora" in directory /home/user/localrepo/.
Now, I have a superset of this remote repository, where I add my own testing framework, but do not want to merge to the main depot until I am certain it works. So I clone this "local" repo to /home/user/workingdir/ but when I issue the command to do so
$ hg clone /home/user/localrepo/
only the repository folder gets copied none of the files get copied.
I'm not sure what you mean when you say that "only the repo folders gets copied". So there's two things you can try :
Try to do a hg update in your new clone.
List the directory in /home/user/workingdir and if there is a directory name localrepo in it, this is actually your repository. To clone in the current directory, you must do hg clone /home/user/localrepo .
This sounds odd but try a few things:
First in the local repo that you cloned from do a
hg status -A
are all the files that you think should be in there in there? If not are you at the tip of the repo.
You can see what revision you are at with
hg parent
If you want to just go to the tip do hg update
If there still aren't any files listed in the repo do the same to check the one on the server.
If there aren't any files on the server you will need to add all of the files you want mercurial to track, mercurial doesn't automagically start tracking files in the repo location.
(Use hg add --all to add all of the file in the entire directory tree under the repo location.)
If there are files in the local repo, check the testing area and make sure that it is on the proper changeset.
Using Mercurial, we can commit one file by using
hg commit file.rb
or 1 folder
hg commit foldername
But how can we push just 1 file or 1 folder out?
The whole project can be pushed using
hg push ssh://peter#192.168.1.102//project/code/preliminary
but there seems to be no way to push out just 1 file or 1 folder?
I tried the following and they don't work:
hg push ssh://peter#192.168.1.102//project/code/preliminary app/views/index.html.erb
or
hg push ssh://peter#192.168.1.102//project/code/preliminary/app/views/index.html.erb
That's not really possible to do with Mercurial. The whole point of Mercurial (and Subversion and git and pretty much every version-control system since CVS) is that you deal with changesets; each commit is a set of changes to one or more files. push and pull only know about commits, not about each part of every commit.
Being very familiar with the subversion workflow and that fact that 99.9% of the time my computer is connected to the internet, I don't like doing 'hg ci' and 'hg push' separately.
I remember bzr had a 'checkout' command that would bind subsequent 'commit' commands to automatically commit directly to the server ('push').
Does mercurial have something similar to this?
PS: Writing a shell script or alias that runs 'hg ci $* && hg push' would be the last thing I'd do.
You could add a hook to run push after a successful commit.
EDIT: I just tried it out and it seems to work fine. I added the following to the .hg/hgrc file of the repository I wanted to activate automatic pushing for:
[hooks]
commit.autopush = hg push
EDIT 2: Also, you don't have to worry about something like this:
You're in a repository that you don't want to automatically push.
You use hg -R ~/another-repo-that-autopushes commit to commit in a different repo that does automatically push.
Will the hg push hook end up pushing the changes in the current directory instead of the one you're committing in?
No, it won't. According to the page I linked:
An executable hook is always run with its current directory set to a repository's root directory.
It's an edge case, but Mercurial handles it correctly.
I'm used to git, where you can run gitk and get something like the following:
Here you can see that there are a couple of changes that need pushing to the remote branch. Alternatively, I can use git log --decorate and the output would be:
b8c2926... (refs/heads/next) Update instructions
6d9f914... Add a first go at generic x compiling
49a6dac... (refs/remotes/github/next) Ignore temp files
Is there anything like this with Mercurial?
hg outgoing - will show you the changesets that are waiting to be pushed to a remote repository.
hg incoming - shows new changesets that are in the remote repository.