chiark / gitweb /
Remove the --force flag to "stg rebase" and "stg pull"
authorKarl Hasselström <kha@treskal.com>
Tue, 11 Sep 2007 00:09:23 +0000 (02:09 +0200)
committerKarl Hasselström <kha@treskal.com>
Sun, 7 Oct 2007 22:14:11 +0000 (00:14 +0200)
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>
stgit/commands/common.py
stgit/commands/pull.py
stgit/commands/rebase.py
stgit/stack.py
t/t2100-pull-policy-fetch.sh
t/t2102-pull-policy-rebase.sh

index 27a616ffe1b27a95753d58c24e70ce0e6a0013f9..98154009f71de58a5a3c4d8fc29191725c237fc9 100644 (file)
@@ -318,14 +318,7 @@ def address_or_alias(addr_str):
                  for addr in addr_str.split(',')]
     return ', '.join([addr for addr in addr_list if addr])
 
-def prepare_rebase(force=None):
-    if not force:
-        # Be sure we won't loose results of stg-(un)commit by error.
-        # Do not require an existing orig-base for compatibility with 0.12 and earlier.
-        origbase = crt_series._get_field('orig-base')
-        if origbase and crt_series.get_base() != origbase:
-            raise CmdException, 'Rebasing would possibly lose data'
-
+def prepare_rebase():
     # pop all patches
     applied = crt_series.get_applied()
     if len(applied) > 0:
index 070db991a389e305f4b5a4583dd84b56f17ce51b..237bdd9e57f798046d43ba1ddfe22644851a601d 100644 (file)
@@ -43,9 +43,6 @@ options = [make_option('-n', '--nopush',
                        action = 'store_true'),
            make_option('-m', '--merged',
                        help = 'check for patches merged upstream',
-                       action = 'store_true'),
-           make_option('--force',
-                       help = 'force rebase even if the stack based was moved by (un)commits',
                        action = 'store_true')]
 
 def func(parser, options, args):
@@ -81,7 +78,7 @@ def func(parser, options, args):
     if policy not in ['pull', 'fetch-rebase', 'rebase']:
         raise GitConfigException, 'Unsupported pull-policy "%s"' % policy
 
-    applied = prepare_rebase(force=options.force)
+    applied = prepare_rebase()
 
     # pull the remote changes
     if policy == 'pull':
index c68f8e79b18e0927b48aabdcbd29fcb9b18ea566..513729a50bffaba52cd7a42bb9d7cc7ab414ae9a 100644 (file)
@@ -34,9 +34,6 @@ options = [make_option('-n', '--nopush',
                        action = 'store_true'),
            make_option('-m', '--merged',
                        help = 'check for patches merged upstream',
-                       action = 'store_true'),
-           make_option('--force',
-                       help = 'force rebase even if the stack based was moved by (un)commits',
                        action = 'store_true')]
 
 def func(parser, options, args):
@@ -56,7 +53,7 @@ def func(parser, options, args):
     if git_id(args[0]) == None:
         raise GitException, 'Unknown revision: %s' % args[0]
         
-    applied = prepare_rebase(force=options.force)
+    applied = prepare_rebase()
     rebase(args[0])
     post_rebase(applied, options.nopush, options.merged)
 
index bdb4e38a5834a9c93c251733c7c1d19ebcbf493a..94856b8a5210d639d2973bbc8e7420b0a4f1e96e 100644 (file)
@@ -623,7 +623,6 @@ class Series(PatchSet):
 
         self.create_empty_field('applied')
         self.create_empty_field('unapplied')
-        self._set_field('orig-base', git.get_head())
 
         config.set(self.format_version_key(), str(FORMAT_VERSION))
 
index 1f50069e583292cae3e4f877f344deda569f3656..28901b1d819b35be0647c33da162d8fd01b00826 100755 (executable)
@@ -55,18 +55,4 @@ test_expect_success \
     test `wc -l <clone/file2` = 3
     '
 
-# this one exercises the guard against commits
-# (use a new file to avoid mistaking a conflict for a success)
-test_expect_success \
-    'New upstream commit and commit a patch in clone' \
-    '
-    (cd upstream && stg new u2 -m u2 &&
-     echo a > file3 && stg add file3 && stg refresh) &&
-    (cd clone && stg commit && stg new c2 -m c2 &&
-     echo a >> file && stg refresh)
-    '
-test_expect_success \
-    'Try to  and commit a patch in clone' \
-    '(cd clone && ! stg pull)'
-
 test_done
index b2fbfcf63657ef9ca62c88767f3132c7c3d58023..ce2e32f91b1a18cf6b533b12ac9094966144b0c3 100755 (executable)
@@ -36,28 +36,4 @@ test_expect_success \
     test `wc -l <file2` = 2
     '
 
-# this one exercises the guard against commits
-# (use a new file to avoid mistaking a conflict for a success)
-test_expect_success \
-    'New commit in parent and commit a patch in stack' \
-    '
-    stg branch parent && stg new u2 -m u2 &&
-     echo c > file3 && stg add file3 && stg refresh &&
-    stg branch stack && stg commit && stg new c2 -m c2 &&
-     echo a >> file && stg refresh
-    '
-test_expect_success \
-    'Try to pull/rebase now that stack base has moved' \
-    '! stg pull'
-
-test_expect_success \
-    'Force the pull/rebase, but do not push yet' \
-    'stg pull --force --nopush'
-test_expect_success \
-    '...check we lost the committed patch' \
-    '! test -e file'
-test_expect_success \
-    '...and check we get a conflict while pushing' \
-    '! stg push'
-
 test_done