[PATCH 2/2] Regression test for "stg assimilate"

Previous thread: [PATCH 3/3] Disregard extraneous arguments when providing help by Karl on Sunday, October 22, 2006 - 6:05 am. (4 messages)

Next thread: Re: VCS comparison table by Matthew D. Fuller on Sunday, October 22, 2006 - 6:33 am. (2 messages)
From: Karl
Date: Sunday, October 22, 2006 - 6:05 am

A new StGIT command that assimilates any GIT commits made on top of
your StGIT patches, and a test to go with it.

--=20
Karl Hasselstr=C3=B6m, kha@treskal.com
      www.treskal.com/kalle
-

From: Karl
Date: Sunday, October 22, 2006 - 6:08 am

From: Karl Hasselstr=C3=B6m <kha@treskal.com>

Introduce an "assimilate" command, with no options. It takes any GIT
commits committed on top of your StGIT patch stack and converts them
into StGIT patches.

Also change the error message when an StGIT command can't do its job
because there are GIT commits on top of the stack. Instead of
recommending "refresh -f", which is a destructive operation, recommend
"assimilate", which is not.

NOTE: "assimilate" currently refuses to work its magic if it
encounters a merge commit. This is reasonable, since merge commits
can't (yet) be represented as StGIT patches. However, it would be
possible (and well-defined) to replace the merge commit with a regular
commit on the branch with the same end result (tree object),
discarding all the parents that aren't on our branch. But this would
take a substantial amount of code, and is of dubious value, so for now
"assimilate" just cries bloody murder if it finds a merge.

Signed-off-by: Karl Hasselstr=C3=B6m <kha@treskal.com>
---

 stgit/commands/assimilate.py |   96 ++++++++++++++++++++++++++++++++++++++=
++++
 stgit/commands/common.py     |    8 ++--
 stgit/git.py                 |    3 +
 stgit/main.py                |    3 +
 stgit/stack.py               |   28 +++++++++---
 5 files changed, 126 insertions(+), 12 deletions(-)

diff --git a/stgit/commands/assimilate.py b/stgit/commands/assimilate.py
new file mode 100644
index 0000000..2c0ec56
--- /dev/null
+++ b/stgit/commands/assimilate.py
@@ -0,0 +1,96 @@
+# -*- coding: utf-8 -*-
+
+__copyright__ =3D """
+Copyright (C) 2006, Karl Hasselstr=C3=B6m <kha@treskal.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See ...
From: Petr Baudis
Date: Sunday, October 22, 2006 - 10:43 am

Dear diary, on Sun, Oct 22, 2006 at 03:08:02PM CEST, I got a letter
where Karl Hasselstr
From: Karl
Date: Sunday, October 22, 2006 - 11:12 am

> where Karl Hasselstr
From: Catalin Marinas
Date: Monday, October 23, 2006 - 4:52 am

On 22/10/06, Karl Hasselstr
From: Karl
Date: Wednesday, October 25, 2006 - 9:32 am

On 2006-10-22 15:08:02 +0200, Karl Hasselstr
From: Catalin Marinas
Date: Wednesday, October 25, 2006 - 9:41 am

On 25/10/06, Karl Hasselstr
From: Karl
Date: Thursday, October 26, 2006 - 1:32 am

On 2006-10-25 17:41:50 +0100, Catalin Marinas wrote:

> On 25/10/06, Karl Hasselstr
From: Karl
Date: Sunday, October 22, 2006 - 6:08 am

From: Karl Hasselstr=C3=B6m <kha@treskal.com>



Signed-off-by: Karl Hasselstr=C3=B6m <kha@treskal.com>
---

 t/t1301-assimilate.sh |   86 +++++++++++++++++++++++++++++++++++++++++++++=
++++
 1 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/t/t1301-assimilate.sh b/t/t1301-assimilate.sh
new file mode 100755
index 0000000..26b263c
--- /dev/null
+++ b/t/t1301-assimilate.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+# Copyright (c) 2006 Karl Hasselstr=C3=B6m
+test_description=3D'Test the assimilate command.'
+=2E ./test-lib.sh
+
+test_expect_success \
+    'Assimilate in a non-initialized repository' \
+    'stg assimilate'
+
+test_expect_success \
+    'Initialize the StGIT repository' \
+    'stg init'
+
+test_expect_success \
+    'Assimilate in a repository without patches' \
+    'stg assimilate'
+
+test_expect_success \
+    'Create a patch' \
+    '
+    stg new foo -m foo &&
+    echo foo > foo.txt &&
+    stg add foo.txt &&
+    stg refresh
+    '
+
+test_expect_success \
+    'Assimilate when there is nothing to do' \
+    'stg assimilate'
+
+test_expect_success \
+    'Create a GIT commit' \
+    '
+    echo bar > bar.txt &&
+    git add bar.txt &&
+    git commit -a -m bar
+    '
+
+test_expect_success \
+    'Assimilate one GIT commit' \
+    '
+    [ $(stg applied | wc -l) -eq 1 ] &&
+    stg assimilate &&
+    [ $(stg applied | wc -l) -eq 2 ]
+    '
+
+test_expect_success \
+    'Create three more GIT commits' \
+    '
+    echo one > numbers.txt &&
+    git add numbers.txt &&
+    git commit -a -m one &&
+    echo two >> numbers.txt &&
+    git commit -a -m two &&
+    echo three >> numbers.txt &&
+    git commit -a -m three
+    '
+
+test_expect_success \
+    'Assimilate three GIT commits' \
+    '
+    [ $(stg applied | wc -l) -eq 2 ] &&
+    stg assimilate &&
+    [ $(stg applied | wc -l) -eq 5 ]
+    '
+
+test_expect_success \
+    'Create a mege commit' \
+    '
+    git checkout -b br master^^ &&
+    ...
Previous thread: [PATCH 3/3] Disregard extraneous arguments when providing help by Karl on Sunday, October 22, 2006 - 6:05 am. (4 messages)

Next thread: Re: VCS comparison table by Matthew D. Fuller on Sunday, October 22, 2006 - 6:33 am. (2 messages)