--- a/hgext/pushlog-legacy/pushlog-feed.py
+++ b/hgext/pushlog-legacy/pushlog-feed.py
@@ -13,16 +13,17 @@ from mercurial.hgweb.common import (
ErrorResponse,
HTTP_OK,
paritygen,
)
from mercurial.node import hex, nullid
from mercurial import (
demandimport,
error,
+ obsolete,
templatefilters,
)
sys.path.append(os.path.dirname(__file__))
with demandimport.deactivated():
from parsedatetime import parsedatetime as pdt
@@ -475,48 +476,63 @@ def pushlogHTML(web, req, tmpl):
startdate='startdate' in req.form and req.form['startdate'][0] or '1 week ago',
enddate='enddate' in req.form and req.form['enddate'][0] or 'now',
querydescription=query.description(),
archives=web.archivelist("tip"))
def pushes_worker(query, repo, full):
"""Given a PushlogQuery, return a data structure mapping push IDs
to a map of data about the push."""
+ haveobs = bool(repo.obsstore)
pushes = {}
for id, user, date, node in query.entries:
id = str(id)
# Create the pushes entry first. It is OK to have empty
# pushes if nodes from the pushlog no longer exist.
if id not in pushes:
pushes[id] = {
'user': user,
'date': date,
'changesets': [],
}
try:
ctx = repo[node]
+ nodekey = 'changesets'
# Changeset is hidden
except error.FilteredRepoLookupError:
- continue
+ # Try to find the hidden changeset so its metadata can be used.
+ try:
+ ctx = repo.unfiltered()[node]
+ except error.LookupError:
+ continue
+
+ nodekey = 'obsoletechangesets'
if full:
node = {
'node': ctx.hex(),
'author': ctx.user(),
'desc': ctx.description(),
'branch': ctx.branch(),
'parents': [c.hex() for c in ctx.parents()],
'tags': ctx.tags(),
'files': ctx.files()
}
+ # Only expose obsolescence metadata if the repo has some.
+ if haveobs:
+ precursors = obsolete.precursormarkers(ctx)
+ precursors = [hex(m.precnode()) for m in precursors]
+ if precursors:
+ node['precursors'] = precursors
+
# we get the pushes in reverse order
- pushes[id]['changesets'].insert(0, node)
+ pushes[id].setdefault(nodekey, []).insert(0, node)
return {'pushes': pushes, 'lastpushid': query.lastpushid}
def pushes(web, req, tmpl):
"""WebCommand to return a data structure containing pushes."""
query = pushlogSetup(web.repo, req)
data = pushes_worker(query, web.repo, 'full' in req.form)
--- a/hgext/pushlog-legacy/tests/test-obsolescence.t
+++ b/hgext/pushlog-legacy/tests/test-obsolescence.t
@@ -60,31 +60,35 @@
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 0 changes to 2 files
recorded push in pushlog
2 new obsolescence markers
-FIXME Hidden changesets should not be exposed to version 1
+Hidden changesets exposed as list under obsoletechangesets in version 1
$ httpjson "http://localhost:$HGPORT/json-pushes?version=1"
200
{
"1": {
"changesets": [
"96ee1d7354c4ad7372047672c36a1f561e3a6a4c"
],
"date": \d+, (re)
"user": "user@example.com"
},
"2": {
"changesets": [],
"date": \d+, (re)
+ "obsoletechangesets": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736",
+ "d313a202a85e114000f669c2fcb49ad42376ac04"
+ ],
"user": "user@example.com"
},
"3": {
"changesets": [
"b3641753ee63b166fad7c5f10060b0cbbc8a86b0",
"62eebb2f0f00195f9d965f718090c678c4fa414d"
],
"date": \d+, (re)
@@ -95,16 +99,18 @@ FIXME Hidden changesets should not be ex
"418a63f508062fb2eb9130065c5ddc7908dd5949",
"d129109168f0ed985e51b0f86df256acdcfcfe45"
],
"date": \d+, (re)
"user": "user@example.com"
}
}
+obsolete changeset metadata exposed under full with version 1
+
$ httpjson "http://localhost:$HGPORT/json-pushes?version=1&full=1"
200
{
"1": {
"changesets": [
{
"author": "test",
"branch": "default",
@@ -120,16 +126,44 @@ FIXME Hidden changesets should not be ex
}
],
"date": \d+, (re)
"user": "user@example.com"
},
"2": {
"changesets": [],
"date": \d+, (re)
+ "obsoletechangesets": [
+ {
+ "author": "test",
+ "branch": "default",
+ "desc": "file0",
+ "files": [
+ "file0"
+ ],
+ "node": "ae13d9da6966307c98b60987fb4fedc2e2f29736",
+ "parents": [
+ "96ee1d7354c4ad7372047672c36a1f561e3a6a4c"
+ ],
+ "tags": []
+ },
+ {
+ "author": "test",
+ "branch": "default",
+ "desc": "file1",
+ "files": [
+ "file1"
+ ],
+ "node": "d313a202a85e114000f669c2fcb49ad42376ac04",
+ "parents": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736"
+ ],
+ "tags": []
+ }
+ ],
"user": "user@example.com"
},
"3": {
"changesets": [
{
"author": "test",
"branch": "default",
"desc": "file2",
@@ -167,56 +201,66 @@ FIXME Hidden changesets should not be ex
"desc": "file0",
"files": [
"file0"
],
"node": "418a63f508062fb2eb9130065c5ddc7908dd5949",
"parents": [
"62eebb2f0f00195f9d965f718090c678c4fa414d"
],
+ "precursors": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736"
+ ],
"tags": []
},
{
"author": "test",
"branch": "default",
"desc": "file1",
"files": [
"file1"
],
"node": "d129109168f0ed985e51b0f86df256acdcfcfe45",
"parents": [
"418a63f508062fb2eb9130065c5ddc7908dd5949"
],
+ "precursors": [
+ "d313a202a85e114000f669c2fcb49ad42376ac04"
+ ],
"tags": [
"tip"
]
}
],
"date": \d+, (re)
"user": "user@example.com"
}
}
-FIXME Hidden changesets should not be exposed to version 2
+Hidden changesets exposed as list with version 2
$ httpjson "http://localhost:$HGPORT/json-pushes?version=2"
200
{
"lastpushid": 4,
"pushes": {
"1": {
"changesets": [
"96ee1d7354c4ad7372047672c36a1f561e3a6a4c"
],
"date": \d+, (re)
"user": "user@example.com"
},
"2": {
"changesets": [],
"date": \d+, (re)
+ "obsoletechangesets": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736",
+ "d313a202a85e114000f669c2fcb49ad42376ac04"
+ ],
"user": "user@example.com"
},
"3": {
"changesets": [
"b3641753ee63b166fad7c5f10060b0cbbc8a86b0",
"62eebb2f0f00195f9d965f718090c678c4fa414d"
],
"date": \d+, (re)
@@ -228,16 +272,18 @@ FIXME Hidden changesets should not be ex
"d129109168f0ed985e51b0f86df256acdcfcfe45"
],
"date": \d+, (re)
"user": "user@example.com"
}
}
}
+Hidden changeset metadata exposed under version 2 with full
+
$ httpjson "http://localhost:$HGPORT/json-pushes?version=2&full=1"
200
{
"lastpushid": 4,
"pushes": {
"1": {
"changesets": [
{
@@ -255,16 +301,44 @@ FIXME Hidden changesets should not be ex
}
],
"date": \d+, (re)
"user": "user@example.com"
},
"2": {
"changesets": [],
"date": \d+, (re)
+ "obsoletechangesets": [
+ {
+ "author": "test",
+ "branch": "default",
+ "desc": "file0",
+ "files": [
+ "file0"
+ ],
+ "node": "ae13d9da6966307c98b60987fb4fedc2e2f29736",
+ "parents": [
+ "96ee1d7354c4ad7372047672c36a1f561e3a6a4c"
+ ],
+ "tags": []
+ },
+ {
+ "author": "test",
+ "branch": "default",
+ "desc": "file1",
+ "files": [
+ "file1"
+ ],
+ "node": "d313a202a85e114000f669c2fcb49ad42376ac04",
+ "parents": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736"
+ ],
+ "tags": []
+ }
+ ],
"user": "user@example.com"
},
"3": {
"changesets": [
{
"author": "test",
"branch": "default",
"desc": "file2",
@@ -302,41 +376,47 @@ FIXME Hidden changesets should not be ex
"desc": "file0",
"files": [
"file0"
],
"node": "418a63f508062fb2eb9130065c5ddc7908dd5949",
"parents": [
"62eebb2f0f00195f9d965f718090c678c4fa414d"
],
+ "precursors": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736"
+ ],
"tags": []
},
{
"author": "test",
"branch": "default",
"desc": "file1",
"files": [
"file1"
],
"node": "d129109168f0ed985e51b0f86df256acdcfcfe45",
"parents": [
"418a63f508062fb2eb9130065c5ddc7908dd5949"
],
+ "precursors": [
+ "d313a202a85e114000f669c2fcb49ad42376ac04"
+ ],
"tags": [
"tip"
]
}
],
"date": \d+, (re)
"user": "user@example.com"
}
}
}
-FIXME Hidden changesets handled properly on feed
+Hidden changesets dropped in feed
$ http --no-headers "http://localhost:$HGPORT/atom-pushlog"
200
<?xml version="1.0" encoding="ascii"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>http://*:$HGPORT/pushlog</id> (glob)
<link rel="self" href="http://*:$HGPORT/pushlog"/> (glob)
@@ -511,29 +591,35 @@ Specifying a fromchange with a hidden ch
"desc": "file0",
"files": [
"file0"
],
"node": "418a63f508062fb2eb9130065c5ddc7908dd5949",
"parents": [
"62eebb2f0f00195f9d965f718090c678c4fa414d"
],
+ "precursors": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736"
+ ],
"tags": []
},
{
"author": "test",
"branch": "default",
"desc": "file1",
"files": [
"file1"
],
"node": "d129109168f0ed985e51b0f86df256acdcfcfe45",
"parents": [
"418a63f508062fb2eb9130065c5ddc7908dd5949"
],
+ "precursors": [
+ "d313a202a85e114000f669c2fcb49ad42376ac04"
+ ],
"tags": [
"tip"
]
}
],
"date": \d+, (re)
"user": "user@example.com"
}
@@ -542,43 +628,107 @@ Specifying a fromchange with a hidden ch
Specifying a tochange with a hidden changeset works
$ httpjson "http://localhost:$HGPORT/json-pushes?startID=1&tochange=ae13d9da6966"
200
{
"2": {
"changesets": [],
"date": \d+, (re)
+ "obsoletechangesets": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736",
+ "d313a202a85e114000f669c2fcb49ad42376ac04"
+ ],
"user": "user@example.com"
}
}
$ httpjson "http://localhost:$HGPORT/json-pushes?startID=1&tochange=ae13d9da6966&full=1"
200
{
"2": {
"changesets": [],
"date": \d+, (re)
+ "obsoletechangesets": [
+ {
+ "author": "test",
+ "branch": "default",
+ "desc": "file0",
+ "files": [
+ "file0"
+ ],
+ "node": "ae13d9da6966307c98b60987fb4fedc2e2f29736",
+ "parents": [
+ "96ee1d7354c4ad7372047672c36a1f561e3a6a4c"
+ ],
+ "tags": []
+ },
+ {
+ "author": "test",
+ "branch": "default",
+ "desc": "file1",
+ "files": [
+ "file1"
+ ],
+ "node": "d313a202a85e114000f669c2fcb49ad42376ac04",
+ "parents": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736"
+ ],
+ "tags": []
+ }
+ ],
"user": "user@example.com"
}
}
Specifying a hidden changeset works
$ httpjson "http://localhost:$HGPORT/json-pushes?changeset=ae13d9da6966"
200
{
"2": {
"changesets": [],
"date": \d+, (re)
+ "obsoletechangesets": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736",
+ "d313a202a85e114000f669c2fcb49ad42376ac04"
+ ],
"user": "user@example.com"
}
}
$ httpjson "http://localhost:$HGPORT/json-pushes?changeset=ae13d9da6966&full=1"
200
{
"2": {
"changesets": [],
"date": \d+, (re)
+ "obsoletechangesets": [
+ {
+ "author": "test",
+ "branch": "default",
+ "desc": "file0",
+ "files": [
+ "file0"
+ ],
+ "node": "ae13d9da6966307c98b60987fb4fedc2e2f29736",
+ "parents": [
+ "96ee1d7354c4ad7372047672c36a1f561e3a6a4c"
+ ],
+ "tags": []
+ },
+ {
+ "author": "test",
+ "branch": "default",
+ "desc": "file1",
+ "files": [
+ "file1"
+ ],
+ "node": "d313a202a85e114000f669c2fcb49ad42376ac04",
+ "parents": [
+ "ae13d9da6966307c98b60987fb4fedc2e2f29736"
+ ],
+ "tags": []
+ }
+ ],
"user": "user@example.com"
}
}