summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
adeef6b)
"squash" is the word git uses for this operation, so we should use it
too to lessen the confusion. Also, it's easier to spell.
We can do the rename without any effort at backwards compatibility
because "stg coalesce" has never been part of any released version.
Signed-off-by: Karl Hasselström <kha@treskal.com>
NOTE: There are at least two more ways to update a non-topmost patch.
One is to use stglink:refresh[] with the +$$--patch$$+ flag, the other
to create a new patch for the update and then merge it into the other
NOTE: There are at least two more ways to update a non-topmost patch.
One is to use stglink:refresh[] with the +$$--patch$$+ flag, the other
to create a new patch for the update and then merge it into the other
-patch with stglink:coalesce[].
+patch with stglink:squash[].
Keeping commit messages up to date
Keeping commit messages up to date
* Use e.g. stglink:float[], stglink:sink[], stglink:push[], and
stglink:pop[] to reorder patches.
* Use e.g. stglink:float[], stglink:sink[], stglink:push[], and
stglink:pop[] to reorder patches.
- * Use stglink:coalesce[] to merge two or more patches into one.
- stgsublink:coalesce[] pushes and pops so that the patches to be
+ * Use stglink:squash[] to merge two or more patches into one.
+ stgsublink:squash[] pushes and pops so that the patches to be
merged are consecutive and unrelated patches aren't in the way,
then makes one big patch out of the patches to be merged, and
finally pushes the other patches back.
merged are consecutive and unrelated patches aren't in the way,
then makes one big patch out of the patches to be merged, and
finally pushes the other patches back.
("r" . stgit-refresh)
("\C-c\C-r" . stgit-rename)
("e" . stgit-edit)
("r" . stgit-refresh)
("\C-c\C-r" . stgit-rename)
("e" . stgit-edit)
("N" . stgit-new)
("R" . stgit-repair)
("C" . stgit-commit)
("N" . stgit-new)
("R" . stgit-repair)
("C" . stgit-commit)
(apply 'stgit-run "delete" args))
(stgit-reload)))))
(apply 'stgit-run "delete" args))
(stgit-reload)))))
-(defun stgit-coalesce (patchsyms)
- "Coalesce the patches in PATCHSYMS.
-Interactively, coalesce the marked patches."
+(defun stgit-squash (patchsyms)
+ "Squash the patches in PATCHSYMS.
+Interactively, squash the marked patches."
(interactive (list stgit-marked-patches))
(when (< (length patchsyms) 2)
(interactive (list stgit-marked-patches))
(when (< (length patchsyms) 2)
- (error "Need at least two patches to coalesce"))
+ (error "Need at least two patches to squash"))
(let ((edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
(let ((edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
- (log-edit 'stgit-confirm-coalesce t nil edit-buf)
+ (log-edit 'stgit-confirm-squash t nil edit-buf)
(set (make-local-variable 'stgit-patchsyms) patchsyms)
(setq default-directory dir)
(let ((standard-output edit-buf))
(set (make-local-variable 'stgit-patchsyms) patchsyms)
(setq default-directory dir)
(let ((standard-output edit-buf))
- (apply 'stgit-run-silent "coalesce" "--save-template=-" patchsyms))))
+ (apply 'stgit-run-silent "squash" "--save-template=-" patchsyms))))
-(defun stgit-confirm-coalesce ()
+(defun stgit-confirm-squash ()
(interactive)
(let ((file (make-temp-file "stgit-edit-")))
(write-region (point-min) (point-max) file)
(stgit-capture-output nil
(interactive)
(let ((file (make-temp-file "stgit-edit-")))
(write-region (point-min) (point-max) file)
(stgit-capture-output nil
- (apply 'stgit-run "coalesce" "-f" file stgit-patchsyms))
+ (apply 'stgit-run "squash" "-f" file stgit-patchsyms))
(with-current-buffer log-edit-parent-buffer
(stgit-clear-marks)
;; Go to first marked patch and stay there
(with-current-buffer log-edit-parent-buffer
(stgit-clear-marks)
;; Go to first marked patch and stay there
to have refreshed. If you asked to refresh a patch other than the
topmost patch, there can be conflicts; in that case, the temporary
patch will be left for you to take care of, for example with stg
to have refreshed. If you asked to refresh a patch other than the
topmost patch, there can be conflicts; in that case, the temporary
patch will be left for you to take care of, for example with stg
The creation of the temporary patch is recorded in a separate entry in
the patch stack log; this means that one undo step will undo the merge
The creation of the temporary patch is recorded in a separate entry in
the patch stack log; this means that one undo step will undo the merge
from stgit.commands import common
from stgit.lib import git, transaction
from stgit.commands import common
from stgit.lib import git, transaction
-help = 'Coalesce two or more patches into one'
+help = 'Squash two or more patches into one'
kind = 'stack'
usage = ['[options] <patches>']
description = """
kind = 'stack'
usage = ['[options] <patches>']
description = """
-Coalesce two or more patches, creating one big patch that contains all
+Squash two or more patches, creating one big patch that contains all
their changes.
If there are conflicts when reordering the patches to match the order
their changes.
If there are conflicts when reordering the patches to match the order
args = [argparse.patch_range(argparse.applied_patches,
argparse.unapplied_patches)]
args = [argparse.patch_range(argparse.applied_patches,
argparse.unapplied_patches)]
-options = [opt('-n', '--name', short = 'Name of coalesced patch')
+options = [opt('-n', '--name', short = 'Name of squashed patch')
] + argparse.message_options(save_template = True)
directory = common.DirectoryHasRepositoryLib()
] + argparse.message_options(save_template = True)
directory = common.DirectoryHasRepositoryLib()
class SaveTemplateDone(Exception):
pass
class SaveTemplateDone(Exception):
pass
-def _coalesce_patches(trans, patches, msg, save_template):
+def _squash_patches(trans, patches, msg, save_template):
cd = trans.patches[patches[0]].data
cd = git.CommitData(tree = cd.tree, parents = cd.parents)
for pn in patches[1:]:
cd = trans.patches[patches[0]].data
cd = git.CommitData(tree = cd.tree, parents = cd.parents)
for pn in patches[1:]:
save_template(msg)
raise SaveTemplateDone()
else:
save_template(msg)
raise SaveTemplateDone()
else:
- msg = utils.edit_string(msg, '.stgit-coalesce.txt').strip()
+ msg = utils.edit_string(msg, '.stgit-squash.txt').strip()
cd = cd.set_message(msg)
return cd
cd = cd.set_message(msg)
return cd
-def _coalesce(stack, iw, name, msg, save_template, patches):
+def _squash(stack, iw, name, msg, save_template, patches):
# If a name was supplied on the command line, make sure it's OK.
def bad_name(pn):
# If a name was supplied on the command line, make sure it's OK.
def bad_name(pn):
if name and bad_name(name):
raise common.CmdException('Patch name "%s" already taken')
if name and bad_name(name):
raise common.CmdException('Patch name "%s" already taken')
- def make_coalesced_patch(trans, new_commit_data):
+ def make_squashed_patch(trans, new_commit_data):
name = get_name(new_commit_data)
trans.patches[name] = stack.repository.commit(new_commit_data)
trans.unapplied.insert(0, name)
name = get_name(new_commit_data)
trans.patches[name] = stack.repository.commit(new_commit_data)
trans.unapplied.insert(0, name)
- trans = transaction.StackTransaction(stack, 'coalesce',
+ trans = transaction.StackTransaction(stack, 'squash',
allow_conflicts = True)
push_new_patch = bool(set(patches) & set(trans.applied))
try:
allow_conflicts = True)
push_new_patch = bool(set(patches) & set(trans.applied))
try:
- new_commit_data = _coalesce_patches(trans, patches, msg, save_template)
+ new_commit_data = _squash_patches(trans, patches, msg, save_template)
- # We were able to construct the coalesced commit
+ # We were able to construct the squashed commit
# automatically. So just delete its constituent patches.
to_push = trans.delete_patches(lambda pn: pn in patches)
else:
# automatically. So just delete its constituent patches.
to_push = trans.delete_patches(lambda pn: pn in patches)
else:
to_push = trans.pop_patches(lambda pn: pn in patches)
for pn in patches:
trans.push_patch(pn, iw)
to_push = trans.pop_patches(lambda pn: pn in patches)
for pn in patches:
trans.push_patch(pn, iw)
- new_commit_data = _coalesce_patches(trans, patches, msg,
+ new_commit_data = _squash_patches(trans, patches, msg,
save_template)
assert not trans.delete_patches(lambda pn: pn in patches)
save_template)
assert not trans.delete_patches(lambda pn: pn in patches)
- make_coalesced_patch(trans, new_commit_data)
+ make_squashed_patch(trans, new_commit_data)
# Push the new patch if necessary, and any unrelated patches we've
# had to pop out of the way.
# Push the new patch if necessary, and any unrelated patches we've
# had to pop out of the way.
patches = common.parse_patches(args, list(stack.patchorder.all))
if len(patches) < 2:
raise common.CmdException('Need at least two patches')
patches = common.parse_patches(args, list(stack.patchorder.all))
if len(patches) < 2:
raise common.CmdException('Need at least two patches')
- return _coalesce(stack, stack.repository.default_iw, options.name,
- options.message, options.save_template, patches)
+ return _squash(stack, stack.repository.default_iw, options.name,
+ options.message, options.save_template, patches)
-test_description='Run "stg coalesce"'
+test_description='Run "stg squash"'
-test_expect_success 'Coalesce some patches' '
+test_expect_success 'Squash some patches' '
[ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
[ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
- stg coalesce --name=q0 --message="wee woo" p1 p2 &&
+ stg squash --name=q0 --message="wee woo" p1 p2 &&
[ "$(echo $(stg series --applied --noprefix))" = "p0 q0 p3" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'
[ "$(echo $(stg series --applied --noprefix))" = "p0 q0 p3" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'
-test_expect_success 'Coalesce at stack top' '
- stg coalesce --name=q1 --message="wee woo wham" q0 p3 &&
+test_expect_success 'Squash at stack top' '
+ stg squash --name=q1 --message="wee woo wham" q0 p3 &&
[ "$(echo $(stg series --applied --noprefix))" = "p0 q1" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'
[ "$(echo $(stg series --applied --noprefix))" = "p0 q1" ] &&
[ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'
echo "Editor was invoked" | tee editor-invoked
EOF
chmod a+x editor
echo "Editor was invoked" | tee editor-invoked
EOF
chmod a+x editor
-test_expect_success 'Coalesce with top != head' '
+test_expect_success 'Squash with top != head' '
echo blahonga >> foo.txt &&
git commit -a -m "a new commit" &&
echo blahonga >> foo.txt &&
git commit -a -m "a new commit" &&
- EDITOR=./editor command_error stg coalesce --name=r0 p0 q1 &&
+ EDITOR=./editor command_error stg squash --name=r0 p0 q1 &&
test "$(echo $(stg series))" = "+ p0 > q1" &&
test ! -e editor-invoked
'
test "$(echo $(stg series))" = "+ p0 > q1" &&
test ! -e editor-invoked
'