Commit Graph

1959 Commits

Author SHA1 Message Date
Jun Wu
d1076977f0 phabricator: add --amend option to phabsend
Previously `hg phabsend` was imitating `hg email` and won't mutate
changesets. That works fine with reviewer-push workflow, reviewers run
`phabread`, `import`.

However, it does not work well with author-push workflow. Namely, the author
needs to run extra commands to get the right commit message, and remove the
local tag after push.

This patch solves those issues by adding the `--amend` option, so local
changesets will have the right commit message, and tags become unnecessary.

Test Plan:
Given the following DAG:

  o  17
  o  16
  | o  15
  | @  14
  |/
  o  13
  o  12

Run `hg phabsend '(13::)-17'  --amend`, check the new DAG looks like:


  o  21
  | o  20
  | @  19
  |/
  o  18
  | o  17
  | x  16
  | x  13
  |/
  o  12

And commit messages are updated to contain the `Differential Revision` lines.
Use `phabread` to make sure Phabricator has the amended node recorded.

Also check `phabsend .` followed by a `phabsend . --amend`, the commit
message will be updated and the tag will be removed.

Differential Revision: https://phab.mercurial-scm.org/D122
2017-08-04 12:39:29 -07:00
Jun Wu
618efa1b1e phabricator: remove an unnecessary writediffproperties call
This was introduced by D229. Thanks Yuya for finding it!

Differential Revision: https://phab.mercurial-scm.org/D366
2017-08-12 21:40:48 -07:00
Augie Fackler
9a0febea27 merge with stable 2017-08-10 14:23:41 -04:00
Mathias De Maré
cafe7e372c chg: define _GNU_SOURCE to allow CentOS 5 compilation
Without this flag, compilation fails with:
 hgclient.c: In function 'hgc_open':
 hgclient.c:466: error: 'O_DIRECTORY' undeclared (first use in this function)
 hgclient.c:466: error: (Each undeclared identifier is reported only once
 hgclient.c:466: error: for each function it appears in.)

Differential Revision: https://phab.mercurial-scm.org/D260
2017-08-07 13:40:36 +02:00
Mathias De Maré
744ba88ca3 centos5: use vault urls
CentOS 5 has reached end-of-life. A working build for it is still
possible using 'vault.centos.org'.

Differential Revision: https://phab.mercurial-scm.org/D261
2017-08-07 13:38:25 +02:00
Boris Feld
d88d8d1c9e obsutil: rename allprecursors into allpredecessors
Use util.nouideprecwarn because obsstore doesn't have easy access to an ui
object.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D247
2017-08-02 19:49:57 +02:00
Jun Wu
51be9cd3a9 phabricator: convert unicode to binary when writing patches
This is a quick fix to make `hg phabread D189` work.

It seems we might want to replace all `r''` to `u''`, and add more
`encoding.*to*` to be more explicit when interacting with `json` module.

Differential Revision: https://phab.mercurial-scm.org/D192
2017-07-27 12:03:01 -07:00
Mathias De Maré
1ebe02c078 docker: pass proxy arguments to docker process
Building in Docker when behind a proxy requires passing the proxy variables.

Differential Revision: https://phab.mercurial-scm.org/D190
2017-07-27 13:44:15 +02:00
Mathias De Maré
30343f1379 makefile: build on CentOS 6 with a Python 2.7
Differential Revision: https://phab.mercurial-scm.org/D189
2017-07-27 14:15:26 +02:00
Augie Fackler
437f1cb3c5 osx: new script for generating OS X package versions
If you're shipping prerelease or rc packages using Munki, you'll
eventually discover that Munki's version comparison logic is not as
good as pip's. In theory we should be able to fix Munki, but it seems
entirely reasonable to produce version strings that sort reasonably
under these conditions. Since the requried logic not brief, add a new
script and some tests of that logic.

A followup change will wire this into the Makefile.
2017-07-24 20:38:09 -04:00
Augie Fackler
7dc97f30ea contrib: remove one test from the python 3 whitelist
5ba3f753c9b1 introduced a use of 'hg revert --no-backup' which is
currently broken. Rather than try and do a fix on the (complicated)
revert code during the freeze, let's just give up on this test under
Python 3 until later. Once we do fix things, the test ratchet script
will re-enable it.
2017-07-24 15:37:57 -04:00
Steve Borho
4981c8f4c5 wix: update list of necessary pyd files 2017-07-21 11:26:51 -05:00
Augie Fackler
bb89feb159 contrib: drop Python 2.6 from manylinux1 wheel script 2017-07-19 13:44:22 -04:00
Augie Fackler
60b506ed63 contrib: make build-linux-wheels.sh executable 2017-07-19 13:45:06 -04:00
Ryan McElroy
5a6e1ad8d5 check-config: mention the file and line of the error
I used this to more quickly track down a failing test-check-config.t issue
in another repo. I thought it might be useful more generally, so I'm sending
it out in case others think it's a worthwhile change.
2017-07-18 06:27:36 -07:00
Jun Wu
1b3b693903 phabricator: sanity check Differential Revision from commit message
Previously, we trust Differential Revision in commit message blindly. This
patch adds sanity check so a host name change will be detected and the
commit message will be ignored.

Differential Revision: https://phab.mercurial-scm.org/D35
2017-07-10 18:02:03 -07:00
Jun Wu
df71cf23ed phabricator: update diff property even if we choose not to create a new diff
The diff property contains metadata like "HG Node". Previously we skip
uploading a new diff if we are sure that the old patch and new patch have a
same content. That has issues when a pusher adds an obsmarker using the old
"HG Node" stored in the old diff.

This patch adds logic to update the diff property so "HG Node" gets updated
to prevent that issue.

Differential Revision: https://phab.mercurial-scm.org/D229
2017-08-04 12:21:23 -07:00
Jun Wu
2ad9b414be phabricator: use Phabricator's last node information
This makes it more strict when checking whether or not we should update a
Differential Revision. For example,

  a) Alice updates D1 to content 1.
  b) Bob updates D1 to content 2.
  c) Alice tries to update D1 to content 1.

Previously, `c)` will do nothing because `phabsend` detects the patch is not
changed. A more correct behavior is to override Bob's update here, hence the
patch.

This also makes it possible to return a reaonsable "last node" when there is
no tags but only `Differential Revision` commit messages.

Test Plan:
```
for i in A B C; do echo $i > $i; hg ci -m $i -A $i; done

hg phabsend 0::
# D40: created
# D41: created
# D42: created

echo 3 >> C; hg amend; hg phabsend .
# D42: updated

hg tag --local --hidden -r 2 -f D42
# move tag to the previous version

hg phabsend .
# D42: skipped (previously it would be "updated")

rm -rf .hg; hg init
hg phabread --stack D42 | hg import -
hg phabsend .
# D42: updated
hg tag --local --remove D42
hg commit --amend
hg phabsend .
# D42: updated (no new diff uploaded, previously it will upload a new diff)
```

The old diff object is now returned, which could be useful in the next
patch.

Differential Revision: https://phab.mercurial-scm.org/D121
2017-07-17 19:52:50 -07:00
Pulkit Goyal
b33128fe07 phabricator: add --confirm option to phabsend command
This adds a --confirm flag similar to the confirm flag of `hg email` using which
one can confirm the changesets before they get emailed. The confirm flag will
show the changesets and ask for confirmation before sending them.

Differential Revision: https://phab.mercurial-scm.org/D218
2017-08-03 03:09:33 +05:30
muxator
ea278f9b31 buildrpm: do not break in presence of custom user configs
For example, if "hg log" was defined as an alias:

  # /etc/mercurial/hgrc
  [alias]
  log = log --graph

the buildrpm script would be surprised by log messages formatted in
unexpected ways, and bail out.

This patch sets HGPLAIN, effectively resetting all the user configs,
including log output, to a common state, making the build more
predictable across all the possible environments.
2017-08-04 08:15:10 +02:00
Mathias De Maré
e2b0d060dd rpms: add chg
I'm not sure if there's a reason chg is not added by default.
If not, I would like to propose adding in this patch.

Differential Revision: https://phab.mercurial-scm.org/D220
2017-07-27 16:09:26 +02:00
Jun Wu
8847ceeedf phabricator: allow specifying reviewers on phabsend
Sometimes people want to specify reviewer explicitly for a stack. The
webpage only allows changing reviewer for one revision at a time. This patch
adds a `--reviewer` flag to make it easier to specify reviewers.

Test Plan:
On a test Phabricator instance, enable `differential.allow-self-accept`,
assign myself as a reviewer and make sure it works. Also try an invalid
username and make sure it raises.

Differential Revision: https://phab.mercurial-scm.org/D38
2017-07-11 08:52:55 -07:00
Jun Wu
1823368531 phabricator: verify local tags before trusting them
Previously we trust local tags blindly and that could cause wrong
Differential Revision to be updated, when people switch between Phabricator
instances.

This patch adds verification logic to detect such issue and remove
problematic tags. For example, a tag "D19" was on node "X", the code will
fetch all diffs attached to D19, and check if nodes server-side overlaps
with nodes in precursors. If they do not overlap, create a new Differential
Revision.

Test Plan:
Use a test Phabricator instance, send patches using `hg phabsend`, then
change the local tag manually to a wrong Differential Revision number.
Amend the patch and send again. Make sure the tag gets ignored and deleted.

Differential Revision: https://phab.mercurial-scm.org/D36
2017-07-11 08:17:29 -07:00
Jun Wu
44e64fc8ff phabricator: finding old nodes in batch
This allows us to do extra sanity checks using batch APIs to prevent
updating a wrong revision, which could happen when people switch Phabricator
instances and having stale tags living in the repo.

Differential Revision: https://phab.mercurial-scm.org/D34
2017-07-10 13:50:50 -07:00
Jun Wu
09b591871f phabricator: respect metadata sent by arc
Previously we only respect hg:meta sent by phabsend. This patch makes it
respect local:commits sent by arc as well. This avoids issues where phabread
could lose the author information.

Test Plan:
Commit using a customized user, send the patch using arc to a test
Phabricator instance, and then read the patch using phabread. Make sure it
preserves the user information.

Differential Revision: https://phab.mercurial-scm.org/D33
2017-07-10 22:37:33 -07:00
Martin von Zweigbergk
dde7459563 util: remove unused ctxmanager
This was meant as a substitute for Python's "with" with multiple
context managers before we moved to Python 2.7. We're now on 2.7, so
we should have no reason to keep ctxmanager. "hg grep --all
ctxmanager" says that it was never used anyway.

Differential Revision: https://phab.mercurial-scm.org/D73
2017-07-13 09:51:50 -07:00
Martin Tietze
36d2e1297d zsh_completion: add '--partial' flag to completions for 'import' (issue5618)
When using the 'import' command running ZSH together with its
Mercurial-specific completions the flag '--partial' (introduced in Mercurial
3.1, 2014-08-01) is not offered as completion option.

This patch adds it to the list of completions for the 'import' command.
2017-07-12 10:11:02 +02:00
Augie Fackler
a8e43e5637 check-code: prohibit if False antipattern
Differential Revision: https://phab.mercurial-scm.org/D20
2017-07-07 15:11:11 -04:00
Boris Feld
1a97ccb186 py3: fix test-diff-newlines.t to be compatible with py3 2017-07-06 17:18:50 +02:00
Augie Fackler
04ece00541 contrib: widen "direct use of python" net again
I think I've now caught all of them.

Differential Revision: https://phab.mercurial-scm.org/D15
2017-07-06 15:15:02 -04:00
Augie Fackler
dc6a89d633 contrib: widen the "don't use python" net a little
I'm still cleaning this up, but it's easier to do in bite-size chunks
like this than all at once. The negative lookahead avoids one false
positive category from some output related to finding Subversion
bindings.

Differential Revision: https://phab.mercurial-scm.org/D13
2017-06-20 17:25:57 -04:00
Jun Wu
2890013afc phabricator: do not read a same revision twice
It's possible to set up non-linear dependencies in Phabricator like:

  o   D4
  |\
  | o D3
  | |
  o | D2
  |/
  o   D1

The old `phabread` code will print D1 twice. This patch adds de-duplication
to prevent that.

Test Plan:
Construct the above dependencies in a Phabricator test instance and make
sure the old code prints D1 twice while the new code won't.
2017-07-04 18:52:28 -07:00
Jun Wu
9875746351 phabricator: try to fetch differential revisions in batch
Previously, we read Differential Revisions one by one by calling
`differential.query`.

Fetching them one by one is suboptimal. Unfortunately, there is no Conduit
API that allows us to get a stack of diffids using a single API call.

This patch tries to be smarter using a simple heuristic: when fetching D59
as a stack, previous IDs like D51, D52, D53, ..., D58 are likely belonging
to a same stack so just fetch them as well. Since `differential.query` only
returns cheap metadata without expensive diff content, it shouldn't be a big
problem for the server.

Using a test Phabricator instance, this patch reduces `phabread` reading a
10 patch stack from about 13 to 30 seconds to 8 seconds.
2017-07-04 16:36:48 -07:00
Jun Wu
9861854a47 phabricator: avoid calling differential.getcommitmessage
Previously, we call differential.getcommitmessage API to get commit
messages. Now we read that from "Differential Revision" object fetched
via "differential.query" API.

This removes one API call per patch.
2017-07-04 16:36:48 -07:00
Jun Wu
50febc4089 phabricator: rework phabread to reduce memory usage and round-trips
This patch reworked phabread a bit so it fetches the lightweight
"Differential Revision" metadata for a stack first. Then read other data.

This allows the code to:

  a) send 1 request to get all `hg:meta` data instead of N requests
  b) patches are read in desired order, no need to buffer the output

"b)" reduces the memory usage from O(N^2) to O(N) since we no longer keep
old patch contents in memory.

The above `N` means the number of patches in the stack.
2017-07-04 16:36:48 -07:00
Jun Wu
a235d789ac phabricator: abort if phabsend gets empty revs
Previously we didn't abort. Now we abort if revs is empty. This is
consistent with "hg export" behavior. Maybe "return 1" is also a reasonable
behavior, but that's inconsistent with the existing "hg export".
2017-07-04 16:36:48 -07:00
Jun Wu
a51d956bfc phabricator: do not upload new diff if nothing changes
Previously, `phabsend` uploads new diffs as long as the commit hash changes.
That's suboptimal because sometimes the diff is exactly the same as before,
the commit hash change is caused by a parent hash change, or commit message
change which do not affect diff content.

This patch adds a check examining actual diff contents to skip uploading new
diffs in that case.
2017-07-04 16:36:48 -07:00
Jun Wu
c59faa75e3 phabricator: add node and p1 to hg:meta property
The "hg:meta" property is for extra metadata to reconstruct the patch.
Previously it does not have node or parent information since I think by
reading the patch again, the commit message will be mangled (like, added the
"Differential Revision" line) and we cannot preserve the commit hash.

However, the "parent" information could be useful. It could be helpful to
locate the "base revision" so in case of a conflict applying the patch
directly, we might be able to use 3-way merge to resolve it correctly.

Note: "local:commits" is an existing "property" used by Phabricator that has
the node and parent information. However, it lacks of timezone information
and requires "author" and "authorEmail" to be separated. So we are using a
different "property" - "hg:meta" to be distinguished from "local:commits".
2017-07-04 16:36:48 -07:00
Jun Wu
8f56c847bd phabricator: check associated Differential Revision from commit message
Previously, only tags can "associate" a changeset to a Differential
Revision. But the usual pattern (arc patch or hg phabread) is to put the
Differential Revision URL in commit message.

This patch makes the code read commit message to find associated
Differential Revision if associated tags are not found.

This makes some workflows possible. For example, if the author loses their
repo, or switch to another computer, they can continue download their own
patches from Phabricator and update them without needing to manually create
tags.
2017-07-04 16:16:37 -07:00
Jun Wu
a28591d46c phabricator: add phabread command to read patches
This patch adds a `phabread` command generating plain-text patches from
Phabricator, suitable for `hg import`. It respects `hg:meta` so user and
date information might be preserved. And it removes `Summary:` field name
which makes the commit message a bit tidier.

To support stacked diffs, a `--stack` flag was added to read dependent
patches recursively.
2017-07-02 20:08:09 -07:00
Jun Wu
a7bae1992d phabricator: add phabsend command to send a stack
The `phabsend` command is intended to provide `hg email`-like experience -
sending a stack, setup dependency information and do not amend existing
changesets.

It uses differential.createrawdiff and differential.revision.edit Conduit
API to create or update a Differential Revision.

Local tags like `D123` are written indicating certain changesets were sent
to Phabricator. The `phabsend` command will use obsstore and tags
information to decide whether to update or create Differential Revisions.
2017-07-02 20:08:09 -07:00
Jun Wu
5a4f85c0c1 phabricator: add a contrib script
The default Phabricator client arcanist is not friendly to send a stack of
changesets. It works better when a feature branch is reviewed as a single
review unit. However, we want multiple revisions per feature branch.

To be able to have an `hg email`-like UX to send and receive a stack of
commits easily, it seems we have to re-invent things. This patch adds
`phabricator.py` speaking Conduit API [1] in `contrib` as the first step.
This may also be an option for people who don't want to run PHP.

Config could be done in `hgrc` (instead of `arcrc` or `arcconfig`):

    [phabricator]
    # API token. Get it from https://phab.mercurial-scm.org/conduit/login/
    token = cli-xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    url = https://phab.mercurial-scm.org/
    # callsign is used by the next patch
    callsign = HG

This patch only adds a single command: `debugcallconduit` to keep the patch
size small. To test it, having the above config, and run:

    $ hg debugcallconduit diffusion.repository.search <<EOF
    > {"constraints": {"callsigns": ["HG"]}}
    > EOF

The result will be printed in prettified JSON format.

[1]: Conduit APIs are listed at https://phab.mercurial-scm.org/conduit/
2017-07-02 20:08:09 -07:00
Gregory Szorc
e4b6d44784 check-config: syntax to allow inconsistent config values
The ignore regular expression has been updated to detect
"inconsistent config." If present, we track which configs have
that set and we suppress the conflicting defaults error for those
options.

I also added named groups to the regexp to aid readability.

A comment was added to profiling.py to make a desired inconsistent
value error go away.
2017-07-01 20:34:27 -07:00
Pulkit Goyal
2150fb394e py3: update the python3-whitelist with new tests which pass on Python 3
We have now 34 tests passing on Python 3.
2017-06-27 21:16:08 +05:30
Augie Fackler
4b4be91515 merge with stable 2017-06-24 15:50:13 -04:00
Anton Shestakov
5f2a285fbe make: templatize Debian build target a la 7766b31dd141 2017-06-23 13:08:46 +08:00
Anton Shestakov
51ae08ed10 docker: install less as a build-time dependency in deb-based distros
It's needed since 99d9c6aa0389, otherwise dpkg-checkbuilddeps errors out.
2017-06-23 10:05:01 +08:00
Rodrigo Damazio Bovendorp
3a507184d3 debian: add less as a build dependency
For builds that run on hermetic environments, it's possible that the "less"
package is not installed by default, yet it's needed for tests to pass after
revision ca1519568a93 (which sets less as the fallback pager).
2017-05-26 19:33:20 -07:00
Matt Harbison
e47fefb937 wix: add 'ro' and 'ru' locales
Also noticed when diffing an MSI installation against an Inno installation.
OTOH, the Inno install doesn't include 'i18n' with the *.po files.
2017-05-25 23:42:37 -04:00
Matt Harbison
9f35da932f wix: include zstd.pyd in the installation
When trying to create a zstd bundle, the MSI based install said:

  abort: compression engine zstd could not be loaded

The Inno installer is unaffected.  The name will need to be updated to include
'cext' when merging into default.
2017-05-25 23:03:56 -04:00