comparison hgext/evolve.py @ 517:0bc0c9edcb15 stable

evolve: usual syntax/grammar errors/long lines cleanup
author Patrick Mezard <patrick@mezard.eu>
date Sat, 25 Aug 2012 09:45:03 +0200
parents 18854dbc92e7
children 9825c7da5b54
comparison
equal deleted inserted replaced
516:18854dbc92e7 517:0bc0c9edcb15
296 ##################################################################### 296 #####################################################################
297 297
298 # Obsolescence related logic can be very slow if we don't have efficient cache. 298 # Obsolescence related logic can be very slow if we don't have efficient cache.
299 # 299 #
300 # This section implements a cache mechanism that did not make it into core for 300 # This section implements a cache mechanism that did not make it into core for
301 # time reason. It store meaningful set of revision related to obsolescence 301 # time reason. It stores meaningful set of revisions related to obsolescence
302 # (obsolete, unstabletble ... 302 # (obsolete, unstable, etc.)
303 # 303 #
304 # Here is: 304 # Here is:
305 # 305 #
306 # - Computation of meaningful set, 306 # - Computation of meaningful sets
307 # - Cache access logic, 307 # - Cache access logic,
308 # - Cache invalidation logic, 308 # - Cache invalidation logic,
309 # - revset and ctx using this cache. 309 # - revset and ctx using this cache.
310 # 310 #
311 311
563 raise util.Abort(_("push includes a conflicting changeset: %s!") 563 raise util.Abort(_("push includes a conflicting changeset: %s!")
564 % ctx) 564 % ctx)
565 return orig(repo, remote, outgoing, *args, **kwargs) 565 return orig(repo, remote, outgoing, *args, **kwargs)
566 566
567 ##################################################################### 567 #####################################################################
568 ### Filter extinct changeset from common operation ### 568 ### Filter extinct changesets from common operations ###
569 ##################################################################### 569 #####################################################################
570 570
571 @eh.wrapfunction(merge, 'update') 571 @eh.wrapfunction(merge, 'update')
572 def wrapmergeupdate(orig, repo, node, *args, **kwargs): 572 def wrapmergeupdate(orig, repo, node, *args, **kwargs):
573 """ensure we don't automatically update on hidden changeset""" 573 """ensure we don't automatically update on hidden changeset"""
1382 assert obs.obsolete() 1382 assert obs.obsolete()
1383 newer = newerversion(repo, obs.node()) 1383 newer = newerversion(repo, obs.node())
1384 # search of a parent which is not killed 1384 # search of a parent which is not killed
1385 while newer == [()]: 1385 while newer == [()]:
1386 ui.debug("stabilize target %s is plain dead," 1386 ui.debug("stabilize target %s is plain dead,"
1387 " trying to stabilize on it's parent") 1387 " trying to stabilize on its parent")
1388 obs = obs.parents()[0] 1388 obs = obs.parents()[0]
1389 newer = newerversion(repo, obs.node()) 1389 newer = newerversion(repo, obs.node())
1390 if len(newer) > 1: 1390 if len(newer) > 1:
1391 ui.write_err(_("conflict rewriting. can't choose destination\n")) 1391 ui.write_err(_("conflict rewriting. can't choose destination\n"))
1392 return 2 1392 return 2
1530 if conflicting.phase() <= phases.public: 1530 if conflicting.phase() <= phases.public:
1531 raise util.Abort("We can't resolve this conflict from the public side") 1531 raise util.Abort("We can't resolve this conflict from the public side")
1532 if len(other.parents()) > 1: 1532 if len(other.parents()) > 1:
1533 raise util.Abort("conflicting changeset can't be a merge (yet)") 1533 raise util.Abort("conflicting changeset can't be a merge (yet)")
1534 if other.p1() not in conflicting.parents(): 1534 if other.p1() not in conflicting.parents():
1535 raise util.Abort("parent are not common (not handled yet)") 1535 raise util.Abort("parents are not common (not handled yet)")
1536 1536
1537 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) 1537 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
1538 ui.status(_('merge:')) 1538 ui.status(_('merge:'))
1539 if not ui.quiet: 1539 if not ui.quiet:
1540 displayer.show(conflicting) 1540 displayer.show(conflicting)
1545 if not ui.quiet: 1545 if not ui.quiet:
1546 displayer.show(base) 1546 displayer.show(base)
1547 if dryrun: 1547 if dryrun:
1548 ui.write('hg update -c %s &&\n' % conflicting) 1548 ui.write('hg update -c %s &&\n' % conflicting)
1549 ui.write('hg merge %s && \n' % other) 1549 ui.write('hg merge %s && \n' % other)
1550 ui.write('hg commit -m "auto merge resolving conflict between %s and %s"&&\n' 1550 ui.write('hg commit -m "auto merge resolving conflict between '
1551 % (conflicting, other)) 1551 '%s and %s"&&\n' % (conflicting, other))
1552 ui.write('hg up -C %s &&\n' % base) 1552 ui.write('hg up -C %s &&\n' % base)
1553 ui.write('hg revert --all --rev tip &&\n') 1553 ui.write('hg revert --all --rev tip &&\n')
1554 ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n' % conflicting) 1554 ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n'
1555 % conflicting)
1555 return 1556 return
1556 #oldphase = max(conflicting.phase(), other.phase())
1557 wlock = lock = None 1557 wlock = lock = None
1558 try: 1558 try:
1559 wlock = repo.wlock() 1559 wlock = repo.wlock()
1560 lock = repo.lock() 1560 lock = repo.lock()
1561 if conflicting not in repo[None].parents(): 1561 if conflicting not in repo[None].parents():
1571 mergeancestor=True) 1571 mergeancestor=True)
1572 hg._showstats(repo, stats) 1572 hg._showstats(repo, stats)
1573 if stats[3]: 1573 if stats[3]:
1574 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " 1574 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
1575 "or 'hg update -C .' to abandon\n")) 1575 "or 'hg update -C .' to abandon\n"))
1576 #repo.dirstate.write()
1577 if stats[3] > 0: 1576 if stats[3] > 0:
1578 raise util.Abort('GASP! Merge Conflict! You are on you own chap!', 1577 raise util.Abort('GASP! Merge Conflict! You are on you own chap!',
1579 hint='/!\\ hg evolve --continue will NOT work /!\\') 1578 hint='/!\\ hg evolve --continue will NOT work /!\\')
1580 tr = repo.transaction('stabilize-conflicting') 1579 tr = repo.transaction('stabilize-conflicting')
1581 try: 1580 try:
1582 repo.dirstate.setparents(conflicting.node(), node.nullid) 1581 repo.dirstate.setparents(conflicting.node(), node.nullid)
1583 oldlen = len(repo) 1582 oldlen = len(repo)
1584 amend(ui, repo) 1583 amend(ui, repo)
1977 [('r', 'rev', [], 'revision to update'),], 1976 [('r', 'rev', [], 'revision to update'),],
1978 # allow to choose the seed ? 1977 # allow to choose the seed ?
1979 _('[-r] revs')) 1978 _('[-r] revs'))
1980 def touch(ui, repo, *revs, **opts): 1979 def touch(ui, repo, *revs, **opts):
1981 """Create successors with exact same property but hash 1980 """Create successors with exact same property but hash
1982 1981
1983 This is used to "resurect" changeset""" 1982 This is used to "resurrect" changesets
1983 """
1984 revs = list(revs) 1984 revs = list(revs)
1985 revs.extend(opts['rev']) 1985 revs.extend(opts['rev'])
1986 if not revs: 1986 if not revs:
1987 revs = ['.'] 1987 revs = ['.']
1988 revs = scmutil.revrange(repo, revs) 1988 revs = scmutil.revrange(repo, revs)
2013 tr.release() 2013 tr.release()
2014 finally: 2014 finally:
2015 lockmod.release(lock, wlock) 2015 lockmod.release(lock, wlock)
2016 2016
2017 @command('^fold', 2017 @command('^fold',
2018 [('r', 'rev', [], 'revision to fold'),], 2018 [('r', 'rev', [], 'revisions to fold'),],
2019 # allow to choose the seed ? 2019 # allow to choose the seed ?
2020 _('[-r] revs')) 2020 _('[-r] revs'))
2021 def fold(ui, repo, *revs, **opts): 2021 def fold(ui, repo, *revs, **opts):
2022 """Fold multiple revision into a single one""" 2022 """Fold multiple revisions into a single one"""
2023 revs = list(revs) 2023 revs = list(revs)
2024 revs.extend(opts['rev']) 2024 revs.extend(opts['rev'])
2025 if not revs: 2025 if not revs:
2026 revs = ['.'] 2026 revs = ['.']
2027 revs = scmutil.revrange(repo, revs) 2027 revs = scmutil.revrange(repo, revs)
2028 if not revs: 2028 if not revs:
2029 ui.write_err('no revision to fold\n') 2029 ui.write_err('no revision to fold\n')
2030 return 1 2030 return 1
2031 roots = repo.revs('roots(%ld)', revs) 2031 roots = repo.revs('roots(%ld)', revs)
2032 if len(roots) > 1: 2032 if len(roots) > 1:
2033 raise util.Abort("set have multiple roots") 2033 raise util.Abort("set has multiple roots")
2034 root = repo[roots[0]] 2034 root = repo[roots[0]]
2035 if root.phase() <= phases.public: 2035 if root.phase() <= phases.public:
2036 raise util.Abort("can't touch public revision") 2036 raise util.Abort("can't fold public revisions")
2037 heads = repo.revs('heads(%ld)', revs) 2037 heads = repo.revs('heads(%ld)', revs)
2038 if len(heads) > 1: 2038 if len(heads) > 1:
2039 raise util.Abort("set have multiple heads") 2039 raise util.Abort("set has multiple heads")
2040 head = repo[heads[0]] 2040 head = repo[heads[0]]
2041 wlock = lock = None 2041 wlock = lock = None
2042 try: 2042 try:
2043 wlock = repo.wlock() 2043 wlock = repo.wlock()
2044 lock = repo.lock() 2044 lock = repo.lock()