Commit Graph

68 Commits

Author SHA1 Message Date
Jun Wu
40b5838e3e revset: optimize "head() & draft()" to "heads(draft())"
`head()` has visible overhead if there are too many heads (ex. 10k+).
Usually when we only care about draft heads, `heads(draft())` is better
since `draft()` are usually pre-calculated and the revset gets calculated as
`draft() - parents(draft())`, unrelated to the number of total heads.

Note that `head() & draft()` and `heads(draft())` are not strictly
equivalent (ex, a head with a secret phase) so it's changing the behavior a
bit. The new behavior is probably more desirable - in both smartlog and
backup case, people do want to see/backup the draft head, regardless of
whether it has secret descendants or not.

This makes `smartlogrevset` take 50ms less:

Before:

  148           | smartlogrevset                smartlog.py:438
  117            \ revs (3 times)               localrepo.py:783
  116             | mfunc (3 times)             revset.py:2202
  116             | getset (3 times)            revset.py:92
  116             | andset (2 times)            revset.py:165
  116             | getset (4 times)            revset.py:92
   62              \ andset (2 times)           revset.py:165
   62               | getset (4 times)          revset.py:92
   78                \ func (3 times)           revset.py:235
   49                  \ head (2 times)         revset.py:1117
   49                    \ branchmap (4 times)  localrepo.py:953
   46                    \ <genexpr> (16348 times) revset.py:1126
   38                     | rev (16344 times)   changelog.py:353 <<<< too many heads
   67                  \ branch (2 times)       revset.py:465
   42                    \ wrapper (2 times)    localrepo.py:141
   42                     | revbranchcache (2 times) localrepo.py:959
   40                     | __init__            branchmap.py:354
   12                     | read (2 times)      vfs.py:78
   25                    \ branchmap (2 times)  localrepo.py:953
   25                \ andset                   revset.py:165
   30              \ func (2 times)             revset.py:235
   30               | notbackedup               backupcommands.py:302
   52               | _backupheads (2 times)    backupcommands.py:389
   28            \ _masterrev                   smartlog.py:426

After:

   99       | smartlogrevset                    smartlog.py:438
   69        \ revs (3 times)                   localrepo.py:783
   68         | mfunc (3 times)                 revset.py:2202
   68         | getset (3 times)                revset.py:92
   68         | andset (2 times)                revset.py:165
   68         | getset (4 times)                revset.py:92
   13         | andset                          revset.py:165
   13         | getset (2 times)                revset.py:92
   27        \ _masterrev                       smartlog.py:426

Differential Revision: https://phab.mercurial-scm.org/D1448
2017-11-21 15:41:57 -08:00
Durham Goode
0ea3abac80 infinitepush: send treepack parts with the client push
This makes the client side pushes also include tree packs in the push.

Also adds a test to see that the tree parts round trip between two tree-only
clients.

This was reverted in D921 because clients couldn't push old non-tree commits to
infinitepush anymore. I've fixed the issue and added a test to this commit.

Differential Revision: https://phab.mercurial-scm.org/D1017
2017-11-01 17:10:05 -07:00
Maxime Montinet
ae3b7f2364 infinitepush: prevent hg pullbackup from doing an automatic backup
Summary:
Instead of making an autobackup, make hg pullbackup simply
write the backup state from the recently restored backup.

Test Plan:
cd ~/facebook-hg-rpms/fb-hgext/tests
source ../../hg-dev
rt test-infinitepush-*.t

Reviewers: #mercurial, cdown, stash

Reviewed By: stash

Subscribers: mjpieters, medson

Differential Revision: https://phabricator.intern.facebook.com/D6186148

Tasks: T22856338

Tags: bootcamp

Signature: 6186148:1509457565:e66cefc6e95d9b1cfb91e9bf8fa5c40b05e4fb82
2017-10-31 07:00:31 -07:00
Mark Thomas
f14cd2e5d5 infinitepush: always read local backup state from source shared repo
With shared working directories, infinitepush must always read the backup state
from the source repo.  Currently it does that for pushing backups, but not for
commands that just query the backup state.

Differential Revision: https://phab.mercurial-scm.org/D1052
2017-10-13 06:59:27 -07:00
Stanislau Hlebik
2502bb5d2c infinitepush: revert D721
Summary:
This diff caused a regression - clients may not have a tree manifests entries
for old commits. That causes infinitepush fail with

```
 KeyError: ('', 'f6db63080ed0d9a81adf2cb266646cf5cf73bb79')
```

Test Plan: Run infinitepush with this diff reverted, make sure it doesn't fail

Reviewers: #fbhgext, ryanmce, durham

Reviewed By: #fbhgext, ryanmce

Differential Revision: https://phab.mercurial-scm.org/D921
2017-10-03 05:49:06 -07:00
Durham Goode
286d6bbe18 infinitepush: send treepack parts with the client push
This makes the client side pushes also include tree packs in the push.

Also adds a test to see that the tree parts round trip between two tree-only
clients.

Differential Revision: https://phab.mercurial-scm.org/D721
2017-09-22 08:55:56 -07:00
Durham Goode
70c2f9fa71 infinitepush: override processparts
Upstream Mercurial now has a function that handles the iteration over bundle
parts. As part of making infinitepush handle more part types, let's override
processparts and completely take over part processing.

Initially the part processing will just mimic the existing handlers, but there's
a config flag that causes it to simply redirect the received parts into the new
bundle. This will be useful later for storing all bundle parts (like tree packs
and obsmarkers).

Differential Revision: https://phab.mercurial-scm.org/D717
2017-09-22 08:55:56 -07:00
Mark Thomas
c68f10b4e6 infinitepush: improve notbackedup performance
The notbackedup revset predicate still has performance problems when the set of
not-backed-up changesets includes some that are completely disjoint from the
set of backed-up changesets.

Rather than trying to express it as a combination of other expressions,
implement the revset calculation directly.  This allows us to also stop as soon
as a public commit is encountered, which should be faster in all cases.

Test Plan:
Expand tests to cover more complex scenarios.  Test perf on a larger and older
checkout of a big repo.

Differential Revision: https://phab.mercurial-scm.org/D764
2017-09-21 06:06:20 -07:00
Stanislau Hlebik
8bc5444998 infinitepush: run at most one backup per hg command
Summary:
Previously we ran auto backups in txnclose hook. But commands like histedit and
rebase create many transactions, and that means that lots of backup processes
are started at the same time. That means that sometimes backup processes use
too much memory.

Instead let's start it once per command if any transaction was opened
during the command.

Test Plan:
Run unit-test.
Run histedit with autobackup enabled, and make sure just one backup process
was started.

Reviewers: #fbhgext, durham

Reviewed By: #fbhgext, durham

Subscribers: durham

Differential Revision: https://phab.mercurial-scm.org/D678
2017-09-20 07:25:52 -07:00
Mark Thomas
5d730d772d infinitepush: don't use only() to compute not-backed-up revs
Summary:
The infinitepush backup smartlog summary uses only(a, b) to determine which
revisions have not been backed up.  However, if the set of backup heads is
empty, only() behaves as if it were called as only(a), which is wrong and slow.

Instead, use ::a - ::b, which is always correct, even if b is empty.

Test Plan: Re-run UTs.  Test perf on a repo with no backup heads.

Reviewers: #fbhgext, stash

Differential Revision: https://phab.mercurial-scm.org/D676
2017-09-11 09:00:56 -07:00
Jun Wu
05c526a68e infinitepush: update test to reflect upstream change
It seems `debugcheckbackup` could get a new kind of error with the latest
upstream code:

  Traceback (most recent call last):
    File "hg/mercurial/scmutil.py", line 150, in callcatch
      return func()
    File "hg/mercurial/dispatch.py", line 292, in _runcatchfunc
      return _dispatch(req)
    File "hg/mercurial/dispatch.py", line 896, in _dispatch
      cmdpats, cmdoptions)
    File "hg/mercurial/dispatch.py", line 658, in runcommand
      ret = _runcommand(ui, options, cmd, d)
    File "hg/mercurial/dispatch.py", line 904, in _runcommand
      return cmdfunc()
    File "hg/mercurial/dispatch.py", line 893, in <lambda>
      d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
    File "hg/mercurial/util.py", line 1118, in check
      return func(*args, **kwargs)
    File "hg/mercurial/extensions.py", line 322, in closure
      return func(*(args + a), **kw)
    File "hg/mercurial/util.py", line 1118, in check
      return func(*args, **kwargs)
    File "hg/hgext/mq.py", line 3542, in mqcommand
      return orig(ui, repo, *args, **kwargs)
    File "hg/mercurial/util.py", line 1118, in check
      return func(*args, **kwargs)
    File "fb-hgext/infinitepush/backupcommands.py", line 272, in checkbackup
      if not _dobackupcheck(bkpstate, ui, repo, dest, **opts):
    File "fb-hgext/infinitepush/backupcommands.py", line 469, in _dobackupcheck
      for r in lookupresults:
    File "hg/mercurial/wireproto.py", line 137, in results
      next(batchable)
    File "hg/mercurial/wireproto.py", line 238, in lookup
      self._abort(error.RepoError(data))
    File "hg/mercurial/sshpeer.py", line 235, in _abort
      raise exception
  RepoError: 0e1a088ff2825213eaa838a82a842bc186f10dd5
  abort: 0e1a088ff2825213eaa838a82a842bc186f10dd5!

The error message only contains a commit hash, which is not friendly to be
printed out. Therefore make sure we have control about the error message and
update the test accordingly.

Differential Revision: https://phab.mercurial-scm.org/D485
2017-08-22 21:58:37 -07:00
Jun Wu
8ee06a4fb7 infinitepush: be compatible with latest changes
Upstream has renamed `cleanup` to `_cleanup`. Let's update our code.

Differential Revision: https://phab.mercurial-scm.org/D486
2017-08-22 21:58:37 -07:00
Mark Thomas
7805c8ae35 infinitepush: improve revset for not-backed-up revisions
Summary:
The first version of infinitepush smartlog summary included some false
positives (in particular, not-backed-up but obsolete revs), and took a long
time to compute the set if there were many heads in the repo.

Improve the revset that is used by taking into account the heads that *should*
be backed up.  Ancestors of these heads, that are not ancestors of the actual
backup heads are the ones that should be considered "not backed up".

Test Plan:
Re-run unit tests.
Manual test on devvm.
Perf test against stash's repo which has more heads than mine.

Reviewers: #fbhgext, stash

Differential Revision: https://phab.mercurial-scm.org/D475
2017-08-22 09:03:43 -07:00
Luke Petre
0b56f3786a infinitepush: write infinitepush backup status
Summary:
  - change the infinitepush extension to record additional state when the a backup occurs.
  - useful for other tools (scm-prompt, nuclide) to indicate when a backup hasn't occurred recently

Test Plan:
  - cd facebook-hg-rpms/
  - source hg-dev
  - cd fb-hgext
  - arc unit

Reviewers: rmcelroy, stash

Reviewed By: stash

Subscribers: rmcelroy, medson, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5321221

Tasks: 18349390

Signature: t1:5321221:1501271966:6698785e0714e3ecf7e1e2684d1e62e52ac0f1a0
2017-08-02 16:42:08 +01:00
Mark Thomas
c8581c4465 infinitepush: add summary of not-backed-up files to smartlog
Summary:
Allow summarisation of commits that have not been backed up
by infinitepush.

1. Add a template keyword (backupstatus) which evaluates to
   one of "Public", "Backed up", "Backup pending", or
   "Not backed up" depending on the backup state of the
   commit.  Commits are pending for 10 minutes, after which
   they are declared not backed up.

2. Add a summary to the end of smartlog that shows the
   number of commits that are not backed up.

   Configuration options allow the addition of an education
   message to inform users what to do about their failing
   backups, and the message can also be suppressed.

Test Plan:
   New unit test for both the keyword and the summary.

Reviewers: #fbhgext, stash

Subscribers: mitrandir, quark, akushner

Differential Revision: https://phab.mercurial-scm.org/D184
2017-08-01 03:12:04 -07:00
Stanislau Hlebik
c27f60af8e infinitepush: remove infinitepush.tempcleanworkingcopiesbackups
Summary:
This option was intended as temporary and it was enabled for long enough time.
Now let's delete it.

Test Plan: Run unit-tests

Reviewers: #fbhgext, quark

Reviewed By: #fbhgext, quark

Differential Revision: https://phab.mercurial-scm.org/D195
2017-07-31 01:00:15 -07:00
Stanislau Hlebik
a4f2299ef4 infinitepush: add limit on a number of backed up nodes
Summary:
We've seen problems when public nodes were pushed to the server.
While the real reason is unknown it's a good idea to add a safety net to prevent
sending too many commits to the server because it's usually means that we are
pushing public commits. We limit number of nodes to 1000

Test Plan: Run infinitepush tests

Reviewers: #fbhgext, ryanmce

Reviewed By: #fbhgext, ryanmce

Subscribers: ryanmce

Differential Revision: https://phab.mercurial-scm.org/D143
2017-07-20 01:25:24 -07:00
Stanislau Hlebik
7ebdf0f427 infinitepush: remove some unused options
Summary:
Infinitepush has too many options and many of them are unused or has never
been changed from the default value. Let's remove some of them.

Test Plan: Run infinitepush tests

Reviewers: #fbhgext, ryanmce

Reviewed By: #fbhgext, ryanmce

Subscribers: ryanmce

Differential Revision: https://phab.mercurial-scm.org/D141
2017-07-20 01:20:59 -07:00
Ryan McElroy
55611588d1 bookmarks: use new applychanges api in all extensions
Summary: This eliminates the recently-added devel-warnings.

Test Plan: fewer `devel-warn`s during tests

Reviewers: #fbhgext, mitrandir

Reviewed By: #fbhgext, mitrandir

Differential Revision: https://phab.mercurial-scm.org/D130
2017-07-18 10:09:28 -07:00
Jun Wu
285b5a92e6 codemod: rewrite nested with
This is the result of running a codemod script:

  python ~/hg/contrib/codemod/codemod_nestedwith.py **/*.py

Plus a manual cleanup that removes the comment in `absorb/__init.py`.

See D76 for the codemod script.

Differential Revision: https://phab.mercurial-scm.org/D78
2017-07-17 12:02:08 -07:00
Stanislau Hlebik
a5b66da81e infinitepush: cleaning up
Summary:
Inspired by @mjpieters comments to another diff.
Let's simplify error handling.

Test Plan: arc unit

Reviewers: #mercurial, mjpieters, quark

Reviewed By: quark

Subscribers: quark, medson, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5310421

Signature: t1:5310421:1498248385:4957c187e99ed112db388fd3e3daf115c0fe9e0f
2017-06-26 00:55:16 -07:00
Stanislau Hlebik
a2c98b25a6 infinitepush: do not fail if backup state file does not exist
Summary:
Previously pushbackups failed when it tried to unlink non-existent infinitepush
backup state file. This diff fixes it.

Test Plan: arc unit

Reviewers: #mercurial, mitrandir

Reviewed By: mitrandir

Subscribers: medson, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5309684

Signature: t1:5309684:1498210504:49af716dbb4e7e1875e8a2b7ee4b40fe28ceefc1
2017-06-23 03:27:49 -07:00
Stanislau Hlebik
96be9a5870 infinitepush: add config option to set a hostname
Summary:
There is a problem with socket.gethostname() because it can return
inconsistent names. See attached task for details.

Instead this diff lets us specify any hostname.

Depends on D5180633

Test Plan: arc unit

Reviewers: #mercurial, simpkins, tja

Subscribers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5180665

Tasks: 18528165
2017-06-07 05:26:29 -07:00
Stanislau Hlebik
cfcb6fc5c9 infinitepush: refactoring to add BackupBookmarkNamingManager
Summary:
Previously there were many small functions that were used to create backup
bookmark name. Changing the logic was quite onerous because one would need to
change function signature in a few places.

This diff introduces special class that incapsulates this behaviour.
With this class making changes to naming scheme would be less problematic.


Depends on D5180390

Test Plan: arc unit

Reviewers: #mercurial

Subscribers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5180633

Tasks: 18528165
2017-06-07 05:26:29 -07:00
Stanislau Hlebik
d3a3074811 infinitepush: add option to trigger re-backups
Summary:
Let's add an option that can be used to trigger full clean backup.
It can be useful in many situations, for example, in case of bug in
infinitepush backup or if the naming scheme of backup bookmarks were changed.

Test Plan: arc unit

Reviewers: #mercurial

Subscribers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5180390

Tasks: 15389402
2017-06-07 05:26:29 -07:00
Jun Wu
ff3d5e9c4a codemod: use policy.importmod
Summary:
Do not `from mercurial.cext import ...`. That breaks pure.
Besides, add `from __future__ import absolute_import` for files I touched.

Test Plan: arc unit

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5156067

Signature: t1:5156067:1496252444:eb620a56c5bd852017ce2b2d41a12631d9d0866f
2017-05-31 10:46:16 -07:00
Stanislau Hlebik
4136d61d32 infinitepush: reduce pushbackup memory usage
Summary:
Previously `_getrevstobackup()` would load manifest for each commit in memory
only to check if a file was deleted in this commit or not. Manifest can be
quite big and since every loaded flatmanifest is cached in fastmanifest then
memory usage can be huge.
Since we are doing this only to check if there are any commits that were
downloaded to the client without filelogs and then were stripped server-side.
This cases are rare and it would be easier to track these commits in the
config file.

Test Plan: arc unit

Reviewers: #mercurial, mjpieters, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5111372

Tasks: 15389402

Signature: t1:5111372:1495848867:4028bd48313ac0e2022c3695195bedc6eda80abf
2017-05-29 12:54:26 -07:00
Durham Goode
6e542135ee imports: update c extension imports
Upstream has moved various c extension into mercurial.cext
2017-05-23 15:26:08 -07:00
Durham Goode
e34660b057 commands: update to use registrar instead of cmdutil
Summary: Upstream has deprecated cmdutil.commands() in favor of registrar.commands()

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5106486

Signature: t1:5106486:1495485074:0e20f00622cc651e8c9dda837f84dd84cc51099e
2017-05-22 13:38:37 -07:00
Stanislau Hlebik
036f4a7f7b infinitepush: use unfiltered() repo in isbackedup command
Summary:
One of the heads may point to filtered commit and isbackedup command fails in
this case. Let's use repo.unfiltered()

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5001977

Signature: t1:5001977:1493907725:f6a138bd4e2cae48b64152fceaf73660ea91f43b
2017-05-17 07:27:52 -07:00
Stanislau Hlebik
9a02f3a792 infinitepush: use infinitepush path instead of default push
Summary:
As @quark suggested, it's better to use `infinitepush` path instead of
default-push, because `default-push` is facebook-specific configuration.

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: quark, rmcelroy, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4962324

Tasks: 15389402

Signature: t1:4962324:1493727112:35c45c57a527d2de5a35ea83e1031dc1908ac28e
2017-05-02 05:50:10 -07:00
Stanislau Hlebik
1642b009fa infinitepush: add isbackedup command
Summary:
Command that checks if a commit was backed up.
It does it by checking if revisions are in local backup state.

Test Plan: Run unit tests and lints

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4938072

Tasks: 17519836

Signature: t1:4938072:1493072854:291765bb59d327db8504feb47d6089818ae1e11a
2017-04-25 01:09:28 -07:00
Stanislau Hlebik
d610259241 infinitepush: delete bkpstate from shared working copy
Summary:
infinitepushbackup.tempcleanworkingcopiesbackups option sends special command
to clean backup bookmarks from the server for the shared working copy (i.e.
if we have main repo `fbsource` and shared working copy `fbsource2` we want
to have backups only for `fbsource` not for `fbsource` and `fbsource2`).
Before this diff cleanup commands were send for every backup.
This diff makes them send only if backup state file is present.

Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4929489

Signature: t1:4929489:1493075761:a408300338a10864043b538540d03880a49c4e1a
2017-04-25 01:09:28 -07:00
Stanislau Hlebik
c15b2d9958 infinitepush: read backup state file from real repo not from shared working copy
Test Plan: arc unit

Reviewers: #mercurial, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4929323

Signature: t1:4929323:1492785417:609a5569ad49f1f9e938908c30214a7b0a89ffb6
2017-04-24 01:07:20 -07:00
Stanislau Hlebik
b6eb201c3f infinitepush: fix backup of commits with removed files
Summary:
There was a bug that caused commits with file deletions to not be backed up.
This diff fixes it by first checking if file exists in the commit and only
then downloading context of the file.

Note:
In tests I had to ignore stdout of `hg pushbackup` because the output was
different on macs and linux.
On linux there was an additional line

  remote: abort: data/committostripfirst.i@091b63e5e4: no match found!

Probably mac's remotefilelog closes stdout/stderr earlier, but I wasn't
able to find a root cause.

Test Plan: Run unit tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: quark, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4929244

Tasks: 15389402

Signature: t1:4929244:1492791804:77b2baa9eb54a53120a955e72e6c132be5db6b44
2017-04-21 10:24:14 -07:00
Stanislau Hlebik
928a96b602 infinitepush: use ui.debug() instead of ui.warn()
Summary: To avoid spamming users

Test Plan: Run tests

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4883447

Signature: t1:4883447:1492088221:3649b14ff514957d2f412aae2647ca1b20ef5fea
2017-04-17 23:44:26 -07:00
Stanislau Hlebik
57dc185f42 infinitepush: don't make separate backups for different working copies
Summary:
Previously we had separate backup per working copy. That's very confusing
since all these working copies shares the same repo. This diff fixes it and
also adds config option to clean unnecessary working copy server-side.

Test Plan: Run infinitepush unittest

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: rmcelroy, quark, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4876230

Signature: t1:4876230:1492025747:3579e5046efc2ed309044fc3335c36ac4f7bdd04
2017-04-13 04:58:11 -07:00
Stanislau Hlebik
efbec7652d infinitepush: fix security concern
Summary: Check owner of a log file before writing to it. See comments for details

Test Plan: arc unit

Reviewers: #mercurial, simpkins

Reviewed By: simpkins

Subscribers: net-systems-diffs@fb.com, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4842933

Tasks: 17155924

Signature: t1:4842933:1491861137:e8a027fb7a930c0c5f553c75cb84214d24f66ce3
2017-04-12 01:12:23 -07:00
Stanislau Hlebik
a50af234cb infinitepush: run backup check before backup from time to time
Summary:
It's a good way to check if backup is consistent. If backup is not consistent
then we set special exit code that will be logged. It let's us easily find users
with inconsistent backups and fix it.

Test Plan: arc unit

Reviewers: #mercurial

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4810442

Tasks: 15389402
2017-04-05 00:56:28 -07:00
Stanislau Hlebik
233dca479c infinitepush: variable renaming and refactoring
Summary:
Give better names to the variables to underline what these variables really
store. And a bit of code movement.

Test Plan: arc unit

Reviewers: #mercurial

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4803405

Tasks: 15389402
2017-04-05 00:56:28 -07:00
Stanislau Hlebik
a1efbe09d2 infinitepush: remove useless checks from _filterbookmarks()
Summary:
`headstobackup` won't point to bad nodes and they are only draft.
No need to check one more time

Test Plan: arc unit

Reviewers: #mercurial

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4803376

Tasks: 15389402
2017-04-05 00:56:28 -07:00
Stanislau Hlebik
12a13d9b3a infinitepush: do not backup extinct heads
Summary:
Previously we backed up extinct node if bookmark pointed to them. But this not
is not present in the bundle because `findcommonoutgoing()` intentionally skips
extinct and secret commits. In this case we'll have infinitepush bookmark that
points to non-existent infinitepush commit. To fix it let's filter extinct heads

Test Plan: arc unit

Reviewers: #mercurial

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4803322

Tasks: 15389402
2017-04-05 00:56:28 -07:00
Stanislau Hlebik
099ba152f5 infinitepush: add getavailablebackups command
Summary:
Command to list available backups for the user.
--json will be used by automation

Test Plan: arc unit

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4728729

Tasks: 15389402

Signature: t1:4728729:1490005762:41b9683cb7dfc9d84ae1032c807d1f0c3fe60dbf
2017-03-29 03:00:46 -07:00
Stanislau Hlebik
44997262d3 infinitepush: call util.shortuser() directly
Summary:
ui.shortuser() doesn't call util.shortuser() if ui.verbose equals to True.
But in our case it's very important to always use short username because
we'll get broken backups otherwise. Let's call util.shortuser() directly.

Test Plan: arc unit

Reviewers: #mercurial, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4721949

Tasks: 15389402

Signature: t1:4721949:1489717973:b7e59929f530578e060b8cdef94ef92b54fa2647
2017-03-20 01:38:06 -07:00
stash@fb.com
d36fb477cb infinitepush: fix the build
Summary:
On macos sshpeer flushes remote output later and it causes tests to fail. Let's
add a call to cleanup() to make sure the output is flushed.

This diff also makes remotefilelog test more robust.

Test Plan: Run tests on macos

Reviewers: #mercurial, tja, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4721276

Tasks: 15389402

Signature: t1:4721276:1489669109:4ce59f4a1d224d57dbb7c1eb341c4e6a659d2e8c
2017-03-16 08:35:15 -07:00
Stanislau Hlebik
6b7e94a53f infinitepush: add --all option to debugcheckbackup
Summary:
By default debugcheckbackup checks only one backup for the user.
With --all option it checks all backups for the user from all host/reporoots

Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4700993

Tasks: 15389402

Signature: t1:4700993:1489548921:800d08f420acc8ef4f807ffd17b31837dbb3fe82
2017-03-16 02:22:39 -07:00
Stanislau Hlebik
3553b5e9bb infinitepush: do not restore bookmark if node is not present
Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4700979

Tasks: 15389402

Signature: t1:4700979:1489548965:bab126d96adc827be84a2fc8939f6c03b0ef6599
2017-03-16 02:22:39 -07:00
Stanislau Hlebik
280028dd61 infinitepush: add maxheadstobackup option
Summary:
Backing up very big repo can cause problems. And very often old commits are
not necessary at all. Let's add a config option to limit the number of heads
that are being backed up.

Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4700965

Tasks: 15389402

Signature: t1:4700965:1489549163:4e2c121f01debd7b495486a1f3b062926873399d
2017-03-16 02:22:39 -07:00
Stanislau Hlebik
2faa6709ca infinitepush: change backup state file format
Summary:
Previously we saved bookmark hash and revision number as state of
the last backup. Storing last backed up revision is error-prone. I saw
a few corrupted backups where bookmarks pointed to non-backed up
nodes. Also this approach puts more pressure on mysql bundle index.
On every backup it first deletes all existing backup bookmarks and then it
writes new bookmarks. Even if user changed one head or one bookmark
(and that is the usual case) current approach still deletes bookmarks first
and then rewrites them.

Instead let's store all backed up heads and bookmarks locally in json format.
Json was chosen because it's simple and human-readable. Then during backup
let's compare last backed up state to the current state of the repo, and send
to the server only the difference.

Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4700930

Tasks: 15389402

Signature: t1:4700930:1489613249:a34369bf53e0718c22258304493dfa27b578857f
2017-03-16 02:22:39 -07:00
Stanislau Hlebik
897faf2d06 infinitepush: refactor and rename _getbackupstate
Summary:
Let's rename _getbackupstate() to _downloadbackupstate() because it actually
downloads it from the server. Also return class instead of tuple

Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4713633

Tasks: 15389402

Signature: t1:4713633:1489612870:3439a6a99ef311bf96784b3b1e53d7e9b94c0713
2017-03-16 02:22:39 -07:00