{"thread":{"id":"6673","subject":"[PATCH] Use branch.*.stgit.parentbranch for authoritative parent information.","startedAt":"2007-02-04T09:48:21Z","lastAt":"2007-02-04T09:48:21Z","messageCount":1,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"33556","messageId":"20070204094723.18334.72391.stgit@gandelf.nowhere.earth","threadId":"6673","inReplyTo":null,"subject":"[PATCH] Use branch.*.stgit.parentbranch for authoritative parent information.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-02-04T09:48:21Z","receivedAt":"2007-02-04T09:48:21Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nAlso set the API to use remote=None as \"parent branch is local\", and\nhave set_parent() translate that to branch.*.remote=\".\".\n\nAlso enforces that we never set a parent-branch info without a\nparent-remote (so they are now both set or both untouched), and try to\ngive useful info when we have to use the old \"origin\" defaults.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\nThis is an updated version of yesterday's patch rebased to current\nHEAD, and with normalized string quoting.\n\n stgit/commands/branch.py |    3 ++-\n stgit/git.py             |    5 +----\n stgit/stack.py           |   30 ++++++++++++++++++++----------\n 3 files changed, 23 insertions(+), 15 deletions(-)\n\ndiff --git a/stgit/commands/branch.py b/stgit/commands/branch.py\nindex f074d47..3026d9c 100644\n--- a/stgit/commands/branch.py\n+++ b/stgit/commands/branch.py\n@@ -151,8 +151,9 @@ def func(parser, options, args):\n             if parentremote:\n                 print 'Using \"%s\" remote to pull parent from.' % parentremote\n             else:\n-                print 'Not identified a remote to pull parent from.'\n+                print 'Recording as a local branch.'\n         else:\n+            # no known parent branch, can't guess the remote\n             parentremote = None\n \n         stack.Series(args[0]).init(create_at = tree_id,\ndiff --git a/stgit/git.py b/stgit/git.py\nindex 3d84e97..73d07fd 100644\n--- a/stgit/git.py\n+++ b/stgit/git.py\n@@ -950,8 +950,5 @@ def identify_remote(branchname):\n         if branchname in remotes_local_branches(remote):\n             return remote\n \n-    # FIXME: in the case of local branch we should maybe set remote to\n-    # \".\" but are we even sure it is the only case left ?\n-\n-    # if we get here we've found nothing\n+    # if we get here we've found nothing, the branch is a local one\n     return None\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex 3960729..e091d4e 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -418,8 +418,10 @@ class Series(StgitObject):\n         if value:\n             return value\n         elif 'origin' in git.remotes_list():\n-            # FIXME: this is for compatibility only.  Should be\n-            # dropped when all relevant commands record this info.\n+            print 'Notice: no parent remote declared for stack \"%s\", ' \\\n+                  'defaulting to \"origin\". Consider setting \"branch.%s.remote\" ' \\\n+                  'and \"branch.%s.merge\" with \"git repo-config\".' \\\n+                  % (self.__name, self.__name, self.__name)\n             return 'origin'\n         else:\n             raise StackException, 'Cannot find a parent remote for \"%s\"' % self.__name\n@@ -428,26 +430,34 @@ class Series(StgitObject):\n         value = config.set('branch.%s.remote' % self.__name, remote)\n \n     def get_parent_branch(self):\n-        value = config.get('branch.%s.merge' % self.__name)\n+        value = config.get('branch.%s.stgit.parentbranch' % self.__name)\n         if value:\n             return value\n         elif git.rev_parse('heads/origin'):\n-            # FIXME: this is for compatibility only.  Should be\n-            # dropped when all relevant commands record this info.\n+            print 'Notice: no parent branch declared for stack \"%s\", ' \\\n+                  'defaulting to \"heads/origin\".  Consider setting ' \\\n+                  '\"branch.%s.stgit.parentbranch\" with \"git repo-config\".' \\\n+                  % (self.__name, self.__name)\n             return 'heads/origin'\n         else:\n             raise StackException, 'Cannot find a parent branch for \"%s\"' % self.__name\n \n     def __set_parent_branch(self, name):\n-        config.set('branch.%s.merge' % self.__name, name)\n+        if config.get('branch.%s.remote' % self.__name):\n+            # Never set merge if remote is not set to avoid\n+            # possibly-erroneous lookups into 'origin'\n+            config.set('branch.%s.merge' % self.__name, name)\n+        config.set('branch.%s.stgit.parentbranch' % self.__name, name)\n \n     def set_parent(self, remote, localbranch):\n+        # policy: record local branches as remote='.'\n+        recordremote = remote or '.'\n         if localbranch:\n+            self.__set_parent_remote(recordremote)\n             self.__set_parent_branch(localbranch)\n-            if remote:\n-                self.__set_parent_remote(remote)\n-        elif remote:\n-            raise StackException, 'Remote \"%s\" without a branch cannot be used as parent' % remote\n+        # We'll enforce this later\n+#         else:\n+#             raise StackException, 'Parent branch (%s) should be specified for %s' % localbranch, self.__name\n \n     def __patch_is_current(self, patch):\n         return patch.get_name() == self.get_current()\n"}]}