if val != NoValue:
return val
elif defaults != NoValue:
return getattr(defaults, attr)
else:
if val != NoValue:
return val
elif defaults != NoValue:
return getattr(defaults, attr)
else:
"""Immutable."""
def __init__(self, tree = NoValue, parents = NoValue, author = NoValue,
committer = NoValue, message = NoValue, defaults = NoValue):
d = make_defaults(defaults)
self.__tree = d(tree, 'tree')
self.__parents = d(parents, 'parents')
"""Immutable."""
def __init__(self, tree = NoValue, parents = NoValue, author = NoValue,
committer = NoValue, message = NoValue, defaults = NoValue):
d = make_defaults(defaults)
self.__tree = d(tree, 'tree')
self.__parents = d(parents, 'parents')
- self.__author = d(author, 'author')
- self.__committer = d(committer, 'committer')
+ self.__author = d(author, 'author', Person.author)
+ self.__committer = d(committer, 'committer', Person.committer)
self.__message = d(message, 'message')
tree = property(lambda self: self.__tree)
parents = property(lambda self: self.__parents)
self.__message = d(message, 'message')
tree = property(lambda self: self.__tree)
parents = property(lambda self: self.__parents)
- return ('Commitdata<tree: %s, parents: %s, author: %s,'
+ return ('CommitData<tree: %s, parents: %s, author: %s,'
' committer: %s, message: "%s">'
) % (tree, parents, self.author, self.committer, self.message)
@classmethod
' committer: %s, message: "%s">'
) % (tree, parents, self.author, self.committer, self.message)
@classmethod
def run(self, args, env = {}):
return run.Run(*args).env(utils.add_dict(self.env, env))
def run(self, args, env = {}):
return run.Run(*args).env(utils.add_dict(self.env, env))
+class RunWithEnvCwd(RunWithEnv):
+ def run(self, args, env = {}):
+ return RunWithEnv.run(self, args, env).cwd(self.cwd)
+
class Repository(RunWithEnv):
def __init__(self, directory):
self.__git_dir = directory
class Repository(RunWithEnv):
def __init__(self, directory):
self.__git_dir = directory
class Worktree(object):
def __init__(self, directory):
self.__directory = directory
class Worktree(object):
def __init__(self, directory):
self.__directory = directory
def __init__(self, index, worktree):
self.__index = index
self.__worktree = worktree
index = property(lambda self: self.__index)
env = property(lambda self: utils.add_dict(self.__index.env,
self.__worktree.env))
def __init__(self, index, worktree):
self.__index = index
self.__worktree = worktree
index = property(lambda self: self.__index)
env = property(lambda self: utils.add_dict(self.__index.env,
self.__worktree.env))
def checkout(self, old_tree, new_tree):
# TODO: Optionally do a 3-way instead of doing nothing when we
# have a problem. Or maybe we should stash changes in a patch?
def checkout(self, old_tree, new_tree):
# TODO: Optionally do a 3-way instead of doing nothing when we
# have a problem. Or maybe we should stash changes in a patch?
self.run(['git', 'read-tree', '-u', '-m',
'--exclude-per-directory=.gitignore',
old_tree.sha1, new_tree.sha1]
self.run(['git', 'read-tree', '-u', '-m',
'--exclude-per-directory=.gitignore',
old_tree.sha1, new_tree.sha1]
except run.RunException:
raise CheckoutException('Index/workdir dirty')
def merge(self, base, ours, theirs):
except run.RunException:
raise CheckoutException('Index/workdir dirty')
def merge(self, base, ours, theirs):
theirs.sha1],
env = { 'GITHEAD_%s' % base.sha1: 'ancestor',
'GITHEAD_%s' % ours.sha1: 'current',
theirs.sha1],
env = { 'GITHEAD_%s' % base.sha1: 'ancestor',
'GITHEAD_%s' % ours.sha1: 'current',