Mercurial > hg
comparison hgext/transplant.py @ 41399:5cb8158a61f7
cleanup: use p1() instead of parents() when we only need the first parent
Differential Revision: https://phab.mercurial-scm.org/D5708
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 25 Jan 2019 23:22:23 -0800 |
parents | 608c15f76f50 |
children | 0531dff73d0b |
comparison
equal
deleted
inserted
replaced
41398:2ff8994ac71d | 41399:5cb8158a61f7 |
---|---|
153 def apply(self, repo, source, revmap, merges, opts=None): | 153 def apply(self, repo, source, revmap, merges, opts=None): |
154 '''apply the revisions in revmap one by one in revision order''' | 154 '''apply the revisions in revmap one by one in revision order''' |
155 if opts is None: | 155 if opts is None: |
156 opts = {} | 156 opts = {} |
157 revs = sorted(revmap) | 157 revs = sorted(revmap) |
158 p1, p2 = repo.dirstate.parents() | 158 p1 = repo.dirstate.p1() |
159 pulls = [] | 159 pulls = [] |
160 diffopts = patch.difffeatureopts(self.ui, opts) | 160 diffopts = patch.difffeatureopts(self.ui, opts) |
161 diffopts.git = True | 161 diffopts.git = True |
162 | 162 |
163 lock = tr = None | 163 lock = tr = None |
184 if pulls: | 184 if pulls: |
185 if source != repo: | 185 if source != repo: |
186 exchange.pull(repo, source.peer(), heads=pulls) | 186 exchange.pull(repo, source.peer(), heads=pulls) |
187 merge.update(repo, pulls[-1], branchmerge=False, | 187 merge.update(repo, pulls[-1], branchmerge=False, |
188 force=False) | 188 force=False) |
189 p1, p2 = repo.dirstate.parents() | 189 p1 = repo.dirstate.p1() |
190 pulls = [] | 190 pulls = [] |
191 | 191 |
192 domerge = False | 192 domerge = False |
193 if node in merges: | 193 if node in merges: |
194 # pulling all the merge revs at once would mean we | 194 # pulling all the merge revs at once would mean we |
321 raise TransplantError(_('fix up the working directory and run ' | 321 raise TransplantError(_('fix up the working directory and run ' |
322 'hg transplant --continue')) | 322 'hg transplant --continue')) |
323 else: | 323 else: |
324 files = None | 324 files = None |
325 if merge: | 325 if merge: |
326 p1, p2 = repo.dirstate.parents() | 326 p1 = repo.dirstate.p1() |
327 repo.setparents(p1, node) | 327 repo.setparents(p1, node) |
328 m = match.always(repo.root, '') | 328 m = match.always(repo.root, '') |
329 else: | 329 else: |
330 m = match.exact(repo.root, '', files) | 330 m = match.exact(repo.root, '', files) |
331 | 331 |
385 else: | 385 else: |
386 merge = True | 386 merge = True |
387 | 387 |
388 extra = {'transplant_source': node} | 388 extra = {'transplant_source': node} |
389 try: | 389 try: |
390 p1, p2 = repo.dirstate.parents() | 390 p1 = repo.dirstate.p1() |
391 if p1 != parent: | 391 if p1 != parent: |
392 raise error.Abort(_('working directory not at transplant ' | 392 raise error.Abort(_('working directory not at transplant ' |
393 'parent %s') % nodemod.hex(parent)) | 393 'parent %s') % nodemod.hex(parent)) |
394 if merge: | 394 if merge: |
395 repo.setparents(p1, parents[1]) | 395 repo.setparents(p1, parents[1]) |
666 # deprecated config: transplant.filter | 666 # deprecated config: transplant.filter |
667 opts['filter'] = ui.config('transplant', 'filter') | 667 opts['filter'] = ui.config('transplant', 'filter') |
668 | 668 |
669 tp = transplanter(ui, repo, opts) | 669 tp = transplanter(ui, repo, opts) |
670 | 670 |
671 p1, p2 = repo.dirstate.parents() | 671 p1 = repo.dirstate.p1() |
672 if len(repo) > 0 and p1 == revlog.nullid: | 672 if len(repo) > 0 and p1 == revlog.nullid: |
673 raise error.Abort(_('no revision checked out')) | 673 raise error.Abort(_('no revision checked out')) |
674 if opts.get('continue'): | 674 if opts.get('continue'): |
675 if not tp.canresume(): | 675 if not tp.canresume(): |
676 raise error.Abort(_('no transplant to continue')) | 676 raise error.Abort(_('no transplant to continue')) |