comparison hgext/histedit.py @ 22976:886711722db6

histedit: add histedit state class Add an histeditstate class that is intended to hold the current state. This allows us encapsulate the state and avoids passing around a tuple which is based on the serialization format. In particular this will give actions more control over the state and allow external sources to have more control of histedits behavior, e.g. an external implementation of x/exec.
author David Soria Parra <davidsp@fb.com>
date Wed, 15 Oct 2014 17:17:12 -0700
parents 8792ac090e3b
children 29ae3b190ec5
comparison
equal deleted inserted replaced
22975:461342e1c8aa 22976:886711722db6
185 # r, roll = like fold, but discard this commit's description 185 # r, roll = like fold, but discard this commit's description
186 # d, drop = remove commit from history 186 # d, drop = remove commit from history
187 # m, mess = edit message without changing commit content 187 # m, mess = edit message without changing commit content
188 # 188 #
189 """) 189 """)
190
191 class histeditstate(object):
192 def __init__(self, repo, parentctxnode=None, rules=None, keep=None,
193 topmost=None, replacements=None):
194 self.repo = repo
195 self.parentctxnode = parentctxnode
196 self.rules = rules
197 self.keep = keep
198 self.topmost = topmost
199 if replacements is None:
200 self.replacements = []
201 else:
202 self.replacements = replacements
203
204 def write(self):
205 fp = self.repo.vfs('histedit-state', 'w')
206 pickle.dump((self.parentctxnode, self.rules, self.keep,
207 self.topmost, self.replacements), fp)
208 fp.close()
190 209
191 def commitfuncfor(repo, src): 210 def commitfuncfor(repo, src):
192 """Build a commit function for the replacement of <src> 211 """Build a commit function for the replacement of <src>
193 212
194 This function ensure we apply the same treatment to all changesets. 213 This function ensure we apply the same treatment to all changesets.