stgit
16 years agoAdd a boundary to parse_patches in pick.py
Catalin Marinas [Mon, 24 Mar 2008 10:19:49 +0000 (10:19 +0000)]
Add a boundary to parse_patches in pick.py

By specifying 'stg pick -B aaa ..', stgit would pick both applied and unapplied patches. Simply set the boundary to len(applied) so that unapplied patches have to be picked explicitly.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoRefuse to send empty patches
Catalin Marinas [Mon, 24 Mar 2008 10:16:05 +0000 (10:16 +0000)]
Refuse to send empty patches

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoSet umask to 0022 during the setup.py execution
Catalin Marinas [Mon, 24 Mar 2008 10:16:05 +0000 (10:16 +0000)]
Set umask to 0022 during the setup.py execution

This allows template files to be installed with the proper rights.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoModify 'series' to use '#' instead of '|'
Catalin Marinas [Thu, 20 Mar 2008 23:12:12 +0000 (23:12 +0000)]
Modify 'series' to use '#' instead of '|'

This is useful if the output is dumped to a file which is later used
for commands like 'float'. The text after '#' is considered a comment
and ignored.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow the synchronisation of the unapplied patches
Catalin Marinas [Thu, 20 Mar 2008 23:12:12 +0000 (23:12 +0000)]
Allow the synchronisation of the unapplied patches

This is useful to avoid pushing patches when a sync operation failed
and needs to be resumed.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoCheck for unnecessary push/pop in 'float'
Catalin Marinas [Thu, 20 Mar 2008 23:12:12 +0000 (23:12 +0000)]
Check for unnecessary push/pop in 'float'

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow pick to import multiple patches
Catalin Marinas [Thu, 20 Mar 2008 23:12:12 +0000 (23:12 +0000)]
Allow pick to import multiple patches

This patch allows multiple patches on the "pick" command line.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoDon't set the default authdate if none specified
Catalin Marinas [Thu, 20 Mar 2008 23:12:11 +0000 (23:12 +0000)]
Don't set the default authdate if none specified

This way, we allow a patch editing to remove an existing date by not
specifying it.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoHandle failed pushes differently depending on cause
Karl Hasselström [Thu, 20 Mar 2008 23:12:11 +0000 (23:12 +0000)]
Handle failed pushes differently depending on cause

Specifically, if the push failed because of a merge conflict, the
patch should be applied but empty; and if it fails for any other
reason (such as a too-dirty worktree), the patch should not be
applied.

This fixes the data loss bug tested for by t3000.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNew test: conflicting push in dirty worktree
Karl Hasselström [Thu, 20 Mar 2008 23:12:11 +0000 (23:12 +0000)]
New test: conflicting push in dirty worktree

When the result of a conflicting push can't be represented in the
worktree because the worktree is dirty, the push should be aborted.
Similarly, the push should be aborted if we have to do the merge in
the worktree, but can't because the worktree is dirty.

Add a new test that tests for this. It currently fails, in a bad way:
the contents of the pushed patch is lost.

(The test uses goto instead of push, because push doesn't use the new
infrastructure yet. And old-infrastructure commands never have this
bug, because they refuse to run with a dirty worktree.)

This bug was found by Erik Sandberg <mandolaerik@gmail.com>, who also
came up with the minimal test case that I turned into this new test.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake sure that we only uncommit commits with exactly one parent
Karl Hasselström [Thu, 20 Mar 2008 23:12:11 +0000 (23:12 +0000)]
Make sure that we only uncommit commits with exactly one parent

If we encounter a commit with 0, or 2 or more parents, fail with a
nice error message instead of crashing.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTry uncommitting a commit with not exactly one parent
Karl Hasselström [Thu, 20 Mar 2008 23:12:10 +0000 (23:12 +0000)]
Try uncommitting a commit with not exactly one parent

This should fail cleanly -- and in fact it does. Except for printing
an assertion backtrace instead of a nice error message. (This is a
regression introduced by the conversion of "stg uncommit" to the new
infrastructure.)

Found by Erik Sandberg <mandolaerik@gmail.com>.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake sure patches with no parents have an empty list of parents
Karl Hasselström [Thu, 20 Mar 2008 23:12:10 +0000 (23:12 +0000)]
Make sure patches with no parents have an empty list of parents

They used to have None instead of an empty list, which was
inconsistent. (It went undetected for quite a while because StGit
seldom needs to handle initial commits.)

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoUse a special exit code for bugs
Karl Hasselström [Thu, 20 Mar 2008 23:12:10 +0000 (23:12 +0000)]
Use a special exit code for bugs

Use a special exit code (4) for any error condition that indicates a
bug in StGit. This will be useful in the test suite.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agostg mail crashes when there is no patch description
Angus Salkeld [Thu, 20 Mar 2008 23:12:10 +0000 (23:12 +0000)]
stg mail crashes when there is no patch description

The error is:
File "/usr/lib/python2.4/site-packages/stgit/commands/mail.py", line
397, in __build_message
descr = p.get_description().strip()
AttributeError: 'NoneType' object has no attribute 'strip'

This patch tries to handle this a bit better by setting the
description to "<empty message>" and forcing the edit_patches option
on.

16 years agoBetter "stg rebase" help text
Alex Chiang [Thu, 20 Mar 2008 23:12:10 +0000 (23:12 +0000)]
Better "stg rebase" help text

Enhance rebase help string by providing guidance on merge conflict
resolution during a rebase.

Based on text suggested by Catalin Marinas.

Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTest the 'stg rename' command
Onno Kortmann [Thu, 21 Feb 2008 21:43:18 +0000 (22:43 +0100)]
Test the 'stg rename' command

This just tests the few basic cases of the stg rename command.

Signed-off-by: Onno Kortmann <onno@gmx.net>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSimple rename of top-most patch
Onno Kortmann [Thu, 21 Feb 2008 21:42:51 +0000 (22:42 +0100)]
Simple rename of top-most patch

Allow renaming of the top-most patch just by calling stg rename
<new-patch-name>, instead of stg rename <old> <new>. This is for
example helpful for those people who always have a typo or two in
their patch names.

Signed-off-by: Onno Kortmann <onno@gmx.net>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoFix "stg branch --delete" on a nonexistent branch
Toby Allsopp [Wed, 13 Feb 2008 22:25:29 +0000 (11:25 +1300)]
Fix "stg branch --delete" on a nonexistent branch

Before this patch, I get the following:

 $ stg branch --delete tmp
 Deleting branch "tmp" ... Traceback (most recent call last):
   File "/usr/bin/stg", line 43, in ?
     main()
   File "/var/lib/python-support/python2.4/stgit/main.py", line 281, in main
     command.func(parser, options, args)
   File "/var/lib/python-support/python2.4/stgit/commands/branch.py", line 190, in func
     __delete_branch(args[0], options.force)
   File "/var/lib/python-support/python2.4/stgit/commands/branch.py", line 100, in __delete_branch
     doomed.delete(force)
   File "/var/lib/python-support/python2.4/stgit/stack.py", line 758, in delete
     except GitException:
 NameError: global name 'GitException' is not defined

After it, I get:

 Deleting branch "tmp" ...
   Warning: Could not delete branch "tmp"
 done

Signed-off-by: Toby Allsopp <toby.allsopp@navman.co.nz>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: change "stg repair" binding
Karl Hasselström [Mon, 11 Feb 2008 22:21:53 +0000 (23:21 +0100)]
Emacs mode: change "stg repair" binding

It used to be C-r, but that's commonly used for reverse searching, so
use R instead.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove unused data field
Karl Hasselström [Tue, 12 Feb 2008 02:15:53 +0000 (03:15 +0100)]
Remove unused data field

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: It's possible to edit unapplied patches now
Karl Hasselström [Thu, 31 Jan 2008 14:36:58 +0000 (15:36 +0100)]
Emacs mode: It's possible to edit unapplied patches now

With the rewrite, "stg edit" gained the ability to edit unapplied
patches, so the emacs mode no longer has to check that a patch is
applied before trying to edit it.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoConvert "stg edit" to the new infrastructure
Karl Hasselström [Fri, 1 Feb 2008 03:37:56 +0000 (04:37 +0100)]
Convert "stg edit" to the new infrastructure

The --annotate and --undo switches were dropped in the conversion.
--annotate could be re-added, but --undo is more problematic since the
command will now rewrite any applied patches on top of the edited
patch. It seems best to leave this job to the fabled general undo
command, expected Real Soon Now.

In addition to the usual improvements from the new infrastructure,
this patch has some additional benefits:

  * There's a new -e/--edit flag, which forces interactive editing
    even if options such as --sign or --author are given. (Normally,
    interactive editing is skipped if the patch is modified with a
    commandline option.)

  * It's now possible to edit any patch, including unapplied patches.
    Even diff editing works for all patches, including unapplied
    patches. (In fact, editing unapplied patches is slightly safer,
    since they don't mind a dirty index/worktree.)

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoParse the date instead of treating it as an opaque string
Karl Hasselström [Fri, 1 Feb 2008 05:12:17 +0000 (06:12 +0100)]
Parse the date instead of treating it as an opaque string

This is needed for when we want to display it, since the
seconds-since-the-epoch format isn't that human-friendly.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTeach new infrastructure to diff two trees
Karl Hasselström [Mon, 28 Jan 2008 23:11:59 +0000 (00:11 +0100)]
Teach new infrastructure to diff two trees

Nothing uses this yet, but "stg edit" will soon.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTeach new infrastructure to apply patches
Karl Hasselström [Mon, 28 Jan 2008 17:45:42 +0000 (18:45 +0100)]
Teach new infrastructure to apply patches

Two new methods: one index method that applies a patch to that index
or fails without side-effects (without touching a worktree in either
case); and one repository method that uses a temp index to apply a
patch to a tree and returning the new tree (or None if the application
failed), entirely side-effect free.

Nothing uses this yet, but "stg edit" will soon.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTeach new infrastructure about the default author and committer
Karl Hasselström [Mon, 28 Jan 2008 22:11:32 +0000 (23:11 +0100)]
Teach new infrastructure about the default author and committer

As specified by the config options user.name and user.email, and the
environment variables GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL,DATE} (the
latter overriding the former).

Nothing uses this yet, but "stg edit" will soon.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd an --index option to "stg refresh"
Peter Oberndorfer [Tue, 8 Jan 2008 16:42:46 +0000 (17:42 +0100)]
Add an --index option to "stg refresh"

Add an --index option to "stg refresh" which takes the contents of the
index as the new commit.

This allows to stage only certain changes to a file by only adding the
desired parts to the index with git-gui, ugit, git add -i or another
tool that manipulates the index and then run stg refresh --index it.
Also allows removing a file from a patch by running git reset HEAD^ --
file_to_remove followed by a stg refresh --index.

Signed-off-by: Peter Oberndorfer <kumbayo84@arcor.de>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRead default diff options from the user's config
Karl Hasselström [Thu, 24 Jan 2008 03:20:24 +0000 (04:20 +0100)]
Read default diff options from the user's config

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoLet "stg show" use the unified --diff-opts handling
Karl Hasselström [Thu, 24 Jan 2008 02:23:30 +0000 (03:23 +0100)]
Let "stg show" use the unified --diff-opts handling

This introduces a small UI change: "stg show" called that flag
--show-opts. This could of course be avoided, but I don't think it's
worth it, since git-diff and git-show accept mostly the same options.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoReduce number of backslashes by using raw strings
Karl Hasselström [Tue, 5 Feb 2008 05:51:30 +0000 (06:51 +0100)]
Reduce number of backslashes by using raw strings

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake documentation less confusing
Karl Hasselström [Mon, 4 Feb 2008 18:57:42 +0000 (19:57 +0100)]
Make documentation less confusing

It's not just by default "stg new" doesn't do a refresh -- it never
does.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDon't check out files if we don't have index+workdir
Karl Hasselström [Sun, 10 Feb 2008 14:43:41 +0000 (15:43 +0100)]
Don't check out files if we don't have index+workdir

It seems no one had tried to run a transaction without having an index
and a workdir, but this is exacly the situation we get when operating
on a stack other than the current one.

The fix is simple: don't try to check out.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDon't clean away patches with conflicts
Karl Hasselström [Sun, 27 Jan 2008 06:48:02 +0000 (07:48 +0100)]
Don't clean away patches with conflicts

If we have conflicts, it means that the topmost patch is empty because
of those conflicts (since StGit explicitly makes a conflicting patch
empty), so don't let "stg clean" touch it.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd test to ensure that "stg clean" preserves conflicting patches
Pavel Roskin [Fri, 25 Jan 2008 08:55:17 +0000 (03:55 -0500)]
Add test to ensure that "stg clean" preserves conflicting patches

If "stg push" fails, the subsequent "stg clean" will remove the patch
that could not be applied. I think it's wrong. Especially when doing
"stg pull", it can happen that I want to run "stg clean" to get rid of
the patches applied upstream so I can concentrate on the conflict.
Instead, the conflicting patch is removed too.

The test added by this patch should pass once the bug is fixed.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoLet the caller supply the diff text to diffstat()
Karl Hasselström [Sun, 27 Jan 2008 13:31:31 +0000 (14:31 +0100)]
Let the caller supply the diff text to diffstat()

Almost all diffstat() callers already have the diff text, so they
might as well pass it to diffstat() instead of letting it recompute
it. In some cases this even makes for a code simplification since the
diff (and thus diffstat) parameters were nontrivial.

Also, diffstat() wasn't as versatile as diff(); for example, it didn't
accept any extra diff options. This patch solves all of those problems
as a side-effect.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSimplify editor selection logic
Karl Hasselström [Mon, 28 Jan 2008 20:19:34 +0000 (21:19 +0100)]
Simplify editor selection logic

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEliminate temp variable that's used just once
Karl Hasselström [Mon, 28 Jan 2008 21:20:09 +0000 (22:20 +0100)]
Eliminate temp variable that's used just once

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoWrap excessively long line
Karl Hasselström [Sun, 27 Jan 2008 12:27:35 +0000 (13:27 +0100)]
Wrap excessively long line

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoCreate index and worktree objects just once
Karl Hasselström [Sun, 27 Jan 2008 08:06:15 +0000 (09:06 +0100)]
Create index and worktree objects just once

Create the objects for a repository's default index, worktree, and
index+worktree just once. Both for performance (though the gain is
probably negligible), and for future-proofing if we ever add mutable
state to those objects.

And make them properties while we're at it.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRefactor --diff-opts handling
Karl Hasselström [Thu, 24 Jan 2008 06:07:08 +0000 (07:07 +0100)]
Refactor --diff-opts handling

Lots of commands take a -O/--diff-opts flag, and they all handle it
identically. So break that out into a library function.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove unused default values
Karl Hasselström [Thu, 24 Jan 2008 06:08:57 +0000 (07:08 +0100)]
Remove unused default values

This function was called from only one place, and the default values
weren't used there, so they're useless.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoHomogenize buffer names
Karl Hasselström [Thu, 24 Jan 2008 06:30:32 +0000 (07:30 +0100)]
Homogenize buffer names

It was driving me crazy that I couldn't tab-complete "*stg" to
"*stgit*" because there was always a "*stgit edit*" buffer lying
around.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDon't keep old committer when rewriting a commit
Karl Hasselström [Thu, 24 Jan 2008 06:17:58 +0000 (07:17 +0100)]
Don't keep old committer when rewriting a commit

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoreplace "git repo-config" usage by "git config"
Peter Oberndorfer [Wed, 16 Jan 2008 20:58:26 +0000 (21:58 +0100)]
replace "git repo-config" usage by "git config"

This is necessary since "git repo-config" will be removed soon.

Signed-off-by: Peter Oberndorfer <kumbayo84@arcor.de>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoFix "stg edit --sign"
Pavel Roskin [Sat, 12 Jan 2008 04:58:03 +0000 (23:58 -0500)]
Fix "stg edit --sign"

It worked in 0.14, but was broken some time after the release.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDon't mention removed "stg refresh" options
Peter Oberndorfer [Tue, 8 Jan 2008 20:43:53 +0000 (21:43 +0100)]
Don't mention removed "stg refresh" options

Change usage string of refresh to not refer to removed options for
changing the patch author, commiter and description.

Signed-off-by: Peter Oberndorfer <kumbayo84@arcor.de>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake "stg goto" subdirectory safe
Karl Hasselström [Wed, 19 Dec 2007 21:12:20 +0000 (22:12 +0100)]
Make "stg goto" subdirectory safe

This is not specific to "stg goto" -- it affects all commands that use
the new infrastructure. (But of those, only goto and coalesce were
subdirectory unsafe.)

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTest that "stg goto" can be called from a subdirectory
Karl Hasselström [Wed, 19 Dec 2007 20:51:21 +0000 (21:51 +0100)]
Test that "stg goto" can be called from a subdirectory

It currently can't; therefore, the tests are marked as known failures.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: coalesce command
David Kågedal [Fri, 14 Dec 2007 08:59:49 +0000 (09:59 +0100)]
Emacs mode: coalesce command

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: Add mark command
David Kågedal [Fri, 14 Dec 2007 08:59:32 +0000 (09:59 +0100)]
Emacs mode: Add mark command

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake "stg commit" fancier
Karl Hasselström [Wed, 12 Dec 2007 22:48:56 +0000 (23:48 +0100)]
Make "stg commit" fancier

Allow the user to commit any patch. Changed behavior: with no
parameters, commit one applied patch, not all applied patches -- this
is what uncommit does.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoConvert "stg commit" to new infrastructure
Karl Hasselström [Wed, 12 Dec 2007 21:59:13 +0000 (22:59 +0100)]
Convert "stg commit" to new infrastructure

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSet exit code to 3 on merge conflict
Karl Hasselström [Wed, 12 Dec 2007 20:56:42 +0000 (21:56 +0100)]
Set exit code to 3 on merge conflict

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agostg coalesce: Support --file and --save-template
Karl Hasselström [Wed, 12 Dec 2007 20:08:46 +0000 (21:08 +0100)]
stg coalesce: Support --file and --save-template

--save-template was a bit tricky, because we want that

  * if we reached the stage where the message is needed without
    conflicts, the message should be written and no other side effects
    should occur; but

  * if we run into conflicts before reaching that point, behave just
    as if --save-template was not given.

This makes this script

  stg coalesce --save-template <patches>
  if template was saved:
    let user edit template
    if user didn't abort:
      stg coalesce --file <patches>

equivalent to

  stg coalesce <patches>

with the added benefit that the user can abort the whole thing without
visible side effects.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoExpose transaction abort function
Karl Hasselström [Thu, 13 Dec 2007 17:10:45 +0000 (18:10 +0100)]
Expose transaction abort function

Users of stack transactions may call abort() instead of run(), if they
wish to roll back the transaction instead of committing it.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNew infrastructure: Make sure that the branch is initialized
Karl Hasselström [Thu, 29 Nov 2007 19:35:27 +0000 (20:35 +0100)]
New infrastructure: Make sure that the branch is initialized

The old infrastructure has been checking this for ages, but the new
forgot to do so until now.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoConvert "stg uncommit" to the new infrastructure
Karl Hasselström [Sun, 25 Nov 2007 04:29:16 +0000 (05:29 +0100)]
Convert "stg uncommit" to the new infrastructure

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoLet "stg goto" use the new infrastructure
Karl Hasselström [Sun, 9 Dec 2007 12:34:12 +0000 (13:34 +0100)]
Let "stg goto" use the new infrastructure

In the process, it loses the --keep option, since the new
infrastructure always keeps local changes (and aborts cleanly if they
are in the way).

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoLet "stg clean" use the new transaction primitives
Karl Hasselström [Sat, 24 Nov 2007 16:34:03 +0000 (17:34 +0100)]
Let "stg clean" use the new transaction primitives

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTeach the new infrastructure about the index and worktree
Karl Hasselström [Sun, 9 Dec 2007 07:56:12 +0000 (08:56 +0100)]
Teach the new infrastructure about the index and worktree

And use the new powers to make "stg coalesce" able to handle arbitrary
patches, not just consecutive applied patches.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove a newline from the e-mail template
Catalin Marinas [Wed, 19 Dec 2007 18:00:16 +0000 (18:00 +0000)]
Remove a newline from the e-mail template

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoRemove unused git functions like add, rm, copy
Catalin Marinas [Wed, 19 Dec 2007 18:00:15 +0000 (18:00 +0000)]
Remove unused git functions like add, rm, copy

They are no longer needed.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoRemove multiple stages returned by git.ls_files
Catalin Marinas [Wed, 19 Dec 2007 18:00:15 +0000 (18:00 +0000)]
Remove multiple stages returned by git.ls_files

This patch uses a set to return unique file names from git.ls_files in
case there are multiple stages in the index.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoDon't assume there is always a stage 2 in git.get_conflicts
Catalin Marinas [Wed, 19 Dec 2007 18:00:15 +0000 (18:00 +0000)]
Don't assume there is always a stage 2 in git.get_conflicts

For example, the t1202-push-undo.sh test generates a conflict where a
file was added in both current and patch but different content and
missing in ancestor, therefore no stage 2.

There could also be a case where stage 3 is missing if a file is
removed by the patch being pushed.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoRe-add the interactive merge
Catalin Marinas [Wed, 19 Dec 2007 18:00:15 +0000 (18:00 +0000)]
Re-add the interactive merge

This feature was dropped by previous changes to
git.merge_recursive(). This patch modifies gitmergeonefile.merge() to
only deal with interactive merges or simply check out the conflict
stages. The stgit.commands.common.resolved() function was moved to
git.resolved(). The patch also drops the git.merge() function since it
can no longer use gitmergeonefile.merge() (different API) and modifies
the 'sync' command to always use git.merge_recursive().

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoLet "stg applied" and "stg unapplied" use the new infrastructure
Karl Hasselström [Wed, 19 Dec 2007 18:00:15 +0000 (18:00 +0000)]
Let "stg applied" and "stg unapplied" use the new infrastructure

This is a trivial change since these commands are so simple, but
because these are the commands used by t4000-upgrade, we now test that
the new infrastructure can upgrade old stacks.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd "stg coalesce"
Karl Hasselström [Wed, 19 Dec 2007 18:00:14 +0000 (18:00 +0000)]
Add "stg coalesce"

It coalesces two or more consecutive applied patches, with no need to
touch index/worktree, and no possibiliy of conflicts.

Future improvements could relax the "consecutive" and "applied"
restrictions, by building a new chain of commits just like "stg push"
will do once it's been converted to the new infrastructure.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoLet "stg clean" use the new infrastructure
Karl Hasselström [Wed, 19 Dec 2007 18:00:14 +0000 (18:00 +0000)]
Let "stg clean" use the new infrastructure

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoUpgrade older stacks to newest version
Karl Hasselström [Wed, 19 Dec 2007 18:00:14 +0000 (18:00 +0000)]
Upgrade older stacks to newest version

This is of course needed by the new infrastructure as well. So break
it out into its own file, where it can be used by both new and old
infrastructure. This has the added benefit of making it easy to see
that the upgrade code doesn't depend on anything it shouldn't.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoWrite metadata files used by the old infrastructure
Karl Hasselström [Wed, 19 Dec 2007 18:00:14 +0000 (18:00 +0000)]
Write metadata files used by the old infrastructure

The new infrastructure doesn't use them, but they're needed to support
the old infrastructure during the transition when both of them are in
use.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNew StGit core infrastructure: repository operations
Karl Hasselström [Wed, 19 Dec 2007 18:00:14 +0000 (18:00 +0000)]
New StGit core infrastructure: repository operations

This is the first part of the New and Improved StGit core
infrastructure. It has functions for manipulating the git repository
(commits, refs, and so on), but doesn't yet touch the index or
worktree.

Currently not used by anything.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove "stg cp"
Karl Hasselström [Wed, 19 Dec 2007 18:00:13 +0000 (18:00 +0000)]
Remove "stg cp"

Plain old "cp" and git-add can do the job just as well.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove "stg rm"
Karl Hasselström [Wed, 19 Dec 2007 18:00:13 +0000 (18:00 +0000)]
Remove "stg rm"

git-rm can do the same job just as well. Besides, since StGit notices
when a file disappears, just "rm" can also do the job.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove "stg add"
Karl Hasselström [Wed, 19 Dec 2007 18:00:13 +0000 (18:00 +0000)]
Remove "stg add"

git-add does the exact same job, so there's no need to have it in
StGit.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoWe keep the different stages of a conflict in the index now
Karl Hasselström [Wed, 19 Dec 2007 18:00:13 +0000 (18:00 +0000)]
We keep the different stages of a conflict in the index now

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRefactoring: pass more than one file to resolved()
Karl Hasselström [Wed, 19 Dec 2007 18:00:13 +0000 (18:00 +0000)]
Refactoring: pass more than one file to resolved()

This lets us cut down on the number of calls to git.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoFix "stg resolved" to work with new conflict representation
Karl Hasselström [Wed, 19 Dec 2007 18:00:13 +0000 (18:00 +0000)]
Fix "stg resolved" to work with new conflict representation

The actual resolving is done by calling the same subroutine as "git
add".

Instead of using existing *.{ancestor,current,patches} files, the
interactive merge has to create them from the index contents, and
delete them afterwards.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoBetter error message if merge fails
Karl Hasselström [Wed, 19 Dec 2007 18:00:12 +0000 (18:00 +0000)]
Better error message if merge fails

This message is no longer printed in case of conflicts, just in case
the merge really failed; so don't talk about conflicts in the error
message.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAsk git about unmerged files
David Kågedal [Wed, 19 Dec 2007 18:00:12 +0000 (18:00 +0000)]
Ask git about unmerged files

Don't look in the "conflicts" file for that, since it isn't updated. Also
added a test that the check_conflicts() function works.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNicer conflict markers
Karl Hasselström [Wed, 19 Dec 2007 18:00:12 +0000 (18:00 +0000)]
Nicer conflict markers

Instead of tagging the conflict markers with sha1 hashes, use
"ancestor", "current", and "patched".

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoUse the output from merge-recursive to list conflicts
David Kågedal [Wed, 19 Dec 2007 18:00:12 +0000 (18:00 +0000)]
Use the output from merge-recursive to list conflicts

merge-recursive already has useful information about what the conflicts
were, so we reuse that when pushing.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSimplify merge_recursive
David Kågedal [Wed, 19 Dec 2007 18:00:12 +0000 (18:00 +0000)]
Simplify merge_recursive

Listing the unmerged files is unnecessary, since the information
isn't really used anyway. Just note if the merge failed or succeeded.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdded a test case to check what happens when push finds a conflict
David Kågedal [Wed, 19 Dec 2007 18:00:11 +0000 (18:00 +0000)]
Added a test case to check what happens when push finds a conflict

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoLeave working dir and index alone after failed (conflicting) push
David Kågedal [Wed, 19 Dec 2007 18:00:11 +0000 (18:00 +0000)]
Leave working dir and index alone after failed (conflicting) push

This leaves the index and working tree in the state that merge-recursive
left it, with unmerged files in different stages, and the non-conflicting
changes in the index.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSplit git.merge into two functions
David Kågedal [Wed, 19 Dec 2007 18:00:11 +0000 (18:00 +0000)]
Split git.merge into two functions

This only prepares for later simplifications.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoWrite removed fields for backwards compatibility
Karl Hasselström [Wed, 19 Dec 2007 18:00:11 +0000 (18:00 +0000)]
Write removed fields for backwards compatibility

Start writing the "top", "bottom", and "bottom.old" fields again. The
last two patches mean we don't need them anymore, but old versions of
StGit still do.

At some later time, we'll want to change the stack on-disk format so
that these can be removed. But we'll probably want to do that as part
of a larger change.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove the 'top' field
David Kågedal [Wed, 19 Dec 2007 18:00:11 +0000 (18:00 +0000)]
Remove the 'top' field

The top is instead implicitly defined by the patch ref.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove the 'bottom' field
David Kågedal [Wed, 19 Dec 2007 18:00:10 +0000 (18:00 +0000)]
Remove the 'bottom' field

The bottom is instead always calculated from the top by getting its
parent commit.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoCheck bottom and invariants
David Kågedal [Wed, 19 Dec 2007 18:00:10 +0000 (18:00 +0000)]
Check bottom and invariants

This code adds some checks that the bottom is actually always the
parent of top.

It also checks that the top is the same as what the patch ref points
to.

This is only to ensure that the next patches are correct.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: Added stgit-new
David Kågedal [Wed, 19 Dec 2007 18:00:09 +0000 (18:00 +0000)]
Emacs mode: Added stgit-new

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: added fontification
David Kågedal [Wed, 19 Dec 2007 18:00:09 +0000 (18:00 +0000)]
Emacs mode: added fontification

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: Add stgit-edit command
David Kågedal [Wed, 19 Dec 2007 18:00:09 +0000 (18:00 +0000)]
Emacs mode: Add stgit-edit command

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: added stgit-commit and stgit-uncommit
David Kågedal [Wed, 19 Dec 2007 18:00:09 +0000 (18:00 +0000)]
Emacs mode: added stgit-commit and stgit-uncommit

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: add stgit-repair
David Kågedal [Wed, 19 Dec 2007 18:00:09 +0000 (18:00 +0000)]
Emacs mode: add stgit-repair

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: Bind n and p
David Kågedal [Wed, 19 Dec 2007 18:00:09 +0000 (18:00 +0000)]
Emacs mode: Bind n and p

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: Improve the output buffer state
David Kågedal [Wed, 19 Dec 2007 18:00:08 +0000 (18:00 +0000)]
Emacs mode: Improve the output buffer state

Make the output buffer have the correct default-directory, and make it
read-only and unmodified.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoEmacs mode: show patches' short description
Karl Hasselström [Wed, 19 Dec 2007 18:00:08 +0000 (18:00 +0000)]
Emacs mode: show patches' short description

Signed-off-by: Karl Hasselström <kha@treskal.com>
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
16 years agoEmacs mode: Bind "G" to "stg goto"
Karl Hasselström [Wed, 19 Dec 2007 18:00:08 +0000 (18:00 +0000)]
Emacs mode: Bind "G" to "stg goto"

Signed-off-by: Karl Hasselström <kha@treskal.com>
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
16 years agoEmacs mode: Let "P" push or pop patch at point
Karl Hasselström [Wed, 19 Dec 2007 18:00:08 +0000 (18:00 +0000)]
Emacs mode: Let "P" push or pop patch at point

When the user presses "P", push or pop the patch at point depending on
whether it's applied or unapplied.

Signed-off-by: Karl Hasselström <kha@treskal.com>
Signed-off-by: David Kågedal <davidk@lysator.liu.se>