Description
It would be very helpfult to some more advanced usecases to be able to modify the order of patches later in the stack, to bridge the gap between stg
and git rebase -i
a little more.
This way it would be possible to reorder future operations without any conflicts and the start going through the stack and taking care of issues as they come up.
I have not looked very closely, but I am thinking this should not be very difficult to implement, as stg delete
already allows you to modify the future, albeit only by deleting patches from the future.
I propose modifications to two commands push
and float
by adding --noapply
flag:
stg push --noapply [patches...]
stg float --noapply -s series-file
I believe this can make it a lot simpler to write a shell script to implement patch guards from #70
guards_pass() {
SHA=$1
# check if patch should be pushed (could check git notes for guard annotations or patch name)
}
# all patches for simple demo, but can check only unapplied + hidden patches in the future.
PATCHES=$(stg series --noprefix -a)
GUARD_PASS=( )
GUARD_FAIL=( )
for patch in $PATCHES; do
if guards_pass $(stg id $patch); then
GUARD_PASS+=( $patch )
else
GUARD_FAIL+=( $patch )
fi
done
stg pop -a
stg push --noapply "${GUARD_PASS[@]}"
stg hide "${GUARD_FAIL[@]}"
This is certainly not exactly the same idea as Mercurial Queue Patch guards, as it assumes that patch sets are not interleaving. But it can easily be extended to take care of interleaving patchsets also as long as you keep track of global patch order in a separate file along with constraints:
patch-list.txt (to be read into PATCHES var)
patch1 +guard1 -guard2
patch2 +guard2
patch3 +guard1
patch4
patch5
Example Workflow:
## Given this stack:
+ setB-p1
+ setB-p2
> setB-p3
- setB-p4
- setA-p1
- setA-p2
- setA-p3
## Work on patch set 1:
$ stg pop -a
$ stg push --noapply setA-p1 setA-p2 setA-p3
## Stack should look like this now: (* = stack changes for illustration)
- setA-p1 *
- setA-p2 *
- setA-p3 *
- setB-p1
- setB-p2
- setB-p3
- setB-p4
$ stg push # now on `setA-p1`
# ... resolve conflicts / adjust `setA-p1`
$ stg push # now on `setA-p2`
# ... resolve conflicts / adjust `setA-p2`
# NOTE: not addressing conflicts or changing `setA-p3` yet
## Stack should look like this now:
+ setA-p1
> setA-p2
- setA-p3
- setB-p1
- setB-p2
- setB-p3
- setB-p4
## Switch to working on set 2:
$ stg pop -a
$ stg push --noapply setB-p1 setB-p2 setB-p3 setB-p4
## Stack should look like this now: (* = stack changes for illustration)
- setB-p1 *
- setB-p2 *
- setB-p3 *
- setB-p4 *
- setA-p1
- setA-p2
- setA-p3
$ stg push # now on `setB-p1`
# ... resolve conflicts / adjust `setB-p1`
## Stack should look like this now:
> setB-p1
- setB-p2
- setB-p3
- setB-p4
- setA-p1
- setA-p2
- setA-p3
# etc...