stgit
16 years agoRelease 0.14 v0.14
Catalin Marinas [Sun, 9 Dec 2007 23:45:08 +0000 (23:45 +0000)]
Release 0.14

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoBetter handling of binary files (bug #8495)
Catalin Marinas [Sun, 9 Dec 2007 23:32:58 +0000 (23:32 +0000)]
Better handling of binary files (bug #8495)

The patch adds the '--binary' option to the git-diff-tree and git-diff-index
commands. The git-apply no longer needs this flag as it is set by default.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow only certain gitk exit codes as valid
Catalin Marinas [Sat, 8 Dec 2007 23:16:30 +0000 (23:16 +0000)]
Allow only certain gitk exit codes as valid

This patch fixes the log and series commands to not report an error when
gitk is killed by the user.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoDon't use test_expect_failure for tests that are supposed to work
Karl Hasselström [Sat, 8 Dec 2007 11:00:10 +0000 (12:00 +0100)]
Don't use test_expect_failure for tests that are supposed to work

test_expect_failure is only for marking known bugs.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDiscard exitcode of subprocess in a better way
Karl Hasselström [Sat, 8 Dec 2007 08:27:22 +0000 (09:27 +0100)]
Discard exitcode of subprocess in a better way

Discard the exit code in a way that meshes better with the existing
handling of exit codes.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoFix bashism
Karl Hasselström [Sat, 8 Dec 2007 09:30:40 +0000 (10:30 +0100)]
Fix bashism

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake sure the refid given to 'mail' has the angle brackets
Catalin Marinas [Fri, 7 Dec 2007 21:19:25 +0000 (21:19 +0000)]
Make sure the refid given to 'mail' has the angle brackets

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoSome clean-up of the branch manipulation commands
Catalin Marinas [Fri, 7 Dec 2007 21:19:25 +0000 (21:19 +0000)]
Some clean-up of the branch manipulation commands

A GIT branch couldn't be deleted if it wasn't a StGIT stack. Added
tests for the creation of branches when the current branch isn't a
stack.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoIgnore the gitk exit code in 'stg log -g' (bug #10010)
Catalin Marinas [Fri, 7 Dec 2007 21:19:25 +0000 (21:19 +0000)]
Ignore the gitk exit code in 'stg log -g' (bug #10010)

The patch adds the 'exitcode' boolean argument to Run.run() and
modifies the 'log' command.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAdd the 'log --number' option to limit the output
Catalin Marinas [Fri, 7 Dec 2007 21:19:25 +0000 (21:19 +0000)]
Add the 'log --number' option to limit the output

The patch also changes the construction of the string when --patch is
supplied to avoid resource consumption (using a list and joining at
the end rather than creating a bigger and bigger string).

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoChange the file timestamp in 'resolved --reset' (bug #10017)
Catalin Marinas [Fri, 7 Dec 2007 21:19:24 +0000 (21:19 +0000)]
Change the file timestamp in 'resolved --reset' (bug #10017)

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow 'show' and 'id' to work on non-StGIT branches (bug #10011)
Catalin Marinas [Fri, 7 Dec 2007 21:19:24 +0000 (21:19 +0000)]
Allow 'show' and 'id' to work on non-StGIT branches (bug #10011)

Some clean-up to only access the current series object if needed.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agogit.pretty_commit() re-implemented with "git show" (bug #10018)
Catalin Marinas [Fri, 7 Dec 2007 21:16:36 +0000 (21:16 +0000)]
git.pretty_commit() re-implemented with "git show" (bug #10018)

This way, it honours the diff.renames etc. options.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoCheck the minimum required versions of GIT and Python (bug #10218)
Catalin Marinas [Fri, 7 Dec 2007 21:16:36 +0000 (21:16 +0000)]
Check the minimum required versions of GIT and Python (bug #10218)

The patch modifies the setup.py script to check the minimum versions
of GIT and Python required for building and installing StGIT. They are
currently set to git-1.5.2 and Python-2.4.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAdd a test for the 'mail --attach' command
Catalin Marinas [Fri, 7 Dec 2007 21:16:36 +0000 (21:16 +0000)]
Add a test for the 'mail --attach' command

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow multipart templates for patch e-mails (bug #10237)
Catalin Marinas [Thu, 6 Dec 2007 23:28:42 +0000 (23:28 +0000)]
Allow multipart templates for patch e-mails (bug #10237)

If the template is a multipart MIME message, it sets the charset only to
the payloads. The patch also adds the '--attach' option to 'mail' which uses
the templates/mailattch.tmpl template file.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoClean-up if the branch creation fails (bug #10015)
Catalin Marinas [Tue, 4 Dec 2007 21:46:14 +0000 (21:46 +0000)]
Clean-up if the branch creation fails (bug #10015)

If the tree switching fails during the branch creation, the new head
will be reverted and the new branch deleted.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoCorrectly identify the parent branch (bug #10014)
Catalin Marinas [Mon, 3 Dec 2007 10:30:20 +0000 (10:30 +0000)]
Correctly identify the parent branch (bug #10014)

Any valid git ref was identified as a possible parent branch. This patch
adds a check for the refs listed by git-show-ref.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoCheck for disappeared newborn files in git.tree_status (bug #8516)
Catalin Marinas [Sat, 1 Dec 2007 23:00:00 +0000 (23:00 +0000)]
Check for disappeared newborn files in git.tree_status (bug #8516)

If a file is added to the index (stg add) but is removed from the shell,
git.tree_status doesn't detect it but other commands like push fail. The
patch adds a call to 'git diff-files' in git.tree_status.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoMake Series.refresh_patch automatically save the undo information
Catalin Marinas [Sat, 1 Dec 2007 22:59:59 +0000 (22:59 +0000)]
Make Series.refresh_patch automatically save the undo information

The patch pushing with was losing the undo information because the arguments
passed to refresh_patch. The backup argument now defaults to True since
this is needed in most of the cases.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoMake "stg repair" help text more helpful
Karl Hasselström [Fri, 30 Nov 2007 01:20:03 +0000 (02:20 +0100)]
Make "stg repair" help text more helpful

Specifically, point out that if messing up the branch with git
commands was a mistake, the user should run "git reset", not "stg
repair".

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoImprove the t1205 test for push
Catalin Marinas [Tue, 27 Nov 2007 22:30:21 +0000 (22:30 +0000)]
Improve the t1205 test for push

Bug #9311 reported in the past for a push conflict with an unrecorded
file. It is no longer reproducible but test added for future
regression.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoKeep the patch log when import --replace deletes patches
Catalin Marinas [Tue, 27 Nov 2007 10:32:12 +0000 (10:32 +0000)]
Keep the patch log when import --replace deletes patches

This is a fix for bug #10123.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAdd missing switch to "stg uncommit" usage line
Karl Hasselström [Sun, 25 Nov 2007 11:42:35 +0000 (12:42 +0100)]
Add missing switch to "stg uncommit" usage line

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoPush and pop don't have --to flags anymore
Karl Hasselström [Sun, 25 Nov 2007 08:52:04 +0000 (09:52 +0100)]
Push and pop don't have --to flags anymore

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agostg-gitk: allow passing args to gitk; add --help.
Yann Dirson [Thu, 22 Nov 2007 21:23:34 +0000 (22:23 +0100)]
stg-gitk: allow passing args to gitk; add --help.

Quite handy to further limit the commits to be shown.

16 years agoAdded test case for stg refresh
David Kågedal [Wed, 21 Nov 2007 10:35:59 +0000 (11:35 +0100)]
Added test case for stg refresh

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoExecute the 'git ...' rather than 'git-...'
Catalin Marinas [Wed, 14 Nov 2007 21:14:55 +0000 (21:14 +0000)]
Execute the 'git ...' rather than 'git-...'

Since many commands are now built into the git binary, it doesn't make
sense to run the git-... scripts. The patch modifies the GRun class to
pass the 'git' file name together with the command arguments. It also
modifies all the other calls to git-...

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years ago'stg pop --keep' doesn't update the index
Catalin Marinas [Wed, 14 Nov 2007 21:14:55 +0000 (21:14 +0000)]
'stg pop --keep' doesn't update the index

While git.apply_diff works correctly, the git.switch implementation
doesn't update the index (only the HEAD) and a subsequent 'stg refresh'
would merge all the popped patches into the current one ('stg refresh
--patch' fails in the same way). This patch fixes git.switch to read the
new index (git-read-tree) if keep == True.

Before commit a77bfa77 (to fix bug #8972), git-apply had the --index
option to automatically update the index but it was failing in many
cases.

The drawback is that a subsequent git-update-index takes longer than
usual, but at least we have a correct behaviour.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow the diff showing in the log command if patch modified by edit
Catalin Marinas [Mon, 12 Nov 2007 10:57:09 +0000 (10:57 +0000)]
Allow the diff showing in the log command if patch modified by edit

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agostg repair: Patchify non-patch commits between patches
Karl Hasselström [Sun, 11 Nov 2007 12:39:12 +0000 (13:39 +0100)]
stg repair: Patchify non-patch commits between patches

This teaches "stg repair" to find non-patch commits that sit between
patches, and turn them into patches. This situation can happen e.g.
like this:

  stg new -m A && stg new -m B && stg new -m C
  stg pop A B C
  stg push B
  echo foo > foo && git add foo && stg refresh
  git reset --hard $(stg id C)

The old "stg repair" would at this point simply conclude that A and C
are applied, and B unapplied. However, B's old commit is still between
them even though it's not a patch, which will cause problems later --
StGit generally assumes that the applied patches are a consecutive
string of commits. The new "stg repair", on the other hand, will find
B's old commit, and create a new patch for it.

One downside of this change is that we can no longer conclude that all
is well just because head == top, so no-op runs of "stg repair" just
got more expensive.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRename "stg assimilate" to "stg repair"
Karl Hasselström [Sun, 11 Nov 2007 13:07:36 +0000 (14:07 +0100)]
Rename "stg assimilate" to "stg repair"

With the capabilities it's gained lately, this is a better name.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoLet some commands work with detached HEAD
Karl Hasselström [Mon, 8 Oct 2007 03:52:06 +0000 (05:52 +0200)]
Let some commands work with detached HEAD

add, resolved, and status didn't use the crt_series that was
initialized for them. So don't initialize it, since that means (1)
less work and (2) they won't fail when HEAD is detached.

Note that this doesn't completely fix the problem with detached HEAD:
a number of other commands (e.g. branch) don't always need to refer to
a current series, but currently fails on a detached HEAD even in those
situations.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoCogito is deprecated, so don't point to it
Karl Hasselström [Wed, 31 Oct 2007 23:27:54 +0000 (00:27 +0100)]
Cogito is deprecated, so don't point to it

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSimple test for "stg clean"
Karl Hasselström [Thu, 8 Nov 2007 04:54:26 +0000 (05:54 +0100)]
Simple test for "stg clean"

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoFix more commands to run correctly in subdirectories
Catalin Marinas [Wed, 7 Nov 2007 22:12:24 +0000 (22:12 +0000)]
Fix more commands to run correctly in subdirectories

Raised recently with bug #10276, commands manipulating patches might
fail to run correctly (even losing data) in subdirectories, mainly
because of git-apply (see the bug log for explanation). This patch
forces all the patch-modifying commands to go to the top level
directory before acting.

In addition to the above, ot also fixes the resolved and export
commands.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow "branch --create" to be given a tag id
Catalin Marinas [Fri, 2 Nov 2007 21:25:58 +0000 (21:25 +0000)]
Allow "branch --create" to be given a tag id

In the past, this used to lead to a broken branch which could be
difficult to even delete. This patch allows the branch to be created
properly and be more tolerant to branch deletion.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow StGIT commands to run correctly in subdirectories
Catalin Marinas [Tue, 23 Oct 2007 21:20:53 +0000 (22:20 +0100)]
Allow StGIT commands to run correctly in subdirectories

This is mainly achieved by checking the file arguments with
git-ls-files. The patch solves two main issues - the refresh/diff/st
can run properly in subdirectories and commands like diff and status
may no longer get nonexistent files as arguments without complaining.

If one wants to check the status/diff or refresh the files in a
subdirectory, the command arguments should be "." and this is expanded
by git-ls-files to the subdirectory content (recursively).

The patch removes some asserts as they are no longer needed since
checks are performed by git-ls-files.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoDo not raise an exception if no FETCH_HEAD
Catalin Marinas [Wed, 17 Oct 2007 20:35:21 +0000 (21:35 +0100)]
Do not raise an exception if no FETCH_HEAD

The fetchcmd option in .git/config can be set to a command that
doesn't generate a FETCH_HEAD file (like 'git svn fetch'). With this
patch, StGIT will only warn if no FETCH_HEAD is found as it is quite
likely that the rebasecmd doesn't need one ('git svn rebase'). The
patch also modifies the 'fetch-rebase' case in pull.py so that it
re-raises the exception initially raised by git.fetch_head() as this
function has the correct information about the type of exception.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years ago"stg pop --keep" fails because of git-apply --index (bug #8972)
Catalin Marinas [Wed, 17 Oct 2007 20:35:21 +0000 (21:35 +0100)]
"stg pop --keep" fails because of git-apply --index (bug #8972)

This patch calls git-apply without --index if --keep is passed to the
pop or goto commands.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoFix assertion in patch creation
Catalin Marinas [Wed, 17 Oct 2007 20:35:01 +0000 (21:35 +0100)]
Fix assertion in patch creation

Top and bottom can be unrelated if the "commit" argument is true since
new_patch will generate a new commit object anyway. Fix the
corresponding assert.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoNew test: "stg diff"
Karl Hasselström [Tue, 9 Oct 2007 04:34:24 +0000 (06:34 +0200)]
New test: "stg diff"

A simple test to make sure that we can run "stg diff" without
arguments, just to list local changes.

Note that two subtests currently fail; these are due to plain "stg
diff" failing on a branch where "stg init" hasn't been run, which is
plainly a bug.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoFix error message generation
Karl Hasselström [Tue, 9 Oct 2007 04:20:34 +0000 (06:20 +0200)]
Fix error message generation

The right-hand-side operand of % is supposed to be a tuple with the
same number of arguments as there are formatting codes in the
left-hand-side operand, or just any value if there is just one
formatting code; however, here it was a variable with a tuple value,
which didn't work. So wrap it in a tuple of length one, and all is
well again.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDon't have a global crt_series in stgit.commans.common
Karl Hasselström [Mon, 8 Oct 2007 08:36:49 +0000 (10:36 +0200)]
Don't have a global crt_series in stgit.commans.common

Global variables baaad. Instead, pass it as a parameter to the
functions that need it.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRefactor crt_series creation
Karl Hasselström [Mon, 8 Oct 2007 05:46:27 +0000 (07:46 +0200)]
Refactor crt_series creation

Instead of hard-coding in main.py which commands do and don't need a
current series, let them speak for themselves.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoProperly detect that HEAD is detached
Karl Hasselström [Mon, 8 Oct 2007 05:15:33 +0000 (07:15 +0200)]
Properly detect that HEAD is detached

We still error out on a lot of places we shouldn't, e.g. "stg branch"
when on a detached HEAD, but at least now we give a sane error
message.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoUse our nice message printout wrapping system
Karl Hasselström [Mon, 8 Oct 2007 05:26:14 +0000 (07:26 +0200)]
Use our nice message printout wrapping system

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAllow caller to customize title of error/warning message
Karl Hasselström [Mon, 8 Oct 2007 05:25:06 +0000 (07:25 +0200)]
Allow caller to customize title of error/warning message

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake "stg refresh" subdirectory safe
Karl Hasselström [Sun, 7 Oct 2007 22:14:11 +0000 (00:14 +0200)]
Make "stg refresh" subdirectory safe

Make "stg refresh" subdirectory safe by letting it internally cd up to
the top of the worktree. This is possibly not the best long-term fix;
one could argue that the refresh subroutine should instead be safe to
run from a subdirectory. However, refreshing from a subdirectory
currently only refreshes changes that are in the index, and not
changes in the working directory, and that has to be fixed.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNew test: try "stg refresh" in a subdirectory
Karl Hasselström [Sun, 7 Oct 2007 22:14:11 +0000 (00:14 +0200)]
New test: try "stg refresh" in a subdirectory

Currently, it doesn't work. Or rather, it does work for changes that
are already in the index, which is the case for newly added files; but
it doesn't work for changes that aren't in the index.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake "stg push" subdirectory safe
Karl Hasselström [Sun, 7 Oct 2007 18:56:05 +0000 (20:56 +0200)]
Make "stg push" subdirectory safe

Make "stg push" subdirectory safe by letting it internally cd up to
the top of the worktree. This is possibly not the best long-term fix;
one could argue that the push subroutine should instead be safe to run
from a subdirectory. However, pushing from a subdirectory currently
erases the parts of a patch that doesn't touch that subdirectory, and
that has to be fixed.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNew test: Try "stg push" in a subdirectory
Karl Hasselström [Sun, 7 Oct 2007 17:36:59 +0000 (19:36 +0200)]
New test: Try "stg push" in a subdirectory

This currently fails for the non-fast-forward cases.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoInfrastructure for current directory handling
Karl Hasselström [Sun, 7 Oct 2007 12:52:26 +0000 (14:52 +0200)]
Infrastructure for current directory handling

Add infrastructure to allow commands to specify if they need a git
repository, if they need to be called from within the working tree,
and if they should cd to the root of the working tree before doing
anything else.

For now, all commands are set to just require a repository (except
"stg clone", which is set to require nothing), which means the only
thing that's added is some very light error checking. The idea is to
tighten this for commands that turn out to need it.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove the --force flag to "stg rebase" and "stg pull"
Karl Hasselström [Tue, 11 Sep 2007 00:09:23 +0000 (02:09 +0200)]
Remove the --force flag to "stg rebase" and "stg pull"

Instead, always behave as if the force flag was given; that is, don't
check if rebasing would leave a dangling commit behind. Reasons:

  * The check for this was very strict and caused a lot of false
    positives.

  * Everything is recorded in the reflog, so we can't actually lose
    commits.

This fixes bug 9181.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDiscard stderr output from git-rev-parse
Karl Hasselström [Sun, 7 Oct 2007 13:48:33 +0000 (15:48 +0200)]
Discard stderr output from git-rev-parse

This gets rid of the annoying "fatal: Needed a single revision"
messages that were printed in addition to StGit's own error message.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSimplify debug level error checking
Karl Hasselström [Sun, 7 Oct 2007 13:09:11 +0000 (15:09 +0200)]
Simplify debug level error checking

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake a common superclass for all StGit exceptions
Karl Hasselström [Sun, 7 Oct 2007 13:07:11 +0000 (15:07 +0200)]
Make a common superclass for all StGit exceptions

This makes it easier to catch them all. (Indeed, the very long list of
exceptions to catch in main.py was missing some of the exceptions.)

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDon't split long and short description in "stg edit"
Karl Hasselström [Sun, 7 Oct 2007 11:34:18 +0000 (13:34 +0200)]
Don't split long and short description in "stg edit"

"stg edit" used to present the patch information like this:

  Short description

  From: ...
  Date: ...

  Long description

If the project follows the git convention with a single-line short
description and follwed by a blank line and the rest of the
description, this merely looks a little odd. However, for projects
that don't follow that convention, presenting the first line
separately is actively inconvenient; for example, it breaks emacs's
fill-paragraph command.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoFix up the help text for "stg edit"
Karl Hasselström [Sat, 6 Oct 2007 08:35:44 +0000 (10:35 +0200)]
Fix up the help text for "stg edit"

The sentence structure was strange, and the example format was
somewhat misleading (StGit doesn't care about sign-off lines, for
example).

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNew test: "stg pop --keep"
Karl Hasselström [Sat, 6 Oct 2007 08:17:30 +0000 (10:17 +0200)]
New test: "stg pop --keep"

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd --ack/--sign options to "stg new"
Karl Hasselström [Sat, 6 Oct 2007 07:47:29 +0000 (09:47 +0200)]
Add --ack/--sign options to "stg new"

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoLet "stg assimilate" handle missing patches
Karl Hasselström [Mon, 1 Oct 2007 16:42:30 +0000 (18:42 +0200)]
Let "stg assimilate" handle missing patches

If a patch was not mentioned in the applied/unapplied files,
"assimilate" used to ignore it. Now it won't. The only information
loss ensuing from this sequence of commands

  $ rm .git/patches/<branch>/{un,}applied
  $ touch .git/patches/<branch>/{un,}applied
  $ stg assimilate

is now the order of the unapplied patches.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTest the new powers of "stg assimilate"
Karl Hasselström [Thu, 9 Aug 2007 20:46:10 +0000 (22:46 +0200)]
Test the new powers of "stg assimilate"

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoTeach "stg assimilate" to repair patch reachability
Karl Hasselström [Tue, 25 Sep 2007 18:21:46 +0000 (20:21 +0200)]
Teach "stg assimilate" to repair patch reachability

Rewrite "stg assimilate" so that it in addition to assimilating
commits made on top of the patch stack also will rewrite the
applied/unapplied files to reflect reality. A patch is considered to
be applied if it is reachable from HEAD without passing through a
merge, and unreachable otherwise.

Performance is adequate: On my laptop, it takes less than four seconds
to process the Linux tree (with hot caches).

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoBetter diagnostic for wrong branch configuration.
Yann Dirson [Fri, 5 Oct 2007 20:44:52 +0000 (22:44 +0200)]
Better diagnostic for wrong branch configuration.

If the branch.*.merge parameter does not name a valid remote head,
stgit would not rebase after a fetch, and would write instead
'Rebasing to "None" ... done'.

This patch makes this situation an error and tells the user what
to fix in his repo configuration.

16 years agoSupport tags in uncommit - use git_id instead of rev_parse
Pavel Roskin [Sun, 30 Sep 2007 17:26:47 +0000 (13:26 -0400)]
Support tags in uncommit - use git_id instead of rev_parse

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoFix the rebasing with an external command
Catalin Marinas [Fri, 28 Sep 2007 21:51:15 +0000 (22:51 +0100)]
Fix the rebasing with an external command

Since git.py caches the HEAD value, rebasing with and external command
didn't clear the cache and the subsequent push simple fast-forwards
the tree. The patch creates a new git.rebase() function which takes
care of custom rebase commands. It also removes "must_rebase" in
pull.py as it doesn't seem to be used.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAllow the rebase command to be defined
Catalin Marinas [Thu, 27 Sep 2007 22:23:26 +0000 (23:23 +0100)]
Allow the rebase command to be defined

This is useful if one wants to use StGIT on top of a Subversion
repository. After a "git svn clone" and "stg init", the following
options have to be defined to allow "stg pull" to work properly:

branch.master.remote = svn
stgit.pull-policy = fetch-rebase
stgit.fetchcmd = git svn fetch
stgit.rebasecmd = git svn rebase

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoMake Run available in stack.py
Karl Hasselström [Wed, 26 Sep 2007 02:03:15 +0000 (04:03 +0200)]
Make Run available in stack.py

Needed by shortlog(). Apparently, we have no test for this.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNew policy: Only use test_expect_failure for broken tests
Karl Hasselström [Sun, 23 Sep 2007 12:18:50 +0000 (14:18 +0200)]
New policy: Only use test_expect_failure for broken tests

New policy for tests:

  * For subtests whose commands fail when the test succeeds, use
    test_expect_success and shell negation (!). test_expect_failure is
    to be used only for subtests that are known to be broken.

  * Patches that introduce a subtest failure must change that subtest
    to use test_expect_failure.

The reason for this change is to ensure that the test suite passes at
all times, even in the middle of disruptive rewrites spread over
several commits.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMake sure that the output of "stg status" is sorted
Karl Hasselström [Sun, 23 Sep 2007 11:42:22 +0000 (13:42 +0200)]
Make sure that the output of "stg status" is sorted

This simplifies testing, but also makes it easier for the user to find
specific files.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRefactor Series.new_patch
David Kågedal [Fri, 14 Sep 2007 22:32:00 +0000 (00:32 +0200)]
Refactor Series.new_patch

This shuffles some code so that the top and bottom never need to be
set to anything other than a valid commit and its parent.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoClear up the semantics of Series.new_patch
David Kågedal [Fri, 14 Sep 2007 22:31:54 +0000 (00:31 +0200)]
Clear up the semantics of Series.new_patch

This patch adds a number of assertions to document and verify the
complex restrictions of the input parameters to the Series.new_patch
function. It also adds the requirement that 'before_existing' and
'commit' cannot be true at the same time when calling it, instead of
updating 'commit' inside the function.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd a 'bottom' parameter to Series.refresh_patch and use it
David Kågedal [Fri, 14 Sep 2007 22:31:49 +0000 (00:31 +0200)]
Add a 'bottom' parameter to Series.refresh_patch and use it

By specifying a bottom for the new patch commit, it is no longer
necessary to update the bottom of the patch before calling
refresh_patch.  This ensures that the patch top always correspond to a
commit object, and the bottom to its parent.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoClean up Series.refresh_patch
David Kågedal [Fri, 14 Sep 2007 22:31:44 +0000 (00:31 +0200)]
Clean up Series.refresh_patch

This patch does some minor simplifications of the code and updates the
documentation string of Series.refresh_patch.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRefactor Series.push_patch
David Kågedal [Fri, 14 Sep 2007 22:31:39 +0000 (00:31 +0200)]
Refactor Series.push_patch

Refactor the Series.push_patch function to make the code flow
simpler. It identifies the simple case and handles it early, and
reduces the number of if statements.

Most changes are simply indentation changes.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoRemove dead code from push_empty_patch
David Kågedal [Fri, 14 Sep 2007 22:31:34 +0000 (00:31 +0200)]
Remove dead code from push_empty_patch

Since the split from push_patch, the push_empty_patch contains some
code that fills no purpose. Remove it and simplify the code.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSplit Series.push_patch in two
David Kågedal [Fri, 14 Sep 2007 22:31:29 +0000 (00:31 +0200)]
Split Series.push_patch in two

The push_patch() function has a complex control flow and actually does
two different things depending on the 'empty' parameter. This patch
splits it in two functions without other code changes.

Later patches will refactor the code to simplify it.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoMoved that status function to the status command file
David Kågedal [Fri, 14 Sep 2007 22:31:24 +0000 (00:31 +0200)]
Moved that status function to the status command file

The git.status() was more of a command than a library function, and
was only used in one place.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoClear up semantics of tree_status
David Kågedal [Fri, 14 Sep 2007 22:31:19 +0000 (00:31 +0200)]
Clear up semantics of tree_status

The tree_status() function does a few slightly different things
depending on the arguments.  This patch adds checks that the arguments
are consistent and that the returned value looks good.

It also changes the semantics slightly.  If the 'files' parameter is
None, it will run status on all files.  If 'files' is a list, it will
run status on only those files.  This changes two things:

 1) If 'files' is the empty list, it will run status on no files.
 2) It 'files' is a list, it will never return the status for other files

Clearing this up will make it easier to understand code that is using
this function.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd some more tests of "stg status" output
David Kågedal [Fri, 14 Sep 2007 22:31:14 +0000 (00:31 +0200)]
Add some more tests of "stg status" output

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoNew test: make sure tha we can run "stg help"
Karl Hasselström [Sun, 23 Sep 2007 22:54:06 +0000 (00:54 +0200)]
New test: make sure tha we can run "stg help"

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoPrint 'updating patch' earlier in 'edit'
Catalin Marinas [Sat, 22 Sep 2007 22:38:30 +0000 (23:38 +0100)]
Print 'updating patch' earlier in 'edit'

Otherwise, the user waits without knowing what's going on.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAdd simple test for "stg branch --delete"
Karl Hasselström [Sat, 22 Sep 2007 08:23:37 +0000 (10:23 +0200)]
Add simple test for "stg branch --delete"

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoProperly remove all config for a deleted branch
Karl Hasselström [Sat, 22 Sep 2007 08:22:18 +0000 (10:22 +0200)]
Properly remove all config for a deleted branch

This uses "git-config --remove-section", which was first released in
git 1.5.1-rc1. I'm not sure if this is later than what we used to
depend on; we already use "git-config --rename-section", but that's
been in since git 1.5.0-rc0.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDon't try to delete the branch twice
Karl Hasselström [Sat, 22 Sep 2007 07:58:24 +0000 (09:58 +0200)]
Don't try to delete the branch twice

We already delete it in Stack.delete(), so don't do it here too.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDon't special-case the "master" branch during branch delete
Karl Hasselström [Sat, 22 Sep 2007 07:54:25 +0000 (09:54 +0200)]
Don't special-case the "master" branch during branch delete

It's unintuitive, unsymmetric and doesn't work if there is no
"master". Instead, prohibit deletion of the current branch.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoIt doesn't make sense to sink below an unapplied patch
Karl Hasselström [Thu, 13 Sep 2007 22:49:43 +0000 (00:49 +0200)]
It doesn't make sense to sink below an unapplied patch

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd 'edit' to the patchcommands list
Catalin Marinas [Fri, 14 Sep 2007 17:58:16 +0000 (18:58 +0100)]
Add 'edit' to the patchcommands list

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoAdd patch editing command
Catalin Marinas [Fri, 14 Sep 2007 17:51:57 +0000 (18:51 +0100)]
Add patch editing command

This patch adds the 'edit' command which takes most of the similar
functionality out of 'refresh'. In addition, it allows the direct
patch diff editing with the '--diff' option. The patch/e-mail parsing
functions were moved from stgit.commands.imprt to
stgit.commands.common as they are now used by both 'import' and
'edit'.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
16 years agoInclude summary of added/deleted files in diffstat
Karl Hasselström [Tue, 11 Sep 2007 03:57:14 +0000 (05:57 +0200)]
Include summary of added/deleted files in diffstat

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd shortlog of patch series to cover mail
Karl Hasselström [Tue, 11 Sep 2007 03:57:14 +0000 (05:57 +0200)]
Add shortlog of patch series to cover mail

Unlike the cover mail diffstat, this covers exactly the selected
patches and nothing else.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd diffstat of whole patch series to cover mail
Karl Hasselström [Tue, 11 Sep 2007 03:57:14 +0000 (05:57 +0200)]
Add diffstat of whole patch series to cover mail

Note: The diffstat is computed from the bottom of the first patch to
the top of the last, which gives a correct result if and only if the
series is contiguous. This is often the case, and handling anything
but this case is nontrivial, as it would involve creating a temporary
series of commits that are contiguous, with all the performance and
merge problems that would entail.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoSet GIT_TEMPLATE_DIR in the testsuite, like it's done in git
Pavel Roskin [Mon, 10 Sep 2007 02:48:15 +0000 (22:48 -0400)]
Set GIT_TEMPLATE_DIR in the testsuite, like it's done in git

Otherwise, the git configuration affects the testsuite.  Since we don't
have git templates in the source tree, use our "template" directory.
No templates are really needed, it's just a directory with known
contents.

Remove the command that moves .git/hooks away, as it's not created
anymore.  Create empty .git/info/, as some tests assume it to exist.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd --sign and --ack options to "stg import"
Karl Hasselström [Tue, 11 Sep 2007 03:57:14 +0000 (05:57 +0200)]
Add --sign and --ack options to "stg import"

Do this by factoring out the handling of these options from "stg
refresh".

Also, don't add sign lines that are already present.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoAdd the any() and all() utility functions from Python 2.5
Karl Hasselström [Tue, 11 Sep 2007 01:34:08 +0000 (03:34 +0200)]
Add the any() and all() utility functions from Python 2.5

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoDiscard stderr when determining if a patch is already applied
Karl Hasselström [Thu, 6 Sep 2007 23:31:22 +0000 (01:31 +0200)]
Discard stderr when determining if a patch is already applied

An error from git-apply just means that the patch isn't applied.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agogit.__remotes_from_dir() should only return lists
Pavel Roskin [Wed, 5 Sep 2007 16:57:22 +0000 (12:57 -0400)]
git.__remotes_from_dir() should only return lists

If there are no remotes, return empty list, not None.  The later doesn't
work with builtin set().

This fixes t1001-branch-rename.sh

Signed-off-by: Pavel Roskin <proski@gnu.org>
16 years agoUse the builtin set() instead of sets.Set()
Karl Hasselström [Mon, 3 Sep 2007 21:48:51 +0000 (23:48 +0200)]
Use the builtin set() instead of sets.Set()

We can do that now that we're guaranteed to have Python 2.4 or later.

Signed-off-by: Karl Hasselström <kha@treskal.com>
16 years agoUse subprocess.Popen to call git executables
Karl Hasselström [Mon, 3 Sep 2007 21:48:45 +0000 (23:48 +0200)]
Use subprocess.Popen to call git executables

Replace popen2.Popen3 and os.spawn* with the superior
subprocess.Popen. Now we can pass a modified environment to any
subprocess, redirect input and output as we please, and the shell is
no longer involved, meaning we don't have to worry about argument
quoting. (We could already do all of that, just not at the same time.)

This is a Python 2.4 library, so StGit now officially requires Python
2.4 or later.

Signed-off-by: Karl Hasselström <kha@treskal.com>