From: Jaroslav Kysela Date: Mon, 16 Jun 2008 09:13:29 +0000 (+0200) Subject: alsatool - enhanced changes, diff commands X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=a4c7f47ffb890c7bafe71a51f9e95fc3a34e9aca;p=alsa.git alsatool - enhanced changes, diff commands --- diff --git a/alsatool b/alsatool index 7ae05c4..423d699 100755 --- a/alsatool +++ b/alsatool @@ -69,7 +69,13 @@ def clone(argv=None): def diff(argv=None): repos = selectrepos(argv) + first = True for repo in repos: + if not first: + print + first = False + print "%s" % repo + print "*"*len(repo) pull([repo]) if os.system("%s --no-pager diff origin/master..master" % git(repo)): raise ValueError, "diff %s" % repo @@ -109,6 +115,8 @@ def version_sort(tags): idx += 1 c1 = int(c[:idx]) c2 = c[idx:] + if c2 == '': + c2 = 'zzzzz' str = "%08i.%08i.%08i.%s" % (a, b, c1, c2) tags1.append(str) tags2[str] = tag @@ -351,6 +359,40 @@ def _merge_members(members, module='alsa-driver', nice=False): result.append('') return result +def parse_log(fp): + commits = [] + commitref = '' + commit = {'comment':[], 'files':[]} + header = True + while 1: + line = fp.readline() + if not line: + break + if line.startswith('commit '): + if commitref: + while commit['comment'][-1] == '\n': + del commit['comment'][-1] + commits.append(commit) + commitref = line[7:].strip() + commit = {'comment':[], 'files':[]} + commit['commit'] = commitref + elif line.startswith('Author:') or line.startswith('AuthorDate:') or \ + line.startswith('Commit:') or line.startswith('CommitDate:') or \ + line.startswith('Merge:'): + a, b = line.split(': ') + commit[a.strip()] = b.strip() + elif line.startswith(' '): + if len(commit['comment']) == 0 and line[4:].strip() == '': + continue + commit['comment'].append(line[4:]) + elif line.strip() != '': + commit['files'].append(line.strip()) + if commitref: + while commit['comment'][-1] == '\n': + del commit['comment'][-1] + commits.append(commit) + return commits + def changes(argv): def rev_to_dot(rev): @@ -366,40 +408,6 @@ def changes(argv): i -= 1 print - def parse_log(fp): - commits = [] - commitref = '' - commit = {'comment':[], 'files':[]} - header = True - while 1: - line = fp.readline() - if not line: - break - if line.startswith('commit '): - if commitref: - while commit['comment'][-1] == '\n': - del commit['comment'][-1] - commits.append(commit) - commitref = line[7:].strip() - commit = {'comment':[], 'files':[]} - commit['commit'] = commitref - elif line.startswith('Author:') or line.startswith('AuthorDate:') or \ - line.startswith('Commit:') or line.startswith('CommitDate:') or \ - line.startswith('Merge:'): - a, b = line.split(': ') - commit[a.strip()] = b.strip() - elif line.startswith(' '): - if len(commit['comment']) == 0 and line[4:].strip() == '': - continue - commit['comment'].append(line[4:]) - elif line.strip() != '': - commit['files'].append(line.strip()) - if commitref: - while commit['comment'][-1] == '\n': - del commit['comment'][-1] - commits.append(commit) - return commits - def store_changes(changes, logs, module, xrev): if module == 'alsa-kmirror': module = 'alsa-driver' @@ -504,10 +512,11 @@ def changes(argv): elif rev2[-1:] >= "a": base = rev2[:-1] for tag in tags: - a = tag[41:-1].strip() + a = tag.strip()[:-1] if a >= rev2: continue - tags1.append(tag[40:-1].strip()) + if tag.strip() != rev2: + tags1.append(tag) tags1 = version_sort(tags1) if len(tags1) != 0: xrev = tags1[len(tags1)-1] @@ -581,13 +590,13 @@ def usage(code=0, msg=''): print print "\t-%s %s" % (opt[0].replace(':', ''), opt[3]) print "\t--%s %s" % (opt[1].replace('=', ''), opt[3]) - print "\t\t%s" % opt[4] + print "\t\t%s" % opt[4].replace('\n', '\t\t') print print 'Where command is:' for cmd in CMDS: print print "\t%s %s" % (cmd[0], cmd[2]) - print "\t\t%s" % cmd[3] + print "\t\t%s" % cmd[3].replace('\n', '\n\t\t') if msg: print print msg @@ -604,7 +613,9 @@ def verbose(argv): global VERBOSE VERBOSE=True -def extpick(argv, edit=False): +def extpick(argv, edit=False, sign=False, interactive=True): + sign = sign and ' --signoff' or ' --committer' + interactive = interactive and ' -i' or '' repo = os.path.abspath(argv[0]) commit = argv[1] tmpdir = ".extpick" @@ -623,7 +634,6 @@ def extpick(argv, edit=False): if a.upper().startswith('SOUNDS: '): a = a[8:].strip() lines[idx] = 'Subject: sound: ' + a + '\n' - print repr(lines[idx]) break open(tmpdir + "/format-patch", "w+").write(''.join(lines)) if edit: @@ -632,7 +642,7 @@ def extpick(argv, edit=False): os.system("%s %s" % (editor, tmpdir + "/format-patch")) if not os.system("diff %s %s > /dev/null" % (tmpdir + "/format-patch", tmpdir + "/format-patch.orig")): return "nochanges" - res = os.system("git am --committer -i -3 --keep %s" % (tmpdir + '/format-patch')) + res = os.system("git am%s%s -3 --keep %s" % (sign, interactive, tmpdir + '/format-patch')) #if os.system("git --work-tree=%s --git-dir=%s mailinfo -u %s %s < %s > %s" % (repo, repo + '/.git', tmpdir + '/msg', tmpdir + '/patch', tmpdir + '/format-patch', tmpdir + '/info')): # raise ValueError, "mail-info" rmtree(tmpdir) @@ -662,7 +672,7 @@ def edit(argv, remove=False): if remove and first: first = False continue - res = extpick(['.', commit], edit=first) + res = extpick(['.', commit], edit=first, interactive=interactive) if type(res) == type('') and res == "nochanges": print "No changes, resetting back to %s..." % head sys.exit(os.system("git reset --hard %s" % head)) @@ -675,6 +685,58 @@ def edit(argv, remove=False): def remove(argv): edit(argv, remove=True) +def import_(argv): + + def compare(commit1, commit2): + diff1 = os.popen("git diff %s~1..%s" % (commit1, commit1)).readlines() + diff2 = os.popen("git diff %s~1..%s" % (commit2, commit2)).readlines() + if len(diff1) != len(diff2): + return False + for idx in range(0, len(diff1)-1): + if diff1[idx].startswith('index ') and diff2[idx].startswith('index '): + continue + elif diff1[idx].startswith('@@ ') and diff2[idx].startswith('@@ '): + a = diff1[idx].split(' ') + b = diff2[idx].split(' ') + a1 = a[1].split(',') + a2 = a[2].split(',') + b1 = b[1].split(',') + b2 = b[2].split(',') + if a1[1] != b1[1] or a2[1] != b2[1]: + return False + elif diff1[idx] != diff2[idx]: + return False + return True + + branch = argv[0] + base = os.popen("git-merge-base master %s" % branch).readline().strip() + log1 = parse_log(os.popen("git log --pretty=fuller --date=iso --reverse master..%s" % branch)) + log2 = parse_log(os.popen("git log --pretty=fuller --date=iso --reverse %s..master" % base)) + tomerge = [] + skipcount = 0 + for l1 in log1: + subject1 = l1['comment'][0].strip() + merged = False + for l2 in log2: + subject2 = l2['comment'][0].strip() + if subject1 == subject2: + if compare(l1['commit'], l2['commit']): + merged = True + break + if merged: + skipcount += 1 + print "Already picked:" + print "** %s/%s %s" % (branch, l1['commit'][:7], l1['comment'][0][:-1]) + print "** master/%s %s" % (l2['commit'][:7], l2['comment'][0][:-1]) + else: + tomerge.append(l1) + print 'Already merged patches: %s' % skipcount + print 'Patches to be merged: %s' % len(tomerge) + for l1 in tomerge: + if extpick(['.', l1['commit']], sign=True): + sys.stderr.write('An error occured...\n') + return + OPTS=[ ['h', 'help', usage, '', 'Print this help'], ['r', 'root', root, '', 'Set GIT root directory (default is %s)' % ROOT], @@ -691,7 +753,8 @@ CMDS=[ ['changes', changes, 'oldtag newtag', 'Show changes between oldtag and newtag'], ['extpick', extpick, 'local-repo-path commit', 'Pick and merge a patch from another repository'], ['edit', edit, 'commit', 'Edit a message for commit'], - ['remove', remove, 'commit', 'Remove a commit'] + ['remove', remove, 'commit', 'Remove a commit'], + ['import', import_, 'branch', 'Import changes from a branch.\nRemove duplicate patches.'] ] def main(): diff --git a/comments.py b/comments.py index 15c5fb7..17a4552 100644 --- a/comments.py +++ b/comments.py @@ -23,6 +23,7 @@ COMMENT_MAP = { ['/utils/alsa-utils.spec.in', 'Core'], ['/cvscompile', 'cvscompile'], ['/hgcompile', 'hgcompile'], + ['/gitcompile', 'gitcompile'], ['/ChangeLog', 'IGNORE'], ['/', 'ERROR'], ], @@ -95,6 +96,7 @@ COMMENT_MAP = { ['/isa', 'ERROR'], ['/include/ak4531_codec.h', 'AK4531 codec'], ['/pci/ac97/ak4531_codec.c', 'AK4531 codec'], + ['/pci/ak4531_codec.c', 'AK4531 codec'], ['/include/ac97_codec.h', 'AC97 Codec'], ['/pci/ac97', 'AC97 Codec'], ['/pci/ali5451', 'ALI5451 driver'], @@ -163,6 +165,7 @@ COMMENT_MAP = { ['/pci/pci_iomap_compat.c', 'PCI iomap compatibility layer'], ['/pci/cs5530.c', 'CS5530 Cyrix/NatSemi VSA1 softaudio init'], ['/pci/oxygen/.*', 'CMI8788 (Oxygen) driver'], + ['/pci/aw2/.*', 'Emagic Audiowerk 2'], ['/pci', 'ERROR'], ['/ppc/Makefile', 'PPC'], ['/ppc/Kconfig', 'PPC'], @@ -229,13 +232,18 @@ COMMENT_MAP = { ['/include/soc-dapm.h', 'SoC Dynamic Audio Power Management'], ['/soc/codecs/Kconfig', 'SoC Layer'], ['/soc/codecs/ac97.(c|h)', 'SoC Codec AC97'], + ['/soc/codecs/wm8510.(c|h)', 'SoC Codec WM8510'], ['/soc/codecs/wm8731.(c|h)', 'SoC Codec WM8731'], ['/soc/codecs/wm8750.(c|h)', 'SoC Codec WM8750'], ['/soc/codecs/wm8753.(c|h)', 'SoC Codec WM8753'], + ['/soc/codecs/wm8990.(c|h)', 'SoC Codec WM8990'], ['/soc/codecs/wm9712.(c|h)', 'SoC Codec WM9712'], + ['/soc/codecs/wm9713.(c|h)', 'SoC Codec WM9713'], ['/soc/codecs/cs4270.(c|h)', 'SoC Codec CS4270'], ['/soc/codecs/tlv320aic3x.(c|h)', 'SoC Codec TLV320AIC3X'], + ['/soc/codecs/uda1380.(c|h)', 'SoC Codec Philips UDA1380'], ['/soc/codecs', 'ERROR'], + ['/soc/at32/.*', 'SoC Audio for the Atmel AT32 System-on-Chip'], ['/soc/at91/.*', 'SoC Audio for the Atmel AT91 System-on-Chip'], ['/soc/pxa/spitz.c', 'SoC PXA2xx Spitz'], ['/soc/pxa/corgi.c', 'SoC PXA2xx Corgi'], @@ -243,10 +251,13 @@ COMMENT_MAP = { ['/soc/pxa/e800_wm9712.c', 'SoC PXA2xx E800/WM9712'], ['/soc/pxa/tosa.c', 'SoC PXA2xx Tosa'], ['/soc/pxa/pxa*', 'SoC PXA2xx Core'], + ['/soc/pxa/em-x270*', 'SoC PXA2xx EM-X270'], ['/soc/pxa/Kconfig', 'SoC PXA2xx Core'], ['/soc/s3c24xx/.*', 'SoC Audio for the Samsung S3C24XX chips'], ['/soc/sh/.*', 'SoC SH7760 AC97'], ['/soc/fsl/.*', 'SoC Freescale'], + ['/soc/davinci/.*', 'SoC DaVinci'], + ['/soc/omap/.*', 'SoC Texas Instruments OMAP'], ['/soc/soc-core.*', 'SoC Layer'], ['/soc/Kconfig', 'SoC Layer'], ['/soc/soc-dapm.c', 'SoC Dynamic Audio Power Management'], @@ -292,6 +303,7 @@ COMMENT_MAP = { ['/include/tlv.h', 'Control Midlevel'], ['/core/control.*', 'Control Midlevel'], ['/core/isadma.*', 'ISA DMA'], + ['/core/vmaster.*', 'Virtual Master'], ['/include/adriver.h', 'ALSA Core'], ['/include/asound.h', 'ALSA Core'], ['/include/asoundef.h', 'ALSA Core'], @@ -359,7 +371,9 @@ COMMENT_MAP = { ['/kconfig.vers', 'Sound Core'], ['/cvscompile', 'cvscompile script'], ['/hgcompile', 'hgcompile script'], + ['/gitcompile', 'gitcompile script'], ['/snddevices.in', 'snddevices script'], + ['/make-alsa-kernel', 'IGNORE'], ['/', 'ERROR'], ], "alsa-tools": [ @@ -383,10 +397,12 @@ COMMENT_MAP = { ['/seq/sbiload/.*', 'sbiload'], ['/seq/cvscompile', 'Core'], ['/seq/hgcompile', 'Core'], + ['/seq/gitcompile', 'Core'], ['/seq/.*', 'ERROR'], ['/Makefile', 'Core'], ['/cvscompile', 'Core'], ['/hgcompile', 'Core'], + ['/gitcompile', 'Core'], ['/', 'ERROR'], ], "alsa-lib": [ @@ -417,6 +433,7 @@ COMMENT_MAP = { ['/include/pcm_extplug.h', 'External PCM Filter Plugin SDK'], ['/include/pcm_rate.h', 'External Rate Converter Plugin SDK'], ['/include/alsa-symbols.h', 'Core'], + ['/include/iatomic.h', 'Core'], ['/src/control/.*', 'Control API'], ['/src/mixer/.*', 'Mixer API'], ['/include/pcm.h', 'PCM API'], @@ -449,6 +466,7 @@ COMMENT_MAP = { ['/NOTES', 'Documentation'], ['/cvscompile', 'Core'], ['/hgcompile', 'Core'], + ['/gitcompile', 'Core'], ['/', 'ERROR'], ], "alsa-firmware": [ @@ -472,6 +490,7 @@ COMMENT_MAP = { ['/README', 'Core'], ['/cvscompile', 'Core'], ['/hgcompile', 'Core'], + ['/gitcompile', 'Core'], ['/', 'ERROR'], ], "alsa-plugins": [ @@ -495,6 +514,7 @@ COMMENT_MAP = { ['/configure.in', 'Core'], ['/cvscompile', 'Core'], ['/hgcompile', 'Core'], + ['/gitcompile', 'Core'], ['/', 'ERROR'], ], "alsa-python": [ @@ -503,11 +523,16 @@ COMMENT_MAP = { ['/pyalsa/alsahcontrol.c', 'pyalsa.alsahcontrol module'], ['/pyalsa/alsamixer.c', 'pyalsa.alsamixer module'], ['/pyalsa/alsaseq.c', 'pyalsa.alsaseq module'], + ['/pyalsa/mixertest[12].py', 'IGNORE'], + ['/pyalsa/cardtest[12].py', 'IGNORE'], + ['/pyalsa/hctltest[12].py', 'IGNORE'], ['/setup.py', 'Core'], ['/PKG-INFO', 'Core'], + ['/MANIFEST.in', 'Core'], ['/utils/.*', 'Python utilities'], ['/test/.*', 'Test python scripts'], ['/tools/.*', 'Tools python scripts'], + ['/doc/.*', 'Documentation'], ['/', 'ERROR'], ], "alsa-oss": [ @@ -523,6 +548,7 @@ COMMENT_MAP = { ['/configure.in', 'Core'], ['/cvscompile', 'Core'], ['/hgcompile', 'Core'], + ['/gitcompile', 'Core'], ['/', 'ERROR'], ], -} +} \ No newline at end of file