{"thread":{"id":"3218","subject":"[PATCH 0/2] Make merge recursive faster in some cases","startedAt":"2006-02-02T11:38:48Z","lastAt":"2006-02-02T11:43:35Z","messageCount":3,"participants":["Fredrik Kuivinen"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"15484","messageId":"20060202113848.GA8103@c165.ib.student.liu.se","threadId":"3218","inReplyTo":null,"subject":"[PATCH 0/2] Make merge recursive faster in some cases","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2006-02-02T11:38:48Z","receivedAt":"2006-02-02T11:38:48Z","isPatch":true,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"The first patch teaches git-merge-recursive how to use the bases that\nare supplied by the merge driver program in some cases. To be more\nprecise: if git-merge-recursive is supplied with a single base then\nthat one will be used, otherwise git-merge-recursive will compute the\nbases on its own.\n\nThe second patch makes the commit graph construction more efficient.\n\n- Fredrik\n"},{"id":"15485","messageId":"20060202114320.GB8103@c165.ib.student.liu.se","threadId":"3218","inReplyTo":"20060202113848.GA8103@c165.ib.student.liu.se","subject":"[PATCH 1/2] merge-recursive: Make use of provided bases","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2006-02-02T11:43:20Z","receivedAt":"2006-02-02T11:43:20Z","isPatch":true,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"This makes some cases faster as we don't have to build the commit graph.\n\nSigned-off-by: Fredrik Kuivinen <freku045@student.liu.se>\n\n\n---\n\n git-merge-recursive.py |   31 +++++++++++++++++++++----------\n 1 files changed, 21 insertions(+), 10 deletions(-)\n\nc78eacd112489b264df5d176df287f7ff5696948\ndiff --git a/git-merge-recursive.py b/git-merge-recursive.py\nindex b17c8e5..ce8a31f 100755\n--- a/git-merge-recursive.py\n+++ b/git-merge-recursive.py\n@@ -45,11 +45,10 @@ cacheOnly = False\n # The entry point to the merge code\n # ---------------------------------\n \n-def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0):\n+def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0, ancestor=None):\n     '''Merge the commits h1 and h2, return the resulting virtual\n     commit object and a flag indicating the cleaness of the merge.'''\n     assert(isinstance(h1, Commit) and isinstance(h2, Commit))\n-    assert(isinstance(graph, Graph))\n \n     global outputIndent\n \n@@ -58,7 +57,11 @@ def merge(h1, h2, branch1Name, branch2Na\n     output(h2)\n     sys.stdout.flush()\n \n-    ca = getCommonAncestors(graph, h1, h2)\n+    if ancestor:\n+        ca = [ancestor]\n+    else:\n+        assert(isinstance(graph, Graph))\n+        ca = getCommonAncestors(graph, h1, h2)\n     output('found', len(ca), 'common ancestor(s):')\n     for x in ca:\n         output(x)\n@@ -86,7 +89,7 @@ def merge(h1, h2, branch1Name, branch2Na\n     [shaRes, clean] = mergeTrees(h1.tree(), h2.tree(), mergedCA.tree(),\n                                  branch1Name, branch2Name)\n \n-    if clean or cacheOnly:\n+    if graph and (clean or cacheOnly):\n         res = Commit(None, [h1, h2], tree=shaRes)\n         graph.addNode(res)\n     else:\n@@ -891,12 +894,11 @@ def usage():\n \n # main entry point as merge strategy module\n # The first parameters up to -- are merge bases, and the rest are heads.\n-# This strategy module figures out merge bases itself, so we only\n-# get heads.\n \n if len(sys.argv) < 4:\n     usage()\n \n+bases = []\n for nextArg in xrange(1, len(sys.argv)):\n     if sys.argv[nextArg] == '--':\n         if len(sys.argv) != nextArg + 3:\n@@ -907,6 +909,8 @@ for nextArg in xrange(1, len(sys.argv)):\n         except IndexError:\n             usage()\n         break\n+    else:\n+        bases.append(sys.argv[nextArg])\n \n print 'Merging', h1, 'with', h2\n \n@@ -914,10 +918,17 @@ try:\n     h1 = runProgram(['git-rev-parse', '--verify', h1 + '^0']).rstrip()\n     h2 = runProgram(['git-rev-parse', '--verify', h2 + '^0']).rstrip()\n \n-    graph = buildGraph([h1, h2])\n-\n-    [dummy, clean] = merge(graph.shaMap[h1], graph.shaMap[h2],\n-                           firstBranch, secondBranch, graph)\n+    if len(bases) == 1:\n+        base = runProgram(['git-rev-parse', '--verify',\n+                           bases[0] + '^0']).rstrip()\n+        ancestor = Commit(base, None)\n+        [dummy, clean] = merge(Commit(h1, None), Commit(h2, None),\n+                               firstBranch, secondBranch, None, 0,\n+                               ancestor)\n+    else:\n+        graph = buildGraph([h1, h2])\n+        [dummy, clean] = merge(graph.shaMap[h1], graph.shaMap[h2],\n+                               firstBranch, secondBranch, graph)\n \n     print ''\n except:\n-- \n1.1.6.gc78e-dirty\n"},{"id":"15486","messageId":"20060202114335.GC8103@c165.ib.student.liu.se","threadId":"3218","inReplyTo":"20060202113848.GA8103@c165.ib.student.liu.se","subject":"[PATCH 2/2] merge-recursive: Speed up commit graph construction","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2006-02-02T11:43:35Z","receivedAt":"2006-02-02T11:43:35Z","isPatch":true,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"Use __slots__ to speed up construction and decrease memory consumption\nof the Commit objects.\n\nSigned-off-by: Fredrik Kuivinen <freku045@student.liu.se>\n\n\n---\n\n gitMergeCommon.py |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\n23aa79d4e86761e049bc44b5106cd45355045174\ndiff --git a/gitMergeCommon.py b/gitMergeCommon.py\nindex ff6f58a..fdbf9e4 100644\n--- a/gitMergeCommon.py\n+++ b/gitMergeCommon.py\n@@ -107,7 +107,10 @@ def isSha(obj):\n     return (type(obj) is str and bool(shaRE.match(obj))) or \\\n            (type(obj) is int and obj >= 1)\n \n-class Commit:\n+class Commit(object):\n+    __slots__ = ['parents', 'firstLineMsg', 'children', '_tree', 'sha',\n+                 'virtual']\n+\n     def __init__(self, sha, parents, tree=None):\n         self.parents = parents\n         self.firstLineMsg = None\n-- \n1.1.6.gc78e-dirty\n"}]}