beginner question: networkless use of hg
Marcin Kasperski
Marcin.Kasperski at softax.com.pl
Tue May 20 04:00:42 CDT 2008
> Merging is always done within a single repo, so is unaffected
> regardless of how you move changes about, networked or not.
As an attempt to clarify: merges will happen in your repository
(and/or repository of your friend). It works so:
- you hack, commit, hack, commit etc
- you get changes from your friend into your repository (by bundle
import or by pull from repo on the stick)
- at this moment your (local) repository contains two (or maybe more)
separate branches (inside repository, your working dir has what it did)
- when you think it is appropriate, you merge those branches (and commit)
The merge changeset is later exported just like any other changes.
>> Is there a howto somewhere on best practices for networkless use of
>> hg?
>
> Probably not, because it's really no different (slower, of course...).
Simplest way likely:
(starting)
hg init /your/working/directory
(normal work)
cd /your/working/directory
hg add, hg rm, hg merge, hg commit etc
# this all happens inside your working directory = whatever
# you commit, is saved inside /your/working/directory/.hg
(when you are to export changes for the first time)
hg clone /your/working/directory /location/on/usb/stick
(your friend takes the stick and creates his repo by)
hg clone /maybe/diferently/mounted/location/on/usb/stick /his/working/dir
When you want to give some new changes:
cd /your/working/directory
hg push /repository/on/usb/stick
# This works if you kept previously used repo on stick, if not,
# just clone as above. The 'push' command takes everything what
# is inside /your/working/directory/.hg but is not inside
# /repository/on/usb/stick/.hg and appends it there.
And your friend does
cd /his/working/dir
hg pull /location/on/usb/stick
# This way he takes everything what is in /location/on/usb/stick/.hg
# which he does not have in /his/working/dir/.hg and copies it there
At this moment he has the changes insiede his repo, but not yet in working
dir. He can issue "hg heads" to verify whether new branches were created,
but in practice it suffices to do the following:
hg update
# if he did not do any changes, it will update to your newest
# version, otherwise it refuses to work and says that merge is needed
or (if told to)
hg merge
# This merges your changes with your friend changes, note that
# everything happens in your friend directory, no network is
# accessed here for anything
hg commit
# To commit the merge changeset (which will be later exported
# as any other commit)
and so on....
Of course you could also export bundles and transfer them via
stick, but the method above is simpler.
>> Also is there any way I can explicitly keep hg from trying to contact
>> remote machines?
hg does not contact remote machines during daily work. Everything
you commit is saved in /your/working/dir/.hg
The only commands which can do something remotely are pull, push and
clone. Those can be used both locally and remotely
hg pull /other/dir
pulls from another local dir (like that on USB stick) while
hg pull ssh://some.host.name/some/dir
pulls from remote machine
As you can see this is fairly explicit (the only non-explicit thing is
that you can save shortcuts in .hg/hgrc to save typing, and that if
your repo was created by cloning some other repo, its location is
saved as alias "default")
Note also, that you can freely mix it. If you happen to be on
one net with your friend, you can pull directly from him.
Or you can email him some bundle. Or you can burn your repo
on CD, send him so he pulls from CD. Or ....
Final word: play with it a bit. Just do
mkdir playing
cd playing
hg init blahblah_mine
cd blahblah_mine
# create 1-2 files, edit them,
# hg commit
hg clone blahblah_mine blahblah_transfer
hg clone blahblah_transfer blahblah_friend
and then try editing and commiting in blahblah_mine and
blahblah_friend, pulling/pushing via blahblah_transfer etc (here
blahblah_mine is acting as your, blahblah_transfer as usb stick and
blahblah_friend as yoru friend repo).
Issue "hg glog" from time to time in different repos. This shows
what is inside and really teaches how do those changesets and branches
grow.
--
----------------------------------------------------------------------
| Marcin Kasperski | People resist change, regardless of what
| http://mekk.waw.pl | it is. (Michael Reed)
| |
----------------------------------------------------------------------
More information about the Mercurial
mailing list