Einführung Mercurial
-
Upload
wielandp -
Category
Technology
-
view
1.949 -
download
0
Transcript of Einführung Mercurial
- 1. Versionsverwaltung?
-
- Real Programmers don't need version control.
-
-
- N.N.
2. Geschichte
- SCCS (1970er, Dateien, Sperren, nicht frei)
-
- RCS(1980er, Dateien, Sperren, frei)
-
- CVS(1985-, Dateien, keine Sperren, frei)
-
- Subversion (SVN) (2001-, frei)
-
- Git (2005-, frei)
-
- Mercurial (2005-, frei)
-
- andere : clearcase, perforce, bitkeeper ($$$$)
3. Installation
- Windows: TortoiseHg-0.x.y.exe http://tortoisehg.sourceforge.net/ alles drin
- Linux/Unix/MacOS X: mercurial-1.0.2.tar.gz http://www.selenic.com/mercurial man braucht Python >=2.3, 3-way merge, gcc
- Konfigurieren (Name, E-Mail, ...) auf Rechner oder im Repository
4. Kommandozeile
-
- D:srchgtalk>hg version
-
- Mercurial Distributed SCM (version 1.0.2+tortoisehg)
-
- ...
-
- D:srchgtalk>hg help init
-
- hg init [-e CMD] [--remotecmd CMD] [DEST]
-
- create a new repository in the given directory
-
- ...
-
- D:srchgtalk>
5. hg init
-
- D:srchgtalk>mkdir 1
-
- D:srchgtalk>cd 1
-
- D:srchgtalk1>hg init
-
- oder
-
- D:srchgtalk>hg init 1
-
- D:srchgtalk>cd 1
6. Leerer Arbeitsbereich
-
- D:srchgtalk1>dir
-
- 12.10.200821:57
- .
- 12.10.200821:57
-
- 12.10.200821:57
- ..
- 12.10.200821:57
-
- 12.10.200821:57
- .hg
- 12.10.200821:57
-
- 0 Datei(en), 0 Bytes
-
- 3 Verzeichnis(se), 80.418.877.440 Bytes frei
7. TortoiseHG Kontextmen im Explorer 8. Repository erzeugen (.hg-Verz.) 9. entspricht hg init 10. .hgignore ist leer (spter mehr) 11. hg status(kurz st)
-
- D:srchgtalk1>hg st
-
- ? .hgignore
-
- ? info1.pl
-
- D:srchgtalk1>
12. jetzt unter Windows ... 13. ... hg status 14. erstmal sieht man nichts ... 15. ... Status unbekannt anwhlen 16. .hgignore blendet Dateimuster aus 17. die ignorierten Dateien sind weg
-
- D:srchgtalk1>hg status
-
- ? info1.pl
-
- D:srchgtalk1>
18. die ignorierten Dateien sind weg
-
- D:srchgtalk1>hg status
-
- ? info1.pl
-
- D:srchgtalk1>dir
-
- 12.10.200818:54
- .hg
- 12.10.200818:54
-
- 12.10.200820:48111 .hgignore
-
- 12.10.200818:540 .hgignore.$$$
-
- 12.10.200819:1490 info1.pl
-
- D:srchgtalk1>
19. unter Windows genauso ... 20. ... oder auch die ignorierten 21. Dateien hinzufgen
-
- D:srchgtalk1>hg add info1.pl
-
- D:srchgtalk1>hg st
-
- A info1.pl
-
- D:srchgtalk1>hg commit
-
- D:srchgtalk1>hg st
-
- D:srchgtalk1>
-
- Achtung: hg add ohne Parameter nimmt alle
-
- Dateien rekursiv.
ffnet Editor fr Kommentar 22. Status im Explorer 23. nderungen
-
- D:srchgtalk1>type info1.pl
-
- use strict;
-
- print "Hg steht fr: Mercurial ";
-
- D:srchgtalk1>hg st
-
- M info1.pl
-
- D:srchgtalk1>
24. Status gendert im Explorer Neue und ignorierte Dateien ohne Symbol 25. noch jemand will arbeiten
-
- D:srchgtalk>hg clone 1 1b
-
- updating working directory
-
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
- D:srchgtalk>cd 1b
-
- D:srchgtalk1b>type info1.pl
-
- use strict;
-
- print "Hg steht fr: hydrargyrum, chemisches Symbol fr Quecksilber ";
-
- D:srchgtalk1b>
26. ... und ndert, ...
-
- D:srchgtalk1b>copy ..1.hgignore .
-
- D:srchgtalk1b>hg diff
-
- diff -r 134e009f9517 info1.pl
-
- --- a/info1.plSun Oct 12 23:14:23 2008 +0200
-
- +++ b/info1.plSun Oct 12 23:43:29 2008 +0200
-
- @@ -1,4 +1,5 @@
-
- use strict;
-
- print "Hg steht fr: hydrargyrum, chemisches Symbol fr Quecksilber ";
-
- +print "oder auch fr Hochschulgesetz ";
-
- D:srchgtalk1b>hg commit
-
- D:srchgtalk1b>
27. ... es sieht gut aus
-
- D:srchgtalk1b>hg st
-
- D:srchgtalk1b>hg log
-
- changeset:1:4e94b6009d08
-
- tag:tip
-
- user:Wieland
-
- date:Sun Oct 12 23:45:13 2008 +0200
-
- summary:gesetz
-
- changeset:0:134e009f9517
-
- user:Wieland
-
- date:Sun Oct 12 23:14:23 2008 +0200
-
- summary:start
-
- D:srchgtalk1b>
28. In 1 merken wir nichts, ...
-
- D:srchgtalk1>hg diff
-
- diff -r 134e009f9517 info1.pl
-
- --- a/info1.plSun Oct 12 23:14:23 2008 +0200
-
- +++ b/info1.plSun Oct 12 23:47:16 2008 +0200
-
- @@ -1,4 +1,4 @@
-
- use strict;
-
- -print "Hg steht fr: hydrargyrum, chemisches Symbol fr Quecksilber ";
-
- +print "Hg steht fr: Mercurial ";
-
- D:srchgtalk1>
29. ... auch nicht beim einchecken
-
- D:srchgtalk1>hg ci -m "hg4hg"
-
- D:srchgtalk1>hg log
-
- changeset:1:69fb82b0a16f
-
- tag:tip
-
- user:Wieland
-
- date:Mon Oct 13 01:22:14 2008 +0200
-
- summary:hg4hg
-
- changeset:0:134e009f9517
-
- user:Wieland
-
- date:Sun Oct 12 23:14:23 2008 +0200
-
- summary:start
-
- D:srchgtalk1>
ffnet nicht Editor fr Kommentar 30. gleicher Anfang, anders weiter 1: 1b: v0 v0 v1 v1' 31. was hat 1b gendert?
-
- D:srchgtalk1>hg incoming ..1b
-
- comparing with ..1b
-
- searching for changes
-
- changeset:1:4e94b6009d08
-
- tag:tip
-
- user:Wieland
-
- date:Sun Oct 12 23:45:13 2008 +0200
-
- summary:gesetz
-
- D:srchgtalk1>
32. wenn 1b noch gendert hat?
-
- D:srchgtalk1>hg incoming ..1b
-
- comparing with ..1b
-
- searching for changes
-
- changeset:1:4e94b6009d08
-
- user:Wieland
-
- date:Sun Oct 12 23:45:13 2008 +0200
-
- summary:gesetz
-
- changeset:2:3ceb703f893d
-
- tag:tip
-
- user:Wieland
-
- date:Mon Oct 13 01:34:23 2008 +0200
-
- summary:!!!
33. was genau hat 1b gendert?
-
- D:srchgtalk1>hg incoming-p ..1b
-
- comparing with ..1b
-
- searching for changes
-
- changeset:1:4e94b6009d08
-
- ...
-
- diff -r 134e009f9517 -r 4e94b6009d08 info1.pl
-
- --- a/info1.plSun Oct 12 23:14:23 2008 +0200
-
- +++ b/info1.plSun Oct 12 23:45:13 2008 +0200
-
- @@ -1,4 +1,5 @@
-
- ...
-
- changeset:2:3ceb703f893d
-
- tag:tip
-
- ...
34. gleicher Anfang, anders weiter 1: 1b: v0 v0 v1 v1' v2' 35. von 1b holen
-
- D:srchgtalk1>hg pull ..1b
-
- pulling from ..1b
-
- searching for changes
-
- adding changesets
-
- adding manifests
-
- adding file changes
-
- added 2 changesets with 2 changes to 1 files (+1 heads)
-
- (run 'hg heads' to see heads, 'hg merge' to merge)
-
- D:srchgtalk1>
36. gleicher Anfang, anders weiter 1: 1b: v0 v0 v1 v1' v2' v3 tip heads tip head gleich verschieden Rep. wd 37. viele Kpfe
-
- D:srchgtalk1>hg heads
-
- changeset:3:3ceb703f893d
-
- tag:tip
-
- user:Wieland
-
- date:Mon Oct 13 01:34:23 2008 +0200
-
- summary:!!!
-
- changeset:1:69fb82b0a16f
-
- user:Wieland
-
- date:Mon Oct 13 01:22:14 2008 +0200
-
- summary:hg4hg
-
- D:srchgtalk1>
38. Konflikte lsen (hg merge) 39. ... im wd gelst v0 v1 v2' v3 40. Knoten automatisch aufgelst 1: 1b: v0 v0 v1 v1' v2' v3 tip heads tip head gleich verschieden Rep. wd 41. Ergebnis des Lsens
-
- D:srchgtalk1>hg diff
-
- diff -r 69fb82b0a16f info1.pl
-
- --- a/info1.plMon Oct 13 01:22:14 2008 +0200
-
- +++ b/info1.plMon Oct 13 10:14:11 2008 +0200
-
- @@ -1,4 +1,5 @@
-
- use strict;
-
- print "Hg steht fr: Mercurial ";
-
- +print "oder auch fr Hochschulgesetz !!! ";
-
- D:srchgtalk1>
42. Ergebnis speichern
-
- D:srchgtalk1>hg commit
-
- D:srchgtalk1>hg st
-
- D:srchgtalk1>hg log
-
- changeset:4:024fdf725d5d
-
- tag:tip
-
- parent:1:69fb82b0a16f
-
- parent:3:3ceb703f893d
-
- user:Wieland
-
- date:Mon Oct 13 10:15:38 2008 +0200
-
- summary:beide Versionen zusammen
-
- ...
-
- D:srchgtalk1>
43. hg tip
-
- D:srchgtalk1>hg log -r4
-
- changeset:4:024fdf725d5d
-
- tag:tip
-
- parent:1:69fb82b0a16f
-
- parent:3:3ceb703f893d
-
- user:Wieland
-
- date:Mon Oct 13 10:15:38 2008 +0200
-
- summary:beide Versionen zusammen
-
- D:srchgtalk1>hg log -rtip
-
- ...
-
- D:srchgtalk1>hg tip
-
- ...
-
- D:srchgtalk1>
44. so einfach ist mergen 1: 1b: v0 v0 v1 v1' v2' v3 tip head tip head gleich verschieden Rep. v4 pull merge 45. hgtk log 46. nderungen schreiben
-
- D:srchgtalk1> hg outgoing ..1b
-
- D:srchgtalk1> hg push ..1b
-
- Das ist zum Schreiben in ein Shared-
-
- Repository (ohne Workdir).
47. nderungen austauschen
-
- hg pull/push/clone - Abgleichen
-
- hg export/import - Patches erz./einl
-
- hg bundle/unbundle - kompr.Teil-Repos.
-
- http://www.selenic.com/mercurial/wiki/index.cgi/CommunicatingChanges
48. Wie soll man arbeiten?
-
- z.B.
-
- ein Dir in (incomming) ohne wd (cache)
-
- ein Dir out (outgoing)
-
- ein Dir fr jeden Fix
-
- 1. Merge often!(in und fixes)
-
- 2. Commit early and commit often
-
- http://www.selenic.com/mercurial/wiki/index.cgi/WorkingPractices
49. Hybrid warum zweimal?
-
- Ein Projekt mit SVN und HG gleichzeitig.
-
- HG lokal
-
- z.B. SVN/GIT fr den Rest der Welt
-
- Vorteile von beiden Systemen,
-
- wenn man es braucht.
50. Keyword Extension
-
- In Textdateien z.B. $Id$ ersetzen mit
-
- $Id: prog.pl rev:hash date time user $
-
- # .hg/hgrc
-
- [extensions]
-
- hgext.keyword=
51. Keyword Extension
-
- # .hg/hgrc
-
- [keyword]
-
- # expand keywords in all perl files
-
- **.pl =
-
- [keywordmaps]
-
- Date = {date|utcdate}
-
- Id = {file|basename} {rev}:{node|short} {date|utcdate} {author|user}
-
- Rev = {node|short}
-
- Node = {node}
52. Keyword Extension
-
- # demo.pl
-
- Date = $Date$
-
- Id = $Id$
-
- Rev = $Rev$
-
- Node = $Node$
-
- D:srchgtalk1>hg add demo.pl
-
- D:srchgtalk1>hg kwexpand
-
- abort: outstanding uncommitted changes in given files
53. Keyword Extension
-
- D:srchgtalk1>hg commit -m "add kw"
-
- D:srchgtalk1>hg kwexpand
-
- D:srchgtalk1>type demo.pl
-
- Date = $Date: 2008/11/18 10:11:30 $
-
- Id = $Id: demo.pl 12:5bd2c929da87 2008/11/18 10:11:30 Wieland $
-
- Rev = $Rev: 5bd2c929da87 $
-
- Node = $Node: 5bd2c929da87c55e3761778...$
Zeit ist UTC, weil utcdate sonst isodate ! 54. Keyword Extension
-
- hg kwshrink
-
- hg kwexpand
-
- bei "hg ci" wird automatisch aktualisiert
-
- http://www.selenic.com/mercurial/wiki/index.cgi/KeywordExtension
-
- keywords: .../hgbookch11.html
Vor und nach nderungen der Keywords z.B. Ein-/Ausschalten 55. Klon ber http erzeugen
-
- D:srchgtalk>hg clone http://hg.serpentine.com/tutorial/hello
-
- destination directory: hello
-
- requesting all changes
-
- adding changesets
-
- adding manifests
-
- adding file changes
-
- added 5 changesets with 5 changes to 2 files
-
- updating working directory
-
- 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
- D:srchgtalk>
56. Klon ohne WD
-
- D:srchgtalk>hg clone -U 1 public
-
- z.B. fr Shared-Repository
57. Literatur: hg book (the book)
-
- Distributed revision control with Mercurial, by Bryan O'Sullivan
-
- http://hgbook.red-bean.com/
58. Links
- http://www.selenic.com/mercurial/wiki/
- http://tortoisehg.sourceforge.net/
- Talk von Bryan O'Sullivan http://www.youtube.com/watch?v=1sV8Z_Lmpt4
- Talk von Linus Torvalds http://www.youtube.com/watch?v=4XpnKHJAok8
- Talk von Randal Schwartz http://www.youtube.com/watch?v=8dhZ9BXQgc4
59. Links II Referenzkarten
- DongWoo Lee: Mercurial Cheat Sheet http://edong.net/2008v1/docs/dongwoo-Hg-120dpi.png
- Mercurial-QuickStart + Mercurial-Usage http://www.ivy.fr/mercurial/ref/v1.0/
60. Fragen? 61. Danke!