* [PATCH 0/2] Make merge recursive faster in some cases
@ 2006-02-02 11:38 Fredrik Kuivinen
2006-02-02 11:43 ` [PATCH 1/2] merge-recursive: Make use of provided bases Fredrik Kuivinen
2006-02-02 11:43 ` [PATCH 2/2] merge-recursive: Speed up commit graph construction Fredrik Kuivinen
0 siblings, 2 replies; 3+ messages in thread
From: Fredrik Kuivinen @ 2006-02-02 11:38 UTC (permalink / raw)
To: git; +Cc: junkio
The first patch teaches git-merge-recursive how to use the bases that
are supplied by the merge driver program in some cases. To be more
precise: if git-merge-recursive is supplied with a single base then
that one will be used, otherwise git-merge-recursive will compute the
bases on its own.
The second patch makes the commit graph construction more efficient.
- Fredrik
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] merge-recursive: Make use of provided bases
2006-02-02 11:38 [PATCH 0/2] Make merge recursive faster in some cases Fredrik Kuivinen
@ 2006-02-02 11:43 ` Fredrik Kuivinen
2006-02-02 11:43 ` [PATCH 2/2] merge-recursive: Speed up commit graph construction Fredrik Kuivinen
1 sibling, 0 replies; 3+ messages in thread
From: Fredrik Kuivinen @ 2006-02-02 11:43 UTC (permalink / raw)
To: git; +Cc: junkio
This makes some cases faster as we don't have to build the commit graph.
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
---
git-merge-recursive.py | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
c78eacd112489b264df5d176df287f7ff5696948
diff --git a/git-merge-recursive.py b/git-merge-recursive.py
index b17c8e5..ce8a31f 100755
--- a/git-merge-recursive.py
+++ b/git-merge-recursive.py
@@ -45,11 +45,10 @@ cacheOnly = False
# The entry point to the merge code
# ---------------------------------
-def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0):
+def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0, ancestor=None):
'''Merge the commits h1 and h2, return the resulting virtual
commit object and a flag indicating the cleaness of the merge.'''
assert(isinstance(h1, Commit) and isinstance(h2, Commit))
- assert(isinstance(graph, Graph))
global outputIndent
@@ -58,7 +57,11 @@ def merge(h1, h2, branch1Name, branch2Na
output(h2)
sys.stdout.flush()
- ca = getCommonAncestors(graph, h1, h2)
+ if ancestor:
+ ca = [ancestor]
+ else:
+ assert(isinstance(graph, Graph))
+ ca = getCommonAncestors(graph, h1, h2)
output('found', len(ca), 'common ancestor(s):')
for x in ca:
output(x)
@@ -86,7 +89,7 @@ def merge(h1, h2, branch1Name, branch2Na
[shaRes, clean] = mergeTrees(h1.tree(), h2.tree(), mergedCA.tree(),
branch1Name, branch2Name)
- if clean or cacheOnly:
+ if graph and (clean or cacheOnly):
res = Commit(None, [h1, h2], tree=shaRes)
graph.addNode(res)
else:
@@ -891,12 +894,11 @@ def usage():
# main entry point as merge strategy module
# The first parameters up to -- are merge bases, and the rest are heads.
-# This strategy module figures out merge bases itself, so we only
-# get heads.
if len(sys.argv) < 4:
usage()
+bases = []
for nextArg in xrange(1, len(sys.argv)):
if sys.argv[nextArg] == '--':
if len(sys.argv) != nextArg + 3:
@@ -907,6 +909,8 @@ for nextArg in xrange(1, len(sys.argv)):
except IndexError:
usage()
break
+ else:
+ bases.append(sys.argv[nextArg])
print 'Merging', h1, 'with', h2
@@ -914,10 +918,17 @@ try:
h1 = runProgram(['git-rev-parse', '--verify', h1 + '^0']).rstrip()
h2 = runProgram(['git-rev-parse', '--verify', h2 + '^0']).rstrip()
- graph = buildGraph([h1, h2])
-
- [dummy, clean] = merge(graph.shaMap[h1], graph.shaMap[h2],
- firstBranch, secondBranch, graph)
+ if len(bases) == 1:
+ base = runProgram(['git-rev-parse', '--verify',
+ bases[0] + '^0']).rstrip()
+ ancestor = Commit(base, None)
+ [dummy, clean] = merge(Commit(h1, None), Commit(h2, None),
+ firstBranch, secondBranch, None, 0,
+ ancestor)
+ else:
+ graph = buildGraph([h1, h2])
+ [dummy, clean] = merge(graph.shaMap[h1], graph.shaMap[h2],
+ firstBranch, secondBranch, graph)
print ''
except:
--
1.1.6.gc78e-dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] merge-recursive: Speed up commit graph construction
2006-02-02 11:38 [PATCH 0/2] Make merge recursive faster in some cases Fredrik Kuivinen
2006-02-02 11:43 ` [PATCH 1/2] merge-recursive: Make use of provided bases Fredrik Kuivinen
@ 2006-02-02 11:43 ` Fredrik Kuivinen
1 sibling, 0 replies; 3+ messages in thread
From: Fredrik Kuivinen @ 2006-02-02 11:43 UTC (permalink / raw)
To: git; +Cc: junkio
Use __slots__ to speed up construction and decrease memory consumption
of the Commit objects.
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
---
gitMergeCommon.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
23aa79d4e86761e049bc44b5106cd45355045174
diff --git a/gitMergeCommon.py b/gitMergeCommon.py
index ff6f58a..fdbf9e4 100644
--- a/gitMergeCommon.py
+++ b/gitMergeCommon.py
@@ -107,7 +107,10 @@ def isSha(obj):
return (type(obj) is str and bool(shaRE.match(obj))) or \
(type(obj) is int and obj >= 1)
-class Commit:
+class Commit(object):
+ __slots__ = ['parents', 'firstLineMsg', 'children', '_tree', 'sha',
+ 'virtual']
+
def __init__(self, sha, parents, tree=None):
self.parents = parents
self.firstLineMsg = None
--
1.1.6.gc78e-dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-02-02 11:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-02 11:38 [PATCH 0/2] Make merge recursive faster in some cases Fredrik Kuivinen
2006-02-02 11:43 ` [PATCH 1/2] merge-recursive: Make use of provided bases Fredrik Kuivinen
2006-02-02 11:43 ` [PATCH 2/2] merge-recursive: Speed up commit graph construction Fredrik Kuivinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).