- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os, sys
ARGV = sys.argv
ARGC = len( ARGV )
GITLOG = "git log --name-status --no-merges --pretty=format:\"%h|_|%ad|_|%s\""
def osexec( _cmd ):
es_ = os.system( _cmd )
print "%d <== '%s'" % ( es_, _cmd )
#raw_input()
# === body =====================================================================
CFD = os.popen( GITLOG )
LOG = CFD.read().split( "\n\n" )
CFD.close()
DLOG = []
for i in LOG:
a = i.split( "\n" )
rdm = a[0] # rev|_|date|_|msg
rdm_ = rdm.split( "|_|" )
files = []
for j in a[1:]:
files.append( j ) # A/M/D\tfilename
e = {}
e["rev"] = rdm_[0]
e["dt"] = rdm_[1]
e["msg"] = rdm_[2]
e["files"] = files
DLOG.append( e )
DLOG.reverse()
for i in DLOG:
print "log:", i
cmd = "git checkout -f %s" % i["rev"]
osexec( cmd )
files = i["files"]
if ( 0 == len( files ) ):
# skip merges
continue
for j in files:
if ( "" == j ):
continue
j_ = j.split( "\t" )
m = j_[0]
f = j_[1]
cmd = ""
if ( "A" == m ):
cmd = "hg add %s" % f
elif ( "D" == m ):
cmd = "hg rm %s" % f
if ( not "" == cmd ):
osexec( cmd )
cmd = "hg ci -m \"%s\" -d \"%s\"" % ( i["msg"], i["dt"] )
osexec( cmd )
Типа переносим гитовые коммиты в меркуриал... При попутном ветре, ага. Буээ
Elvenfighter 18.09.2012 01:29 # 0
Elvenfighter 18.09.2012 01:34 # 0
Lure Of Chaos 18.09.2012 02:59 # +3
или это потому что python украшает любое говно?
Nemoden 21.09.2012 10:42 # 0
Мистер Хэнки 21.09.2012 20:42 # +2