hgext3rd/evolve/__init__.py
changeset 3836 b91db6989231
parent 3797 9d63d124fd23
parent 3813 27e7ed2d13a6
child 3839 ac0717f23921
equal deleted inserted replaced
3832:fb821ed44f86 3836:b91db6989231
   964     return getattr(ctx, 'topicidx', lambda: None)()
   964     return getattr(ctx, 'topicidx', lambda: None)()
   965 
   965 
   966 def _getcurrenttopic(repo):
   966 def _getcurrenttopic(repo):
   967     return getattr(repo, 'currenttopic', '')
   967     return getattr(repo, 'currenttopic', '')
   968 
   968 
   969 def _prevupdate(repo, displayer, target, bookmark, dryrun):
   969 def _prevupdate(repo, displayer, target, bookmark, dryrun, mergeopt):
   970     if dryrun:
   970     if dryrun:
   971         repo.ui.write(_('hg update %s;\n') % target)
   971         repo.ui.write(_('hg update %s;\n') % target)
   972         if bookmark is not None:
   972         if bookmark is not None:
   973             repo.ui.write(_('hg bookmark %s -r %s;\n')
   973             repo.ui.write(_('hg bookmark %s -r %s;\n')
   974                           % (bookmark, target))
   974                           % (bookmark, target))
   975     else:
   975     else:
       
   976         updatecheck = None
       
   977         # --merge is passed, we don't need to care about commands.update.check
       
   978         # config option
       
   979         if mergeopt:
       
   980             updatecheck = 'none'
   976         try:
   981         try:
   977             ret = hg.updatetotally(repo.ui, repo, target.node(), None)
   982             ret = hg.updatetotally(repo.ui, repo, target.node(), None,
       
   983                                    updatecheck=updatecheck)
   978         except error.Abort as exc:
   984         except error.Abort as exc:
   979             # replace the hint to mention about --merge option
   985             # replace the hint to mention about --merge option
   980             exc.hint = _('do you want --merge?')
   986             exc.hint = _('do you want --merge?')
   981             raise
   987             raise
   982         if not ret:
   988         if not ret:
  1045     """update to parent revision
  1051     """update to parent revision
  1046 
  1052 
  1047     Displays the summary line of the destination for clarity."""
  1053     Displays the summary line of the destination for clarity."""
  1048     wlock = None
  1054     wlock = None
  1049     dryrunopt = opts['dry_run']
  1055     dryrunopt = opts['dry_run']
       
  1056     mergeopt = opts['merge']
  1050     if not dryrunopt:
  1057     if not dryrunopt:
  1051         wlock = repo.wlock()
  1058         wlock = repo.wlock()
  1052     try:
  1059     try:
  1053         wkctx = repo[None]
  1060         wkctx = repo[None]
  1054         wparents = wkctx.parents()
  1061         wparents = wkctx.parents()
  1055         if len(wparents) != 1:
  1062         if len(wparents) != 1:
  1056             raise error.Abort(_('merge in progress'))
  1063             raise error.Abort(_('merge in progress'))
  1057         if not opts['merge']:
  1064         if not mergeopt:
  1058             # we only skip the check if noconflict is set
  1065             # we only skip the check if noconflict is set
  1059             if ui.config('commands', 'update.check') == 'noconflict':
  1066             if ui.config('commands', 'update.check') == 'noconflict':
  1060                 pass
  1067                 pass
  1061             else:
  1068             else:
  1062                 try:
  1069                 try:
  1075             backup = repo.ui.backupconfig('_internal', 'keep-topic')
  1082             backup = repo.ui.backupconfig('_internal', 'keep-topic')
  1076             try:
  1083             try:
  1077                 if topic and _getcurrenttopic(repo) != _gettopic(target):
  1084                 if topic and _getcurrenttopic(repo) != _gettopic(target):
  1078                     repo.ui.setconfig('_internal', 'keep-topic', 'yes',
  1085                     repo.ui.setconfig('_internal', 'keep-topic', 'yes',
  1079                                       source='topic-extension')
  1086                                       source='topic-extension')
  1080                 _prevupdate(repo, displayer, target, bookmark, dryrunopt)
  1087                 _prevupdate(repo, displayer, target, bookmark, dryrunopt,
       
  1088                             mergeopt)
  1081             finally:
  1089             finally:
  1082                 repo.ui.restoreconfig(backup)
  1090                 repo.ui.restoreconfig(backup)
  1083             return 0
  1091             return 0
  1084         else:
  1092         else:
  1085             return 1
  1093             return 1
  1211     if opts.get('dry_run'):
  1219     if opts.get('dry_run'):
  1212         ui.write(_('hg update %s;\n') % children)
  1220         ui.write(_('hg update %s;\n') % children)
  1213         if shouldmove:
  1221         if shouldmove:
  1214             ui.write(_('hg bookmark %s -r %s;\n') % (bm, children))
  1222             ui.write(_('hg bookmark %s -r %s;\n') % (bm, children))
  1215     else:
  1223     else:
       
  1224         updatecheck = None
       
  1225         # --merge is passed, we don't need to care about commands.update.check
       
  1226         # config option
       
  1227         if opts['merge']:
       
  1228             updatecheck = 'none'
  1216         try:
  1229         try:
  1217             ret = hg.updatetotally(ui, repo, children.node(), None)
  1230             ret = hg.updatetotally(ui, repo, children.node(), None,
       
  1231                                    updatecheck=updatecheck)
  1218         except error.Abort as exc:
  1232         except error.Abort as exc:
  1219             # replace the hint to mention about --merge option
  1233             # replace the hint to mention about --merge option
  1220             exc.hint = _('do you want --merge?')
  1234             exc.hint = _('do you want --merge?')
  1221             raise
  1235             raise
  1222 
  1236