I have a local mercurial repository. And I back it up with a clone in a separate folder that lives in my google drive folder. Every now and again I'll go into the google drive repo and do an hg pull, and google drive takes care of backing it up. But I'd like to swap those responsibilities, so that my local is a clone of the one in google drive. In other words, today I do this:
From my local c:\source folder:
do stuff
hg commit
cd c:\googledrive\source
hg pull
I would rather:
From my local c:\source folder:
do stuff
hg commit
hg push
I don't know what to do in my hgrc files to make that happen. Can someone help?
Here's the contents of my c:\source hgrc:
# Generated by TortoiseHg settings dialog
[tortoisehg]
summarylen = 80
engmsg = True
editor = notepad
tabwidth = 2
forcerepotab = False
monitorrepo = localonly
[ui]
username = *****
And this is the contents of the clone in google drive
[paths]
default = c:\source\SwissArmyKnife
Your question reveals an illuminating misconception. When one says that Mercurial is a Distributed Version Control System (DVCS), it means that there is no ‘master‘ repository.
When you type hg push <repo> or hg pull <repo>, then Mercurial compares the changesets in the current repository with those in <repo>, and pushes or pulls changesets to make this one and the remote one consistent. The <repo> can be indicated by a URL (that is, ssh://..., or http://...) or else by a shorthand named in your .hg/hgrc: thus in your case you might add
[paths]
gdrive = c:\googledrive\source
and that would mean that you could write hg push gdrive or hg pull gdrive and Mercurial would know what you meant. You can have multiple paths listed here.
There's one ‘magic’ path, however. If you have a path default then that's the path that Mercurial uses if you don't specify a <repo>.
Thus (finally), if you adjust the .hg/hgrc in your c:\source folder to include
[paths]
default = c:\googledrive\source
then in that directory plain hg push will sync changesets with that drive.
When you clone a repository (hg clone) Mercurial generally adds to your .hg/hgrc a default = ... which indicates the location from which you cloned the repository. Given that default behaviour, it's very natural to think of that repository as the ‘master’ one, but there's nothing fundamentally special about it.
Related
I have a mercurial repo structured as follows:
/parent
/child1
/child2
with the following webconfig file for hg serve:
[paths]
/ = ./*
/parent/child1 = ./parent/child1/*
/parent/child2 = ./parent/child2/*
[web]
allow_push = *
push_ssl = false
I want to be able to clone /parent/child1 or /parent/child2 and update them, then later clone /parent and have all the changes from the children. Preferably showing the commits for the children as well.
I'd also like to be able to easily add /grandchild to one of the children at any time and have it function the same as the children (can clone parent or child folder and get all changes)
The current setup will let me clone the children as I want, but any changes are not reflected in the parent repository.
I'm using hg server --web-config to serve these repos.
I believe I need to use .hgsub to achieve these results, but I'm not sure how and most of the places I find with info link to the old mercurial website, which now doesn't exist.
Other subrepo related configs I've found are just for mapping /parent/child1 to /child1 (I will have a lot of subrepos that may be named similar or the same, so I'd prefer not to have each available in the base) or for mapping someone else's repo as a dependency.
This is an example of what I'd like to be able to do (cmd example):
hg clone http://server/parent/child1 child1
cd child1
echo changes >file1.txt
hg commit -m "changes to child1"
hg push
cd ..
hg clone http://server/parent parent
cd parent/child1
echo new changes >>file1.txt
hg commit -m "changes to child1 again"
hg push
cd ../../child1
hg pull -u
type file1.txt
which should print
changes
new changes
Is this possible with mercurial serve? How can I achieve what I want with a web config? I'm still setting up my mercurial server, so I don't need to worry about history.
If it's not possible, is there another version control software that can do as I need?
I have a repository which will be cloned.
I go to directory of the repository and type the following command to get the branches.
hg branches
As the reuslt I get the
blank 0:4d82003d3fc7
And also I get the size of the repository using
du -sh ./
It prints
312M ./
This repository containes the following.
ls -a
. .. dummy .hg .hglf
Now when I clone it using this command
hg clone /path/libname -r blank
I get the new repository, the size of which is only 52 kbts and it containes
. .. dummy .hg .hglf
I also clone it without -r blank option
hg clone /path/libname
And get the same result. I suppose if repository have 312M size, the cloned repository also should have a comparable size. Where is a problem ?
The original repository has a '.hglf' file. This indicates that (most likely) it uses 'largefiles'. Largefiles are stored on the server, and are only downloaded for a specific revision if you update to that revision. There are a few possibilities:
You are not on a revision that uses largefiles. Update to one that does and you'll see a larger size.
You don't have the 'largefiles extension' enabled. Enable it and try to clone again, you should see a difference. To enable largefiles, add to your .hgrc:
[extensions]
largefiles =
Starting with Mercurial 3.4 (not yet released as of this writing), the largefiles extension will be enabled automatically when cloning a repository with largefiles.
I have a dependancy as a subrepository (without write access to) in my project.
I'd like to add a few personal customizations to that subrepository - possibly using mq.
I also would love to be able to just clone the main repo to build it. Currently I have to:
clone the repo - with subrepositories getting cloned automagically
manually clone all the patchqueues for subrepositories
How do I get rid of step 2? Is it even possible without an outside script? (I'm using bitbucket if it makes any difference).
One notion is to make the subrepo not the repo to which you have no write access, but a clone of your own based on their repo.
cd myclones
hg clone http://notmydomain.com/their-repo my-clone-of-their-repo
and in your project's .hg/hgrc you use a [subpaths] section to map their URL to your local clone:
[subpaths]
http://notmydomain.com/their-repo = ../my-clone-of-their-repo
Then you end up with your repo using your local (read-write) clone of their repo to which you otherwise have read-only access. This has a few benefits:
faster -- you're only checking local repositories for all actions
writeable -- you can edit directoy in myproject/their-repo and commit and push (to your local clone)
And when you want to merge in their upstream changes you just go into ../my-clone-of-their-repo and hg pull and hg merge their updates into your customizations.
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.
When a project is started with
mkdir proj
cd proj
hg init
[create some files]
hg add file.txt
hg commit
hg push ssh://me#somewhere.somehost.com/proj
now when hg path is issued, nothing will show. How do we actually change the repository so that it is as if it is cloned from me#somewhere.somehost.com/proj ? Is it just by editing .hg/hgrc and adding
[paths]
default = ssh://me#somewhere.somehost.com/proj
because that feels like too low level an operation to do (by editing a text file)
It's the only way to do it in this situation. There are plenty of other cases where you have to edit the hgrc by hand, like setting up hooks or enabling extensions, so it's not as if it's unusual.
(As you probably already know, hg clone will set the path entry in the clone to point back to the original.)