~mdw
/
stgit
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Optimise the Commit objects creation
[stgit]
/
stgit
/
git.py
diff --git
a/stgit/git.py
b/stgit/git.py
index
3a999e4
..
c1c20c7
100644
(file)
--- a/
stgit/git.py
+++ b/
stgit/git.py
@@
-75,10
+75,23
@@
class Commit:
def get_committer(self):
return self.__committer
def get_committer(self):
return self.__committer
+# dictionary of Commit objects, used to avoid multiple calls to git
+__commits = dict()
#
# Functions
#
#
# Functions
#
+def get_commit(id_hash):
+ """Commit objects factory. Save/look-up them in the __commits
+ dictionary
+ """
+ if id_hash in __commits:
+ return __commits[id_hash]
+ else:
+ commit = Commit(id_hash)
+ __commits[id_hash] = commit
+ return commit
+
def get_conflicts():
"""Return the list of file conflicts
"""
def get_conflicts():
"""Return the list of file conflicts
"""
@@
-94,7
+107,6
@@
def get_conflicts():
def _input(cmd, file_desc):
p = popen2.Popen3(cmd)
for line in file_desc:
def _input(cmd, file_desc):
p = popen2.Popen3(cmd)
for line in file_desc:
- print line
p.tochild.write(line)
p.tochild.close()
if p.wait():
p.tochild.write(line)
p.tochild.close()
if p.wait():
@@
-450,7
+462,7
@@
def switch(tree_id):
for fs in to_delete:
os.remove(fs[1])
for fs in to_delete:
os.remove(fs[1])
-def
fetch
(location, head = None, tag = None):
+def
pull
(location, head = None, tag = None):
"""Fetch changes from the remote repository. At the moment, just
use the 'git fetch' scripts
"""
"""Fetch changes from the remote repository. At the moment, just
use the 'git fetch' scripts
"""
@@
-460,11
+472,9
@@
def fetch(location, head = None, tag = None):
elif tag:
args += ['tag', tag]
elif tag:
args += ['tag', tag]
- if __run('git
fetch
', args) != 0:
+ if __run('git
pull
', args) != 0:
raise GitException, 'Failed "git fetch %s"' % location
raise GitException, 'Failed "git fetch %s"' % location
- return read_string(os.path.join(base_dir, 'FETCH_HEAD'))
-
def apply_patch(filename = None):
"""Apply a patch onto the current index. There must not be any
local changes in the tree, otherwise the command fails
def apply_patch(filename = None):
"""Apply a patch onto the current index. There must not be any
local changes in the tree, otherwise the command fails