{"thread":{"id":"7983","subject":"[StGIT PATCH 0/2] Improving patchlogs","startedAt":"2007-05-05T14:00:18Z","lastAt":"2007-05-05T14:00:28Z","messageCount":3,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"41133","messageId":"20070505135830.5194.90861.stgit@gandelf.nowhere.earth","threadId":"7983","inReplyTo":null,"subject":"[StGIT PATCH 0/2] Improving patchlogs","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-05T14:00:18Z","receivedAt":"2007-05-05T14:00:18Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"This is a first pass on recording missing history in the patchlogs, as\ndescribed in a former email.  At least \"sync\" still has unrecorded\n(merge) information.\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"41134","messageId":"20070505140023.5194.8083.stgit@gandelf.nowhere.earth","threadId":"7983","inReplyTo":"20070505135830.5194.90861.stgit@gandelf.nowhere.earth","subject":"[PATCH 1/2] Cleanup variable names in pick.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-05T14:00:23Z","receivedAt":"2007-05-05T14:00:23Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nI'm going to need patch objects there, so avoid using variable \"patch\"\nto store only a patchname.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/commands/pick.py |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/stgit/commands/pick.py b/stgit/commands/pick.py\nindex edd614d..4eb79a3 100644\n--- a/stgit/commands/pick.py\n+++ b/stgit/commands/pick.py\n@@ -71,11 +71,11 @@ def func(parser, options, args):\n     else:\n         patch_branch = commit_str.split('@')\n         if options.name:\n-            patch = options.name\n+            patchname = options.name\n         elif len(patch_branch) == 2:\n-            patch = patch_branch[0]\n+            patchname = patch_branch[0]\n         else:\n-            patch = make_patch_name(commit.get_log(), crt_series.patch_exists)\n+            patchname = make_patch_name(commit.get_log(), crt_series.patch_exists)\n \n     if options.parent:\n         parent = git_id(options.parent)\n@@ -118,17 +118,17 @@ def func(parser, options, args):\n         print 'Importing commit %s...' % commit_id,\n         sys.stdout.flush()\n \n-        crt_series.new_patch(patch, message = message, can_edit = False,\n+        crt_series.new_patch(patchname, message = message, can_edit = False,\n                              unapplied = True, bottom = bottom, top = top,\n                              author_name = author_name,\n                              author_email = author_email,\n                              author_date = author_date)\n         if not options.unapplied:\n-            modified = crt_series.push_patch(patch)\n+            modified = crt_series.push_patch(patchname)\n         else:\n             modified = False\n \n-        if crt_series.empty_patch(patch):\n+        if crt_series.empty_patch(patchname):\n             print 'done (empty patch)'\n         elif modified:\n             print 'done (modified)'\n"},{"id":"41135","messageId":"20070505140028.5194.46650.stgit@gandelf.nowhere.earth","threadId":"7983","inReplyTo":"20070505135830.5194.90861.stgit@gandelf.nowhere.earth","subject":"[PATCH 2/2] Copy patchlogs when cloning a stack or picking a patch.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-05T14:00:28Z","receivedAt":"2007-05-05T14:00:28Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nThis will allow to keep patch history accross those operations, and\nsee when they diverged when looking at the respective patchlogs.  With\nmore work, that will allow to locate the common ancestor when sync'ing\na patch across branches.\n\nThe work on \"pick\" can still be improved: currently the patchlog is\npreserved on \"pick patch[@branch][//top]\", but we could make it work\nfor //top.old as well (or any rev in the patchlog when we'll be able\nto name those).\n\nPatchlog preservation in pick can only work when referencing a patch\nby name.  When picking an arbitrary commit we could also improve\nthings by recording a \"pick\" operation instead of a \"new\".\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/commands/pick.py |   31 ++++++++++++++++++++++++++-----\n stgit/stack.py         |   22 +++++++++++++++-------\n 2 files changed, 41 insertions(+), 12 deletions(-)\n\ndiff --git a/stgit/commands/pick.py b/stgit/commands/pick.py\nindex 4eb79a3..4ef9860 100644\n--- a/stgit/commands/pick.py\n+++ b/stgit/commands/pick.py\n@@ -21,6 +21,7 @@ from optparse import OptionParser, make_option\n from stgit.commands.common import *\n from stgit.utils import *\n from stgit import stack, git\n+from stgit.stack import Series\n \n \n help = 'import a patch from a different branch or a commit object'\n@@ -118,11 +119,31 @@ def func(parser, options, args):\n         print 'Importing commit %s...' % commit_id,\n         sys.stdout.flush()\n \n-        crt_series.new_patch(patchname, message = message, can_edit = False,\n-                             unapplied = True, bottom = bottom, top = top,\n-                             author_name = author_name,\n-                             author_email = author_email,\n-                             author_date = author_date)\n+        newpatch = crt_series.new_patch(patchname, message = message, can_edit = False,\n+                                        unapplied = True, bottom = bottom, top = top,\n+                                        author_name = author_name,\n+                                        author_email = author_email,\n+                                        author_date = author_date)\n+        # find a patchlog to fork from\n+        (refpatchname, refbranchname, refpatchid) = parse_rev(commit_str)\n+        if refpatchname and not refpatchid and \\\n+               (not refpatchid or refpatchid == 'top'):\n+            # FIXME: should also support picking //top.old\n+            if refbranchname:\n+                # assume the refseries is OK, since we already resolved\n+                # commit_str to a git_id\n+                refseries = Series(refbranchname)\n+            else:\n+                refseries = crt_series\n+            patch = refseries.get_patch(refpatchname)\n+            if patch.get_log():\n+                print\"log was %s\" % newpatch.get_log()\n+                print \"setting log to %s\\n\" %  patch.get_log()\n+                newpatch.set_log(patch.get_log())\n+                print\"log is now %s\" % newpatch.get_log()\n+            else:\n+                print \"no log for %s\\n\" % patchname\n+ \n         if not options.unapplied:\n             modified = crt_series.push_patch(patchname)\n         else:\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex b0a01dd..044348a 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -23,6 +23,7 @@ import sys, os, re\n from stgit.utils import *\n from stgit import git, basedir, templates\n from stgit.config import config\n+from shutil import copyfile\n \n \n # stack exception class\n@@ -628,13 +629,18 @@ class Series(StgitObject):\n             patches = applied = unapplied = []\n         for p in patches:\n             patch = self.get_patch(p)\n-            new_series.new_patch(p, message = patch.get_description(),\n-                                 can_edit = False, unapplied = True,\n-                                 bottom = patch.get_bottom(),\n-                                 top = patch.get_top(),\n-                                 author_name = patch.get_authname(),\n-                                 author_email = patch.get_authemail(),\n-                                 author_date = patch.get_authdate())\n+            newpatch = new_series.new_patch(p, message = patch.get_description(),\n+                                            can_edit = False, unapplied = True,\n+                                            bottom = patch.get_bottom(),\n+                                            top = patch.get_top(),\n+                                            author_name = patch.get_authname(),\n+                                            author_email = patch.get_authemail(),\n+                                            author_date = patch.get_authdate())\n+            if patch.get_log():\n+                print \"setting log to %s\" %  patch.get_log()\n+                newpatch.set_log(patch.get_log())\n+            else:\n+                print \"no log for %s\" % patchname\n \n         # fast forward the cloned series to self's top\n         new_series.forward_patches(applied)\n@@ -865,6 +871,8 @@ class Series(StgitObject):\n             if refresh:\n                 self.refresh_patch(cache_update = False, log = 'new')\n \n+        return patch\n+\n     def delete_patch(self, name):\n         \"\"\"Deletes a patch\n         \"\"\"\n"}]}