comparison hgext/transplant.py @ 47012:d55b71393907

node: replace nullid and friends with nodeconstants class The introduction of 256bit hashes require changes to nullid and other constant magic values. Start pushing them down from repository and revlog where sensible. Differential Revision: https://phab.mercurial-scm.org/D9465
author Joerg Sonnenberger <joerg@bec.de>
date Mon, 29 Mar 2021 01:52:06 +0200
parents 0428e555acb7
children 5ced12cfa41b
comparison
equal deleted inserted replaced
46992:5fa019ceb499 47012:d55b71393907
20 from mercurial.i18n import _ 20 from mercurial.i18n import _
21 from mercurial.pycompat import open 21 from mercurial.pycompat import open
22 from mercurial.node import ( 22 from mercurial.node import (
23 bin, 23 bin,
24 hex, 24 hex,
25 nullid,
26 short, 25 short,
27 ) 26 )
28 from mercurial import ( 27 from mercurial import (
29 bundlerepo, 28 bundlerepo,
30 cmdutil, 29 cmdutil,
132 131
133 132
134 class transplanter(object): 133 class transplanter(object):
135 def __init__(self, ui, repo, opts): 134 def __init__(self, ui, repo, opts):
136 self.ui = ui 135 self.ui = ui
136 self.repo = repo
137 self.path = repo.vfs.join(b'transplant') 137 self.path = repo.vfs.join(b'transplant')
138 self.opener = vfsmod.vfs(self.path) 138 self.opener = vfsmod.vfs(self.path)
139 self.transplants = transplants( 139 self.transplants = transplants(
140 self.path, b'transplants', opener=self.opener 140 self.path, b'transplants', opener=self.opener
141 ) 141 )
219 domerge = True 219 domerge = True
220 if not hasnode(repo, node): 220 if not hasnode(repo, node):
221 exchange.pull(repo, source.peer(), heads=[node]) 221 exchange.pull(repo, source.peer(), heads=[node])
222 222
223 skipmerge = False 223 skipmerge = False
224 if parents[1] != nullid: 224 if parents[1] != repo.nullid:
225 if not opts.get(b'parent'): 225 if not opts.get(b'parent'):
226 self.ui.note( 226 self.ui.note(
227 _(b'skipping merge changeset %d:%s\n') 227 _(b'skipping merge changeset %d:%s\n')
228 % (rev, short(node)) 228 % (rev, short(node))
229 ) 229 )
514 series.close() 514 series.close()
515 515
516 def parselog(self, fp): 516 def parselog(self, fp):
517 parents = [] 517 parents = []
518 message = [] 518 message = []
519 node = nullid 519 node = self.repo.nullid
520 inmsg = False 520 inmsg = False
521 user = None 521 user = None
522 date = None 522 date = None
523 for line in fp.read().splitlines(): 523 for line in fp.read().splitlines():
524 if inmsg: 524 if inmsg:
566 566
567 def transplantfilter(self, repo, source, root): 567 def transplantfilter(self, repo, source, root):
568 def matchfn(node): 568 def matchfn(node):
569 if self.applied(repo, node, root): 569 if self.applied(repo, node, root):
570 return False 570 return False
571 if source.changelog.parents(node)[1] != nullid: 571 if source.changelog.parents(node)[1] != repo.nullid:
572 return False 572 return False
573 extra = source.changelog.read(node)[5] 573 extra = source.changelog.read(node)[5]
574 cnode = extra.get(b'transplant_source') 574 cnode = extra.get(b'transplant_source')
575 if cnode and self.applied(repo, cnode, root): 575 if cnode and self.applied(repo, cnode, root):
576 return False 576 return False
802 opts[b'filter'] = ui.config(b'transplant', b'filter') 802 opts[b'filter'] = ui.config(b'transplant', b'filter')
803 803
804 tp = transplanter(ui, repo, opts) 804 tp = transplanter(ui, repo, opts)
805 805
806 p1 = repo.dirstate.p1() 806 p1 = repo.dirstate.p1()
807 if len(repo) > 0 and p1 == nullid: 807 if len(repo) > 0 and p1 == repo.nullid:
808 raise error.Abort(_(b'no revision checked out')) 808 raise error.Abort(_(b'no revision checked out'))
809 if opts.get(b'continue'): 809 if opts.get(b'continue'):
810 if not tp.canresume(): 810 if not tp.canresume():
811 raise error.StateError(_(b'no transplant to continue')) 811 raise error.StateError(_(b'no transplant to continue'))
812 elif opts.get(b'stop'): 812 elif opts.get(b'stop'):