Software /
code /
prosody
Annotate
util/mercurial.lua @ 8791:8da11142fabf
muc: Allow clients to change multiple affiliations or roles at once (#345)
According to XEP-0045 sections 9.2, 9.5 and 9.8 affiliation lists and role
lists should allow mass-modification. Prosody however would just use the
first entry of the list and ignore the rest. This is fixed by introducing
a `for` loop to `set` stanzas of the respective `muc#admin` namespace.
In order for this loop to work, the error handling was changed a little.
Prosody no longer returns after the first error. Instead, an error reply
is sent for each malformed or otherwise wrong entry, but the loop keeps
going over the other entries. This may lead to multiple error messages
being sent for one client request. A notable exception from this is when
the XML Schema for `muc#admin` requests is violated. In that case the loop
is aborted with an error message to the client.
The change is a bit bigger than that in order to have the loop only for
`set` stanzas without changing the behaviour of the `get` stanzas. This is
now more in line with trunk, where there are separate methods for each
stanza type.
References: #345
author | Lennart Sauerbeck <devel@lennart.sauerbeck.org> |
---|---|
date | Sat, 18 Mar 2017 18:47:28 +0100 |
parent | 6585:ec94dc502113 |
child | 10533:a6cc5b844d7b |
rev | line source |
---|---|
6585
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 local lfs = require"lfs"; |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local hg = { }; |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 function hg.check_id(path) |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 if lfs.attributes(path, 'mode') ~= "directory" then |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 return nil, "not a directory"; |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 end |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local hg_dirstate = io.open(path.."/.hg/dirstate"); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 local hgid, hgrepo |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 if hg_dirstate then |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 hgid = ("%02x%02x%02x%02x%02x%02x"):format(hg_dirstate:read(6):byte(1, 6)); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 hg_dirstate:close(); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 local hg_changelog = io.open(path.."/.hg/store/00changelog.i"); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 if hg_changelog then |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 hg_changelog:seek("set", 0x20); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 hgrepo = ("%02x%02x%02x%02x%02x%02x"):format(hg_changelog:read(6):byte(1, 6)); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 hg_changelog:close(); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 end |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 else |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 local hg_archival,e = io.open(path.."/.hg_archival.txt"); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 if hg_archival then |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 local repo = hg_archival:read("*l"); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 local node = hg_archival:read("*l"); |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 hg_archival:close() |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 hgid = node and node:match("^node: (%x%x%x%x%x%x%x%x%x%x%x%x)") |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 hgrepo = repo and repo:match("^repo: (%x%x%x%x%x%x%x%x%x%x%x%x)") |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 end |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 return hgid, hgrepo; |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 end |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 |
ec94dc502113
util.mercurial: Utility functions for Mercurial repositories
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 return hg; |