Slide 1

Slide 1 text

Mercurial Migration im großen Stil Markus Zapke-Gründemann PyCon DE 2011

Slide 2

Slide 2 text

Markus Zapke-Gründemann • Softwareentwickler seit 2001 • Python, Django und Mercurial • Inqbus GmbH & Co. KG

Slide 3

Slide 3 text

Ein paar Fragen...

Slide 4

Slide 4 text

Wer benutzt ein zentrales Versionskontrollsystem?

Slide 5

Slide 5 text

Wer arbeitet mit einem verteilten Versionskontrollsystem?

Slide 6

Slide 6 text

Wer hat noch nie ein Versionskontrollsystem benutzt?

Slide 7

Slide 7 text

Verteilte Versionskontrollsysteme

Slide 8

Slide 8 text

Verteilte Versionskontrollsysteme • Kein zentrales Repository nötig (aber möglich) • Jeder Client hat ein eigenes Repository • Viele Operationen sind schneller als bei einem zentralen Repository • Führt zu anderen Entwicklungsmodellen

Slide 9

Slide 9 text

hg

Slide 10

Slide 10 text

Mercurial • Verteiltes Versionskontrollsystem • Mercurial v0.1 im April 2005 • Fast vollständig in Python geschrieben • Plattformunabhängig • Erweiterbar (Extensions) • Einfach zu erlernen • Open Source (GNU GPL 2) - Version 0.1 unter 600 SLOC Python - Version 1.9.3 hat 52.656 SLOC Python (86% von 60.999 SLOC)

Slide 11

Slide 11 text

Lantiq

Slide 12

Slide 12 text

• Weltweit agierendes Fabless-Unternehmen • Rund 1.000 Mitarbeiter • Hersteller hochintegrierter System on Chip-Lösungen • Etwa 20 Niederlassungen weltweit Lantiq Logo und Produktfoto © Copyright Lantiq - Ehemals Wireline Communications Division von Infineon Technologies - Alle xDSL-Varianten, VoIP, WLAN, FTTx oder Gigabit Ethernet - Auswahl der Standorte: Europa (Neubiberg, Duisburg, Villach, Riga und Yakum), Nordamerika (Bedford, MA und Milpitas, CA) sowie in Asien-Pazifik (Taipei, Singapur und Bangalore)

Slide 13

Slide 13 text

Das Projekt

Slide 14

Slide 14 text

Anforderungen • Angepasste Mercurial Distribution • Linux (verschiedene RHEL Versionen) • Windows (TortoiseHg) • Zentraler Mercurial Server mit LDAP Authentifizierung • Subrepositories • ClearCase Migration - Da die Repositories bei Lantiq oft sehr groß sind und aus vielen Modulen bestehen waren Subrepositories teil der Anforderung.

Slide 15

Slide 15 text

DevOps Bildquelle: https://en.wikipedia.org/wiki/File:Devops.png

Slide 16

Slide 16 text

Mercurial Distribution

Slide 17

Slide 17 text

Mercurial Distribution Red Hat Enterprise Linux • Environment Modules • virtualenv • Python 2.7 • fabric Windows • TortoiseHg • Verschiedene Mercurial Extensions • Angepasste Mercurial Konfiguration - RHEL 4.x und 5.x für 32 und 64 bit - http://modules.sourceforge.net/ - Nicht alle Mercurial Extensions liegen als Python Package vor - Linux Distribution im Einsatz als Client und Server

Slide 18

Slide 18 text

Struktur der Linux Distribution /opt/ !"" mercurial # $"" 1.9.2 # !"" bin # # $"" hg # !"" contrib # !"" etc # # $"" mercurial # # $"" hgrc # !"" linux40_64 # !"" linux50_32 # $"" linux50_64 # !"" bin # # !"" activate # # !"" hg # # !"" pip # # $"" python # $"" lib $"" modulesfiles $"" prog $"" mercurial !"" .version $"" 1.9.2 $ module load mercurial

Slide 19

Slide 19 text

Mercurial Extensions

Slide 20

Slide 20 text

mercurial_keyring https://pypi.python.org/pypi/mercurial_keyring

Slide 21

Slide 21 text

onsub http://mercurial.selenic.com/wiki/OnsubExtension

Slide 22

Slide 22 text

projrc http://mercurial.selenic.com/wiki/ProjrcExtension - Entwicklung wurde von Lantiq bezahlt.

Slide 23

Slide 23 text

hglock https://pypi.python.org/pypi/hglock - Entwicklung wurde von Lantiq bezahlt.

Slide 24

Slide 24 text

versions https://pypi.python.org/pypi/hg-versions

Slide 25

Slide 25 text

relink http://mercurial.selenic.com/wiki/RelinkExtension

Slide 26

Slide 26 text

importfs - Entwicklung wurde von Lantiq bezahlt. - Extension noch nicht veröffentlicht.

Slide 27

Slide 27 text

cc_import - Entwicklung wurde von Lantiq bezahlt. - Extension noch nicht veröffentlicht.

Slide 28

Slide 28 text

Mercurial Server

Slide 29

Slide 29 text

Mercurial Server • Apache • mod_authnz_ldap • mod_ssl • mod_proxy • mod_wsgi • mod_macro • hgweb • Supervisord • Munin

Slide 30

Slide 30 text

Reverse Proxy Backend Projekt A Client Backend Projekt B Backend Projekt C SSL LDAP Auth. Supervisord WSGI + hgweb - Das Backend für jedes Projekt läuft unter dem Account des Projekts. - Die Projekt-Admins verwalten die Repositories selbst. - Jedes Projekt kann über 100 Repositories haben. - Jedes Backend kann eine andere Mercurial Version nutzen.

Slide 31

Slide 31 text

Reverse Proxy Konfiguration ... ProxyTimeout 600 - Default sind 300 Sekunden.

Slide 32

Slide 32 text

Authentifizierung von Gruppen [web] allow_read = @unixgroup, james, @devs allow_push = @devs [web.groups] devs = john, lisa, paul, linda, @team1 - Entwicklung wurde von Lantiq bezahlt. - Code noch nicht veröffentlicht.

Slide 33

Slide 33 text

Mercurial Server Outpost Mercurial Client Mercurial Client Mercurial Client Mercurial Outposts

Slide 34

Slide 34 text

ClearCase Migration

Slide 35

Slide 35 text

ClearCase Migration • ClearCase Baseline ≈ Mercurial Tag • Migration von Baselines als Mercurial Revisions • Erstellung von neuen Branches möglich • importfs und cc_import Extensions

Slide 36

Slide 36 text

Mercurial Extensions schreiben

Slide 37

Slide 37 text

"""printparents Prints the parents of a given revision. """ from mercurial import util def printparents(ui, repo, node, **opts): """Print parent information""" ctx = repo[node] parents = ctx.parents() try: if opts['short']: ui.write('short %s %s\n' % (parents[0], parents[1])) elif opts['long']: ui.write('long %s %s\n' % (parents[0].hex(), parents[1].hex())) else: ui.write('default %s %s\n' % (parents[0], parents[1])) except IndexError: raise util.Abort('revision %s has only one parent' % node) cmdtable = { 'print-parents': (printparents, [('s', 'short', None, 'print short form'), ('l', 'long', None, 'print long form')], '[options] REV') } printparents.py

Slide 38

Slide 38 text

Test printparents extension: $ echo "[extensions]" >> $HGRCPATH $ echo "printparents=" >> $HGRCPATH $ hg init r $ cd r $ echo c1 > f1 $ hg commit -Am 0 adding f1 $ echo c2 > f2 $ hg commit -Am 1 adding f2 $ hg up 0 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ echo c3 > f3 $ hg commit -Am 2 adding f3 created new head $ hg merge 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg commit -m 3 $ hg print-parents tip default 33960aadc16f c3adabd1a5f4 $ hg print-parents 2 abort: revision 2 has only one parent [255] test-printparents.t

Slide 39

Slide 39 text

cram A simple testing framework for command line applications https://pypi.python.org/pypi/cram

Slide 40

Slide 40 text

Danke! Fragen? @keimlink / www.keimlink.de / www.inqbus.de