# HG changeset patch # User Pierre-Yves David # Date 1498043927 -7200 # Node ID d8b47d961c7778c1987fea94d545ddc55fad83f5 # Parent b9cfb8bd0965b000ee903c671d52e0f7cae5127c topic-change: update the working copy along when changing topic of '.' This avoids leaving the working copy behind, removing another large parts of issue5441. diff -r b9cfb8bd0965 -r d8b47d961c77 README --- a/README Wed Jun 21 13:21:08 2017 +0200 +++ b/README Wed Jun 21 13:18:47 2017 +0200 @@ -129,7 +129,7 @@ - stack: also show the unstable status for the current changeset (issue5553) - stack: properly abort when and unknown topic is requested, - - topic: fix issue5441 in the linear case, + - topic: changing topic on revs no longer adds extra instability (issue5441) - topic: topics: rename '--change' flag to '--rev' flag, 6.4.1 - in progress diff -r b9cfb8bd0965 -r d8b47d961c77 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Wed Jun 21 13:21:08 2017 +0200 +++ b/hgext3rd/topic/__init__.py Wed Jun 21 13:18:47 2017 +0200 @@ -62,6 +62,7 @@ context, error, extensions, + hg, localrepo, lock, merge, @@ -306,8 +307,9 @@ def _changetopics(ui, repo, revset, newtopic): rewrote = 0 needevolve = False - l = txn = None + wl = l = txn = None try: + wl = repo.wlock() l = repo.lock() txn = repo.transaction('rewrite-topics') p1 = None @@ -358,9 +360,19 @@ needevolve = needevolve or (len(c.children()) > 0) obsolete.createmarkers(repo, [(c, (repo[newnode],))]) rewrote += 1 + # move the working copy too + wctx = repo[None] + # in-progress merge is a bit too complexe for now. + if len(wctx.parents()) == 1: + newid = successors.get(wctx.p1().node()) + if newid is not None: + # this provide some useless output we shoudl eventually suppress + # + # 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + hg.update(repo, newid) txn.close() finally: - lock.release(txn, l) + lock.release(txn, l, wl) repo.invalidate() ui.status('changed topic on %d changes\n' % rewrote) if needevolve: diff -r b9cfb8bd0965 -r d8b47d961c77 tests/test-topic.t --- a/tests/test-topic.t Wed Jun 21 13:21:08 2017 +0200 +++ b/tests/test-topic.t Wed Jun 21 13:18:47 2017 +0200 @@ -653,6 +653,8 @@ Reading the same topic with topic --rev should work: $ hg topic --rev . watwat + switching to topic watwat + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved changed topic on 1 changes Testing issue5441 @@ -676,10 +678,12 @@ | $ hg topics --rev '13::19' changewat + switching to topic changewat + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved changed topic on 2 changes please run hg evolve --rev "topic(changewat)" now $ hg log -Gr 'draft()' - o changeset: 21:58e15a6365ca + @ changeset: 21:58e15a6365ca | tag: tip | topic: changewat | user: test @@ -693,20 +697,6 @@ | date: Thu Jan 01 00:00:00 1970 +0000 | summary: start on fran | - | @ changeset: 19:b72b86a1f96b - | | topic: watwat - | | parent: 13:d91cd8fd490e - | | user: test - | | date: Thu Jan 01 00:00:00 1970 +0000 - | | summary: fran? - | | - | x changeset: 13:d91cd8fd490e - |/ topic: wat - | parent: 3:a53952faf762 - | user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: start on fran - | Case with branching: @@ -739,10 +729,12 @@ | summary: start on fran | $ hg topics --rev 't1::' changewut + switching to topic changewut + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved changed topic on 3 changes please run hg evolve --rev "topic(changewut)" now $ hg log -Gr 'draft()' - o changeset: 25:05d1bf93e1d8 + @ changeset: 25:05d1bf93e1d8 | tag: tip | topic: changewut | parent: 23:1f668635e0c2 @@ -763,17 +755,3 @@ | date: Thu Jan 01 00:00:00 1970 +0000 | summary: start on fran | - | @ changeset: 22:373f490f8854 - | | topic: changewat - | | parent: 20:a96ac830b62e - | | user: test - | | date: Thu Jan 01 00:00:00 1970 +0000 - | | summary: gamma - | | - | x changeset: 20:a96ac830b62e - |/ topic: changewat - | parent: 3:a53952faf762 - | user: test - | date: Thu Jan 01 00:00:00 1970 +0000 - | summary: start on fran - |