Mercurial > hg
annotate tests/remotefilelog-getflogheads.py @ 47584:ee1fc8f970e6
run-tests: introduce a `HGTEST_REAL_HG` variable for test
It turns out that currently, `hg` and `which hg` can point to different things
because `hg` is an alias… This is annoying because script and pieces of test
are unknowingly using the wrong `hg`.
We will fix it in another changeset. However some test actually need to use a
real `hg` binary and not some `chg` or `rhg` equivalent. So we introduce a new
variable with the right value and we put it to us in the appropriate location.
Differential Revision: https://phab.mercurial-scm.org/D11049
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 09 Jul 2021 20:03:46 +0200 |
parents | 3000f2100711 |
children | 6000f5b25c9b |
rev | line source |
---|---|
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 from __future__ import absolute_import |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 from mercurial.i18n import _ |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 from mercurial import ( |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 hg, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 registrar, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 ) |
46955
3000f2100711
remotefilelog: use `get_unique_pull_path` in `getflogheads`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46663
diff
changeset
|
8 from mercurial.utils import ( |
3000f2100711
remotefilelog: use `get_unique_pull_path` in `getflogheads`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46663
diff
changeset
|
9 urlutil, |
3000f2100711
remotefilelog: use `get_unique_pull_path` in `getflogheads`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46663
diff
changeset
|
10 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 cmdtable = {} |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 command = registrar.command(cmdtable) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41253
diff
changeset
|
15 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41253
diff
changeset
|
16 @command(b'getflogheads', [], b'path') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 def getflogheads(ui, repo, path): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 """ |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 Extension printing a remotefilelog's heads |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 Used for testing purpose |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 """ |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
46955
3000f2100711
remotefilelog: use `get_unique_pull_path` in `getflogheads`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46663
diff
changeset
|
24 dest = urlutil.get_unique_pull_path(b'getflogheads', repo, ui)[0] |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 peer = hg.peer(repo, {}, dest) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
43076
diff
changeset
|
27 try: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
43076
diff
changeset
|
28 flogheads = peer.x_rfl_getflogheads(path) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
43076
diff
changeset
|
29 finally: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
43076
diff
changeset
|
30 peer.close() |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 if flogheads: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 for head in flogheads: |
41253
29996f6c2687
tests: add missing b prefixes in remotefilelog-getflogheads.py
Augie Fackler <augie@google.com>
parents:
40511
diff
changeset
|
34 ui.write(head + b'\n') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 else: |
41253
29996f6c2687
tests: add missing b prefixes in remotefilelog-getflogheads.py
Augie Fackler <augie@google.com>
parents:
40511
diff
changeset
|
36 ui.write(_(b'EMPTY\n')) |