{"thread":{"id":"19599","subject":"[StGit PATCH] Add \"stg id\" support for \"{public}\" ref","startedAt":"2009-05-29T21:30:04Z","lastAt":"2009-05-31T08:20:31Z","messageCount":2,"participants":["Catalin Marinas","Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"115052","messageId":"20090529213003.8908.87850.stgit@localhost.localdomain","threadId":"19599","inReplyTo":null,"subject":"[StGit PATCH] Add \"stg id\" support for \"{public}\" ref","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-05-29T21:30:04Z","receivedAt":"2009-05-29T21:30:04Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"From: Catalin Marinas <catalin.marinas@arm.com>\n\nThe {public} ref refers to the public version of the branch as described\nin the \"publish\" command.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@arm.com>\n---\n stgit/commands/common.py  |   16 +++++++++++++++-\n stgit/commands/diff.py    |    6 +-----\n stgit/commands/id.py      |   13 +++++++------\n stgit/commands/publish.py |    4 +---\n 4 files changed, 24 insertions(+), 15 deletions(-)\n\ndiff --git a/stgit/commands/common.py b/stgit/commands/common.py\nindex 4f53f91..dfd7e26 100644\n--- a/stgit/commands/common.py\n+++ b/stgit/commands/common.py\n@@ -53,11 +53,20 @@ def git_id(crt_series, rev):\n     repository = libstack.Repository.default()\n     return git_commit(rev, repository, crt_series.get_name()).sha1\n \n+def get_public_ref(branch_name):\n+    \"\"\"Return the public ref of the branch.\"\"\"\n+    public_ref = config.get('branch.%s.public' % branch_name)\n+    if not public_ref:\n+        public_ref = 'refs/heads/%s.public' % branch_name\n+    return public_ref\n+\n def git_commit(name, repository, branch_name = None):\n     \"\"\"Return the a Commit object if 'name' is a patch name or Git commit.\n     The patch names allowed are in the form '<branch>:<patch>' and can\n     be followed by standard symbols used by git rev-parse. If <patch>\n-    is '{base}', it represents the bottom of the stack.\n+    is '{base}', it represents the bottom of the stack. If <patch> is\n+    {public}, it represents the public branch corresponding to the stack as\n+    described in the 'publish' command.\n     \"\"\"\n     # Try a [branch:]patch name first\n     branch, patch = parse_rev(name)\n@@ -69,6 +78,11 @@ def git_commit(name, repository, branch_name = None):\n         base_id = repository.get_stack(branch).base.sha1\n         return repository.rev_parse(base_id +\n                                     strip_prefix('{base}', patch))\n+    elif patch.startswith('{public}'):\n+        public_ref = get_public_ref(branch)\n+        return repository.rev_parse(public_ref +\n+                                    strip_prefix('{public}', patch),\n+                                    discard_stderr = True)\n \n     # Other combination of branch and patch\n     try:\ndiff --git a/stgit/commands/diff.py b/stgit/commands/diff.py\nindex 7d2f719..568651c 100644\n--- a/stgit/commands/diff.py\n+++ b/stgit/commands/diff.py\n@@ -32,11 +32,7 @@ description = \"\"\"\n Show the diff (default) or diffstat between the current working copy\n or a tree-ish object and another tree-ish object (defaulting to HEAD).\n File names can also be given to restrict the diff output. The\n-tree-ish object can be an StGIT patch, a standard git commit, tag or\n-tree. In addition to these, the command also supports '{base}',\n-representing the bottom of the current stack.\n-\n-rev = '[branch:](<patch>|{base}) | <tree-ish>'\"\"\"\n+tree-ish object has the format accepted by the linkstg:id[] command.\"\"\"\n \n args = [argparse.known_files, argparse.dirty_files]\n options = [\ndiff --git a/stgit/commands/id.py b/stgit/commands/id.py\nindex 566edcc..654ff72 100644\n--- a/stgit/commands/id.py\n+++ b/stgit/commands/id.py\n@@ -24,12 +24,13 @@ help = 'Print the git hash value of a StGit reference'\n kind = 'repo'\n usage = ['[options] [id]']\n description = \"\"\"\n-Print the SHA1 value of a Git id (defaulting to HEAD). In addition to\n-the standard Git id's like heads and tags, this command also accepts\n-'[<branch>:]<patch>' and '[<branch>:]{base}' showing the id of a patch\n-or the base of the stack. If no branch is specified, it defaults to the\n-current one. The bottom of a patch is accessible with the\n-'[<branch>:]<patch>^' format.\"\"\"\n+Print the SHA1 value of a Git id (defaulting to HEAD). In addition to the\n+standard Git id's like heads and tags, this command also accepts\n+'[<branch>:]<patch>' for the id of a patch, '[<branch>:]\\{base\\}' for the base\n+of the stack and '[<branch>:]\\{public\\}' for the public branch corresponding\n+to the stack (see the 'publish' command for details). If no branch is\n+specified, it defaults to the current one. The bottom of a patch is accessible\n+with the '[<branch>:]<patch>^' format.\"\"\"\n \n args = [argparse.applied_patches, argparse.unapplied_patches,\n         argparse.hidden_patches]\ndiff --git a/stgit/commands/publish.py b/stgit/commands/publish.py\nindex e4b1a8d..401fbdf 100644\n--- a/stgit/commands/publish.py\n+++ b/stgit/commands/publish.py\n@@ -82,9 +82,7 @@ def func(parser, options, args):\n     stack = repository.get_stack(options.branch)\n \n     if not args:\n-        public_ref = config.get('branch.%s.public' % stack.name)\n-        if not public_ref:\n-            public_ref = 'refs/heads/%s.public' % stack.name\n+        public_ref = common.get_public_ref(stack.name)\n     elif len(args) == 1:\n         public_ref = args[0]\n     else:\n"},{"id":"115119","messageId":"20090531082031.GA17719@diana.vm.bytemark.co.uk","threadId":"19599","inReplyTo":"20090529213003.8908.87850.stgit@localhost.localdomain","subject":"Re: [StGit PATCH] Add \"stg id\" support for \"{public}\" ref","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-05-31T08:20:31Z","receivedAt":"2009-05-31T08:20:31Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-05-29 22:30:04 +0100, Catalin Marinas wrote:\n\n> The {public} ref refers to the public version of the branch as\n> described in the \"publish\" command.\n\nLooks reasonable.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}