summary refs log blame commit diff stats
path: root/doc/pick.sh
blob: e5f18da4037efd17e9c056ea870a6b09c05df2da (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                          


                                                                
 
                              




                                               
                                                                           
 
                              
                         
                                
#!/bin/bash

# I work on a branch (named hut) which contains commits
# that should not be part of the standard distribution.
#
# This script picks all the good commits from hut and
# adds them to the master branch.
# Bad commits are marked with a "custom:" at the beginning
# of the commit message.

MASTER_BRANCH='master'
CUSTOM_BRANCH='hut'
ORIGINAL_BRANCH=`git branch 2>/dev/null|grep -e ^* | tr -d \*\ `

git checkout -m $MASTER_BRANCH

while read -r hash tag rest; do
	if [ $tag != 'custom:' ]; then
		git cherry-pick $hash || exit 1
	fi
done < <(git log --oneline --no-color $MASTER_BRANCH..$CUSTOM_BRANCH | tac)

git checkout -m $CUSTOM_BRANCH
git rebase $MASTER_BRANCH
git checkout -m $ORIGINAL_BRANCH
class="kt">int } // Used to cache layout of each row/column type gridLayout struct { Offset int Size int } type GridCell struct { Row int Column int RowSpan int ColSpan int Content Drawable invalid atomic.Value // bool } func NewGrid() *Grid { return &Grid{invalid: true} } func (cell *GridCell) At(row, col int) *GridCell { cell.Row = row cell.Column = col return cell } func (cell *GridCell) Span(rows, cols int) *GridCell { cell.RowSpan = rows cell.ColSpan = cols return cell } func (grid *Grid) Rows(spec []GridSpec) *Grid { grid.rows = spec return grid } func (grid *Grid) Columns(spec []GridSpec) *Grid { grid.columns = spec return grid } func (grid *Grid) Children() []Drawable { grid.mutex.RLock() defer grid.mutex.RUnlock() children := make([]Drawable, len(grid.cells)) for i, cell := range grid.cells { children[i] = cell.Content } return children } func (grid *Grid) Draw(ctx *Context) { invalid := grid.invalid if invalid { grid.reflow(ctx) } grid.mutex.RLock() defer grid.mutex.RUnlock() for _, cell := range grid.cells { cellInvalid := cell.invalid.Load().(bool) if !cellInvalid && !invalid { continue } rows := grid.rowLayout[cell.Row : cell.Row+cell.RowSpan] cols := grid.columnLayout[cell.Column : cell.Column+cell.ColSpan] x := cols[0].Offset y := rows[0].Offset width := 0 height := 0 for _, col := range cols { width += col.Size } for _, row := range rows { height += row.Size } subctx := ctx.Subcontext(x, y, width, height) cell.Content.Draw(subctx) } } func (grid *Grid) reflow(ctx *Context) { grid.rowLayout = nil grid.columnLayout = nil flow := func(specs *[]GridSpec, layouts *[]gridLayout, extent int) { exact := 0 weight := 0 nweights := 0 for _, spec := range *specs { if spec.Strategy == SIZE_EXACT { exact += spec.Size } else if spec.Strategy == SIZE_WEIGHT { nweights += 1 weight += spec.Size } } offset := 0 for _, spec := range *specs { layout := gridLayout{Offset: offset} if spec.Strategy == SIZE_EXACT { layout.Size = spec.Size } else if spec.Strategy == SIZE_WEIGHT { size := float64(spec.Size) / float64(weight) size *= float64(extent - exact) layout.Size = int(math.Floor(size)) } offset += layout.Size *layouts = append(*layouts, layout) } } flow(&grid.rows, &grid.rowLayout, ctx.Height()) flow(&grid.columns, &grid.columnLayout, ctx.Width()) grid.invalid = false } func (grid *Grid) invalidateLayout() { grid.invalid = true grid.DoInvalidate(grid) } func (grid *Grid) Invalidate() { grid.invalidateLayout() grid.mutex.RLock() for _, cell := range grid.cells { cell.Content.Invalidate() } grid.mutex.RUnlock() } func (grid *Grid) AddChild(content Drawable) *GridCell { cell := &GridCell{ RowSpan: 1, ColSpan: 1, Content: content, } grid.mutex.Lock() grid.cells = append(grid.cells, cell) grid.mutex.Unlock() cell.Content.OnInvalidate(grid.cellInvalidated) cell.invalid.Store(true) grid.invalidateLayout() return cell } func (grid *Grid) RemoveChild(content Drawable) { grid.mutex.Lock() for i, cell := range grid.cells { if cell.Content == content { grid.cells = append(grid.cells[:i], grid.cells[i+1:]...) break } } grid.mutex.Unlock() grid.invalidateLayout() } func (grid *Grid) cellInvalidated(drawable Drawable) { var cell *GridCell grid.mutex.RLock() for _, cell = range grid.cells { if cell.Content == drawable { break } cell = nil } grid.mutex.RUnlock() if cell == nil { panic(fmt.Errorf("Attempted to invalidate unknown cell")) } cell.invalid.Store(true) grid.DoInvalidate(grid) }