# HG changeset patch # User Sushil khanchi # Date 1538465129 -19800 # Node ID cc3a0b13ae578660c4ae5f3526e09b5f3dab1a63 # Parent dd81d7f438576bd1343000202430ec71ba4b32c5 evolve: use stack alias s# in `hg evolve` msgs As repository grows revision number lose their usefulness. To make it a little better than now, after this patch we will be using short stack aliases introduced by the topic extension (as displayed by `hg stack`). These stack aliases s# will be used only when user has enabled topic extension and his repo's current active topic is same as the revs to be evolved. For now, this patch doesn't cover `continue` case. I will discuss about this with Pierre-Yves David. Maybe we have to store the info in evolvestate that "we were using stack aliases". diff -r dd81d7f43857 -r cc3a0b13ae57 hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Mon Oct 01 19:59:17 2018 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Tue Oct 02 12:55:29 2018 +0530 @@ -54,7 +54,7 @@ abortmessage = _("see `hg help evolve.interrupted`\n") def _solveone(ui, repo, ctx, evolvestate, dryrun, confirm, - progresscb, category, lastsolved=None): + progresscb, category, lastsolved=None, stacktmplt=False): """Resolve the troubles affecting one revision returns a tuple (bool, newnode) where, @@ -63,8 +63,14 @@ formed. newnode can be node, when resolution led to no new commit. If bool is False, this is ''. """ + displayer = None + if stacktmplt: + displayer = compat.changesetdisplayer(ui, repo, + {'template': stacktemplate}) + else: + displayer = compat.changesetdisplayer(ui, repo, + {'template': shorttemplate}) wlock = lock = tr = None - displayer = compat.changesetdisplayer(ui, repo, {'template': shorttemplate}) try: wlock = repo.wlock() lock = repo.lock() @@ -1571,12 +1577,23 @@ # lastsolved: keep track of successor of last troubled cset we evolved # to confirm that if atop msg should be suppressed to remove redundancy lastsolved = None + + # check if revs to be evolved are in active topic to make sure that we + # can use stack aliases s# in evolve msgs. + activetopic = getattr(repo, 'currenttopic', '') + rev = revs[0] + revtopic = getattr(repo[rev], 'topic', '') + if revtopic: + revtopic = revtopic() + stacktmplt = False + if activetopic and revtopic and (activetopic == revtopic): + stacktmplt = True for rev in revs: curctx = repo[rev] progresscb() ret = _solveone(ui, repo, curctx, evolvestate, dryrunopt, confirmopt, progresscb, targetcat, - lastsolved=lastsolved) + lastsolved=lastsolved, stacktmplt=stacktmplt) seen += 1 if ret[0]: evolvestate['replacements'][curctx.node()] = ret[1] @@ -1588,7 +1605,8 @@ # we were processing an orphan merge with both parents obsolete, # stabilized for second parent, re-stabilize for the first parent ret = _solveone(ui, repo, repo[ret[1]], evolvestate, dryrunopt, - confirmopt, progresscb, targetcat) + confirmopt, progresscb, targetcat, + stacktmplt=stacktmplt) if ret[0]: evolvestate['replacements'][curctx.node()] = ret[1] else: diff -r dd81d7f43857 -r cc3a0b13ae57 tests/test-evolve-topic.t --- a/tests/test-evolve-topic.t Mon Oct 01 19:59:17 2018 +0530 +++ b/tests/test-evolve-topic.t Tue Oct 02 12:55:29 2018 +0530 @@ -123,10 +123,19 @@ Run evolve --all + $ hg stack + ### topic: foo + ### target: default (branch) + s4$ add fff (current unstable) + s3$ add eee (unstable) + s2: add ddd + s1: add ccc + s0^ add bbb (base) + $ hg evolve --all - move:[4] add eee - atop:[10] add ddd - move:[11] add fff + move:[s3] add eee + atop:[s2] add ddd + move:[s4] add fff working directory is now at 070c5573d8f9 $ hg log -G @ 13 - {foo} 070c5573d8f9 add fff (draft)