Mercurial: Unterschied zwischen den Versionen

Aus SchnallIchNet
Wechseln zu: Navigation, Suche
Zeile 2: Zeile 2:
  
 
==Installation==
 
==Installation==
{{TODO|Mach et}}
+
install mercurial to use as central repo-server
 +
 
 +
===install mercurial===
 
install mercurial from your prefered distro.
 
install mercurial from your prefered distro.
 
  apt-get install mercurial
 
  apt-get install mercurial
Zeile 8: Zeile 10:
 
  yum install mercurial
 
  yum install mercurial
  
 +
===install svn-extension===
 
install mercurial-svn extension
 
install mercurial-svn extension
 
<pre>
 
<pre>
Zeile 33: Zeile 36:
  
 
==Configuration==
 
==Configuration==
 +
configure mercurial/apache to be a central repo-server
 +
 +
===hgwebdir===
 
to serve your repo through http(s) look [http://mercurial.selenic.com/wiki/PublishingRepositories HERE]!<br/>
 
to serve your repo through http(s) look [http://mercurial.selenic.com/wiki/PublishingRepositories HERE]!<br/>
 
i will use hgwebdir-method which i will describe here.<br/>
 
i will use hgwebdir-method which i will describe here.<br/>
Zeile 42: Zeile 48:
 
  cp -a /usr/share/doc/mercurial/examples/hgwebdir.cgi /var/www/html/hgwebdir.cgi
 
  cp -a /usr/share/doc/mercurial/examples/hgwebdir.cgi /var/www/html/hgwebdir.cgi
  
 +
now we have to configure hgwebdir.<br/>
 +
so we create the config-file: /var/www/html/hgweb.config
 +
<pre>
 +
[paths]
 +
my_repo_name = /var/repos/hg/repo_name
 +
</pre>
 +
 +
===apache===
 
now configure apache to serve...<br/>
 
now configure apache to serve...<br/>
 
edit you vhost file and add:
 
edit you vhost file and add:
Zeile 65: Zeile 79:
 
</pre>
 
</pre>
  
<pre>
+
make apache be able to write to your repos:
[paths]
+
chown apache:apache /var/repos/hg/*
my_repo_name = /var/repos/hg/repo_name
+
 
</pre>
+
restart apache!! ;-)<br/>
 +
 
 +
 
  
if you serve repos from a central server and own the files by e.g. apache you will have to add apache as trusted user.<br/>
+
if you get messages from 'hg [command]' like this:<br/>
so if you get messages from 'hg [command]' like this:<br/>
+
 
  Not trusting file /path/to/repos/myrepo/.hg/hgrc from untrusted user apache, group apache
 
  Not trusting file /path/to/repos/myrepo/.hg/hgrc from untrusted user apache, group apache
to trust the user 'apache' create a file in mercurials hgrc.d-directory:
+
then add apache-user to trusted user's-file. create a file in mercurials hgrc.d-directory:
  vi /etc/mercurial/hgrc.d/trustedUsers.rc
+
  vi /etc/mercurial/hgrc.d/trusted_users.rc
 
and add something like that:
 
and add something like that:
 
<pre>
 
<pre>
Zeile 87: Zeile 102:
 
be sure to add only hooks that should be triggered on server-side.<br/>
 
be sure to add only hooks that should be triggered on server-side.<br/>
 
e.g. add hooks for commit-mails here...<br/>
 
e.g. add hooks for commit-mails here...<br/>
do '''NOT''' add hooks for commit-mails in client hgrc-files because you don't want<br/>
+
or for disallowing to create 2 or more heads!!
to be informed of commits the developer commits to his/her local repo-copy!<br/>
+
  
  
==Usage==
+
==General usage==
 
keep in mind that mercurial creates a local repo<br/>
 
keep in mind that mercurial creates a local repo<br/>
 
commits are are going to your local copy/clone and are '''NOT''' pushed to the <br/>
 
commits are are going to your local copy/clone and are '''NOT''' pushed to the <br/>
Zeile 163: Zeile 177:
 
### hg resolve [--all | FilePath/FileName]
 
### hg resolve [--all | FilePath/FileName]
 
# hg push
 
# hg push
 +
 +
===info output===
 +
hg tags
 +
prints out the tags-list<br/>
 +
note that the tag '''tip''' is the equivalent ouf your trunk in svn<br/>
 +
so your trunk simply is your default-tag
 +
<pre>
 +
# hg tags
 +
tip                            4573:72a1a1c04f10
 +
M9                              2612:b248ea41c460
 +
M8                              2140:3ec0fd753656
 +
trunk-with-XXX                  2101:902dd0b485ee
 +
merge-xxxxxxx-YYY              1923:9ecb31562ad1
 +
merge-xxxxxxx                  1466:4fd4bc5a79fd
 +
</pre>
 +
<br/>
 +
 +
hg branches
 +
prints out a list of created branches
 +
<pre>
 +
# hg branches
 +
M9                          4573:72a1a1c04f10
 +
default                    4571:5742e3be45c5
 +
aa-yyyyy-utf8-fixes        3339:d914991eaa6c
 +
M8                          2846:c7742dc608e9
 +
M7                          2375:0326a021977b
 +
trunk-before-zzz            2099:c24644d3367c
 +
changelogger-7462          1717:c46758e604b7
 +
</pre>

Version vom 15. April 2010, 07:28 Uhr

A very good alternativ to svn or git

Installation

install mercurial to use as central repo-server

install mercurial

install mercurial from your prefered distro.

apt-get install mercurial

or

yum install mercurial

install svn-extension

install mercurial-svn extension

mkdir -p /usr/src/mercurial
cd /usr/src/mercurial
hg clone http://bitbucket.org/durin42/hgsubversion hgsubversion
cd hgsubversion
python ./setup.py build install

now tell mercurial where hgsubversion is build
edit file /etc/mercurial/hgrc

[extensions]
rebase=
svn=/usr/src/mercurial/hgsubversion/hgsubversion

from now on you can use hg-commands to pull svn repos
which are converted to mercurial equivalents.

for detailed usage look HERE!

now create a new or pull/convert a svn repo.

Configuration

configure mercurial/apache to be a central repo-server

hgwebdir

to serve your repo through http(s) look HERE!
i will use hgwebdir-method which i will describe here.

locate hgwebdir.cgi which is delivered with mercurial package. for me ist here:

/usr/share/doc/mercurial/examples/hgwebdir.cgi

i copied it to somewhere suitable:

cp -a /usr/share/doc/mercurial/examples/hgwebdir.cgi /var/www/html/hgwebdir.cgi

now we have to configure hgwebdir.
so we create the config-file: /var/www/html/hgweb.config

[paths]
my_repo_name = /var/repos/hg/repo_name

apache

now configure apache to serve...
edit you vhost file and add:

<VirtualHost aaa.bbb.ccc.ddd:80>
   
   [...]
   
   # set the script-alias
   ScriptAlias /repo     "/var/www/html/hgwebdir.cgi"
   
   # protect you repo by password
   <Location /repo>
      AuthType Basic
      AuthName "Mercurial repositories"
      AuthUserFile /var/repos/hg/.htpasswd_mercurial
      Require valid-user
   </Location>
   
   [...]
   
</VirtualHost>

make apache be able to write to your repos:

chown apache:apache /var/repos/hg/*

restart apache!! ;-)


if you get messages from 'hg [command]' like this:

Not trusting file /path/to/repos/myrepo/.hg/hgrc from untrusted user apache, group apache

then add apache-user to trusted user's-file. create a file in mercurials hgrc.d-directory:

vi /etc/mercurial/hgrc.d/trusted_users.rc

and add something like that:

[trusted]
users = apache
# comment in next line for trusted groups
# and modify to your needs...
#groups = fred, barney

Hooks (Central Server)

be sure to add only hooks that should be triggered on server-side.
e.g. add hooks for commit-mails here...
or for disallowing to create 2 or more heads!!


General usage

keep in mind that mercurial creates a local repo
commits are are going to your local copy/clone and are NOT pushed to the
upstream-repository automatically!

Clone repo (svn checkout)

$ hg clone https://SERVER/path/repo my-repo-clone

creates an exact copy of the repo at SERVER

status of repo (changes)

$ hg status
M some_changed_file.cpp
? some_new_file.cpp

show changes of files

$ hg diff some_changed_file.cpp
/**
- *
+ *
+ *
+ *
+ *
  *
  * @author Christoph Steidl
  * @since Mar 29, 2010
  * @version 6.6.6
  * @copyright netcar24 GmbH
+ *
+ *
+ *

revert changes

$ hg revert some_changed_file.cpp

reverts the file some_changed_file.cpp back to the last committed version

Commit changes (to local clone)

$ hg commit

shows up you default editor to enter a commit-comment in the 1st line.
following lines show the files to be commited
enter a comment!!! and write/quit the file...
if NO error appears, hg exits silently

or use -m "comment" on command-line e.g.

$ hg commit -m "my comment"

push changes (to upstream-repo)

$ hg push
Remote: adding changesets
Remote: adding manifests
Remote: adding file changes
Remote: added 1 changesets with 2 changes to 2 files
$ _

no errors/conflicts

merge repo

if you push-command says something like:

abort: push creates new remote heads on branch 'default'!
(you should pull and merge or use push -f to force)

then you will have to merge with changes somebody else has pushed before.
do the following steps:

  1. hg pull
  2. hg merge
    1. conficts are solved automatically if possible
    2. if NOT possigle:
      1. hg resolve [--all | FilePath/FileName]
  3. hg push

info output

hg tags

prints out the tags-list
note that the tag tip is the equivalent ouf your trunk in svn
so your trunk simply is your default-tag

# hg tags
tip                             4573:72a1a1c04f10
M9                              2612:b248ea41c460
M8                              2140:3ec0fd753656
trunk-with-XXX                  2101:902dd0b485ee
merge-xxxxxxx-YYY               1923:9ecb31562ad1
merge-xxxxxxx                   1466:4fd4bc5a79fd


hg branches

prints out a list of created branches

# hg branches
M9                          4573:72a1a1c04f10
default                     4571:5742e3be45c5
aa-yyyyy-utf8-fixes         3339:d914991eaa6c
M8                          2846:c7742dc608e9
M7                          2375:0326a021977b
trunk-before-zzz            2099:c24644d3367c
changelogger-7462           1717:c46758e604b7