You are on page 1of 40

Mercurial Migration im groen Stil

Markus Zapke-Grndemann PyCon DE 2011

Markus Zapke-Grndemann
Softwareentwickler seit 2001 Python, Django und Mercurial Inqbus GmbH & Co. KG

Ein paar Fragen...

Wer benutzt ein zentrales Versionskontrollsystem?

Wer arbeitet mit einem verteilten Versionskontrollsystem?

Wer hat noch nie ein Versionskontrollsystem benutzt?

Verteilte Versionskontrollsysteme

Verteilte Versionskontrollsysteme
Kein zentrales Repository ntig (aber
mglich)

Jeder Client hat ein eigenes Repository Viele Operationen sind schneller als bei
einem zentralen Repository

Fhrt zu anderen Entwicklungsmodellen

hg

Mercurial

Verteiltes Versionskontrollsystem Mercurial v0.1 im April 2005 Fast vollstndig in Python geschrieben Plattformunabhngig 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)

Lantiq

Weltweit agierendes Fabless-Unternehmen Rund 1.000 Mitarbeiter Hersteller hochintegrierter System on


Chip-Lsungen

Etwa 20 Niederlassungen weltweit

Lantiq Logo und Produktfoto Copyright Lantiq

- Ehemals Wireline Communications Division von Inneon 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-Pazik (Taipei, Singapur und Bangalore)

Das Projekt

Anforderungen
Angepasste Mercurial Distribution Linux (verschiedene RHEL Versionen) Windows (TortoiseHg) Zentraler Mercurial Server mit LDAP
Authentizierung

Subrepositories ClearCase Migration


- Da die Repositories bei Lantiq oft sehr gro sind und aus vielen Modulen bestehen waren Subrepositories teil der Anforderung.

DevOps

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

Mercurial Distribution

Mercurial Distribution
Red Hat Enterprise Linux Windows

Environment Modules virtualenv Python 2.7 fabric

TortoiseHg

Verschiedene Mercurial Extensions Angepasste Mercurial Konguration

RHEL 4.x und 5.x fr 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

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

Mercurial Extensions

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

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

projrc
http://mercurial.selenic.com/wiki/ProjrcExtension

- Entwicklung wurde von Lantiq bezahlt.

hglock
https://pypi.python.org/pypi/hglock

- Entwicklung wurde von Lantiq bezahlt.

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

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

importfs

- Entwicklung wurde von Lantiq bezahlt. - Extension noch nicht verffentlicht.

cc_import

- Entwicklung wurde von Lantiq bezahlt. - Extension noch nicht verffentlicht.

Mercurial Server

Mercurial Server

Apache

mod_authnz_ldap mod_ssl mod_proxy mod_wsgi mod_macro

hgweb Supervisord Munin

Backend Projekt A

Client

Reverse Proxy
SSL LDAP Auth.

Backend Projekt B

Backend Projekt C
Supervisord WSGI + hgweb

Das Backend fr jedes Projekt luft 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.

Reverse Proxy Konguration


<VirtualHost 10.1.2.3> ... ProxyTimeout 600 </VirtualHost>

- Default sind 300 Sekunden.

Authentizierung 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 verffentlicht.

Mercurial Outposts
Mercurial Server Mercurial Client

Outpost

Mercurial Client Mercurial Client

ClearCase Migration

ClearCase Migration
ClearCase Baseline Mercurial Tag Migration von Baselines als Mercurial
Revisions

Erstellung von neuen Branches mglich importfs und cc_import Extensions

Mercurial Extensions schreiben

printparents.py
"""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') }

test-printparents.t
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]

A simple testing framework for command line applications


https://pypi.python.org/pypi/cram

cram

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

You might also like