chiark / gitweb /
Stop recording branch.*.remote to '.' for local parents.
authorYann Dirson <ydirson@altern.org>
Tue, 15 May 2007 17:09:57 +0000 (18:09 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 15 May 2007 21:13:14 +0000 (22:13 +0100)
We should be using the remote name of the remote branch in
branch.*.merge, instead of the local one as we currently do (I'll
ensure this in a later patch).

As a consequence, setting "remote" to '.' and "merge" to the name of a
*local* parent would become inconsistent with the remote case.  Anyway
the local case should make use of pull-policy=rebase instead, and this
change revealed that we were fetching useless information in the local
case (no need for a remote).

Signed-off-by: Yann Dirson <ydirson@altern.org>
stgit/commands/pull.py
stgit/stack.py

index 7b3c90ca93e8b987e27a2fe96ab5b81ad9de3bfb..f551b981d1f3d07a442f36322f384a4251cc1978 100644 (file)
@@ -50,13 +50,25 @@ options = [make_option('-n', '--nopush',
 def func(parser, options, args):
     """Pull the changes from a remote repository
     """
-    if len(args) > 1:
-        parser.error('incorrect number of arguments')
+    policy = config.get('branch.%s.stgit.pull-policy' % crt_series.get_branch()) or \
+             config.get('stgit.pull-policy')
+
+    if policy == 'rebase':
+        # parent is local
+        if len(args) == 1:
+            parser.error('specifying a repository is meaningless for policy="%s"' % policy)
+        if len(args) > 0:
+            parser.error('incorrect number of arguments')
 
-    if len(args) >= 1:
-        repository = args[0]
     else:
-        repository = crt_series.get_parent_remote()
+        # parent is remote
+        if len(args) > 1:
+            parser.error('incorrect number of arguments')
+
+        if len(args) >= 1:
+            repository = args[0]
+        else:
+            repository = crt_series.get_parent_remote()
 
     if crt_series.get_protected():
         raise CmdException, 'This branch is protected. Pulls are not permitted'
@@ -65,8 +77,6 @@ def func(parser, options, args):
     check_conflicts()
     check_head_top_equal()
 
-    policy = config.get('branch.%s.stgit.pull-policy' % crt_series.get_branch()) or \
-             config.get('stgit.pull-policy')
     if policy == 'pull':
         must_rebase = 0
     elif policy == 'fetch-rebase':
index 9868699f1a70624d9a0c716bdff76b18fb88bc0f..65a7d83e741a87cb5c584282bb540769ba547d4c 100644 (file)
@@ -450,10 +450,8 @@ class Series(StgitObject):
         config.set('branch.%s.stgit.parentbranch' % self.__name, name)
 
     def set_parent(self, remote, localbranch):
-        # policy: record local branches as remote='.'
-        recordremote = remote or '.'
         if localbranch:
-            self.__set_parent_remote(recordremote)
+            self.__set_parent_remote(remote)
             self.__set_parent_branch(localbranch)
         # We'll enforce this later
 #         else: