# HG changeset patch # User Anton Shestakov # Date 1513949146 -28800 # Node ID 4c7ae95e1c714c6e35795fab4a8d2d6e31764b8c # Parent 1721ce06100a307dab2da055e96a9b3d855f90f8 hgweb: link to successors of obsoleted changesets _siblings() prepare various useful properties to use in templates. This function usually prepares parents and children of changesets for use in hgweb templates, but it can be used for successors too. It's needed because item['successors'] is a _hybrid object that works well when used in regular templates, but in hgweb templates work slightly differently and can't get hex nodes of the successors, which are required for these links to work. diff -r 1721ce06100a -r 4c7ae95e1c71 mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Tue Nov 21 17:03:41 2017 +0800 +++ b/mercurial/hgweb/webutil.py Fri Dec 22 21:25:46 2017 +0800 @@ -353,7 +353,10 @@ return '%d:%d' % (fromline + 1, toline) def succsandmarkers(repo, ctx): - return templatekw.showsuccsandmarkers(repo, ctx) + for item in templatekw.showsuccsandmarkers(repo, ctx): + item['successors'] = _siblings(repo[successor] + for successor in item['successors']) + yield item def commonentry(repo, ctx): node = ctx.node() diff -r 1721ce06100a -r 4c7ae95e1c71 mercurial/templates/gitweb/map --- a/mercurial/templates/gitweb/map Tue Nov 21 17:03:41 2017 +0800 +++ b/mercurial/templates/gitweb/map Fri Dec 22 21:25:46 2017 +0800 @@ -271,7 +271,8 @@ inbranchtag = '{name|escape} ' bookmarktag = '{name|escape} ' alltags = '{phasetag}{obsoletetag}{instabilities%instabilitytag}{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag}' -obsfatesuccessors = '{if(successors, ' as ')}{join(successors, ', ')}' +successorlink = '{node|short} ' +obsfatesuccessors = '{if(successors, ' as ')}{successors%successorlink}' obsfateverb = '{obsfateverb(successors, markers)}' obsfateoperations = '{if(obsfateoperations(markers), ' using {join(obsfateoperations(markers), ', ')}')}' obsfateentry = '{obsfateverb}{obsfateoperations}{obsfatesuccessors}' diff -r 1721ce06100a -r 4c7ae95e1c71 mercurial/templates/monoblue/map --- a/mercurial/templates/monoblue/map Tue Nov 21 17:03:41 2017 +0800 +++ b/mercurial/templates/monoblue/map Fri Dec 22 21:25:46 2017 +0800 @@ -229,7 +229,8 @@ inbranchtag = '{name|escape} ' bookmarktag = '{name|escape} ' alltags = '{phasetag}{obsoletetag}{instabilities%instabilitytag}{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag}' -obsfatesuccessors = '{if(successors, ' as ')}{join(successors, ', ')}' +successorlink = '{node|short} ' +obsfatesuccessors = '{if(successors, ' as ')}{successors%successorlink}' obsfateverb = '{obsfateverb(successors, markers)}' obsfateoperations = '{if(obsfateoperations(markers), ' using {join(obsfateoperations(markers), ', ')}')}' obsfateentry = '{obsfateverb}{obsfateoperations}{obsfatesuccessors}' diff -r 1721ce06100a -r 4c7ae95e1c71 mercurial/templates/paper/map --- a/mercurial/templates/paper/map Tue Nov 21 17:03:41 2017 +0800 +++ b/mercurial/templates/paper/map Fri Dec 22 21:25:46 2017 +0800 @@ -209,7 +209,8 @@ changelogbranchname = '{name|escape} ' alltags = '{phasetag}{obsoletetag}{instabilities%instabilitytag}{inbranch%changelogbranchname}{branches%changelogbranchhead}{tags%changelogtag}{bookmarks%changelogtag}' -obsfatesuccessors = '{if(successors, ' as ')}{join(successors, ', ')}' +successorlink = '{node|short} ' +obsfatesuccessors = '{if(successors, ' as ')}{successors%successorlink}' obsfateverb = '{obsfateverb(successors, markers)}' obsfateoperations = '{if(obsfateoperations(markers), ' using {join(obsfateoperations(markers), ', ')}')}' obsfateentry = '{obsfateverb}{obsfateoperations}{obsfatesuccessors}' diff -r 1721ce06100a -r 4c7ae95e1c71 mercurial/templates/spartan/map --- a/mercurial/templates/spartan/map Tue Nov 21 17:03:41 2017 +0800 +++ b/mercurial/templates/spartan/map Fri Dec 22 21:25:46 2017 +0800 @@ -166,7 +166,8 @@ diffblock = '
{lines}
' changelogtag = 'tag:{tag|escape}' changesettag = 'tag:{tag|escape}' -obsfatesuccessors = '{if(successors, ' as ')}{join(successors, ', ')}' +successorlink = '{node|short} ' +obsfatesuccessors = '{if(successors, ' as ')}{successors%successorlink}' obsfateverb = '{obsfateverb(successors, markers)}' obsfateoperations = '{if(obsfateoperations(markers), ' using {join(obsfateoperations(markers), ', ')}')}' obsfateentry = '{obsfateverb}{obsfateoperations}{obsfatesuccessors}' diff -r 1721ce06100a -r 4c7ae95e1c71 tests/test-obsolete.t --- a/tests/test-obsolete.t Tue Nov 21 17:03:41 2017 +0800 +++ b/tests/test-obsolete.t Fri Dec 22 21:25:46 2017 +0800 @@ -1036,15 +1036,15 @@ check an obsolete changeset that has been rewritten $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=paper' | grep rewritten - rewritten as 6:3de5eca88c00 + rewritten as 3de5eca88c00 $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=coal' | grep rewritten - rewritten as 6:3de5eca88c00 + rewritten as 3de5eca88c00 $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=gitweb' | grep rewritten - obsoleterewritten as 6:3de5eca88c00 + obsoleterewritten as 3de5eca88c00 $ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=monoblue' | grep rewritten -
obsolete
rewritten as 6:3de5eca88c00
+
obsolete
rewritten as 3de5eca88c00
$ get-with-headers.py localhost:$HGPORT 'rev/cda648ca50f5?style=spartan' | grep rewritten - rewritten as 6:3de5eca88c00 + rewritten as 3de5eca88c00 check changeset with instabilities