Commit Graph

325 Commits

Author SHA1 Message Date
Adam Simpkins
7f1c4eb449 [sparse] make sure "hg update --clean" correctly forgets about excluded files
Summary:
A user ran into a bug where a failed rebase left their repository in a state
where "hg status" reported many excluded files had been removed.

They weren't able to recover from this state, even using "hg update --clean ."
This was because the sparse extension was ignoring the actions to forget these
files from the dirstate.  The sparse extension should allow excluded files to
be forgotten.

Test Plan:
I tried writing a test case for this but wasn't able to figure out how to
trigger exactly the situation that the user's repository was in.  (It looks
like there were other bugs in "hg rebase --abort" that led to their repository
state.)

I was able to cause some other problems with files in the "g" type
("remote created") that "hg update --clean" wouldn't fix.  I haven't added
those test cases for now though, since that problem isnt' fixed by this diff.
It does seem like there are potentially other problems here that still need to
be addressed.

Reviewers: quark, rmcelroy, mjpieters, durham

Reviewed By: durham

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Tasks: 13694820

Signature: t1:3966580:1475676328:48433e203ae702a50b40176e52f1ed90a5c45504
2016-10-13 11:49:58 -07:00
Jun Wu
82b158ed59 githelp: fix crash in mergebase
Summary: `_` does not take two arguments while `ui.status` does.

Test Plan: Added a test case

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4010079:1476298648:81e678fbe433aa8cca8b03c9eba50d9b78bbc9bb

Blame Revision: D2811887
2016-10-12 19:47:42 +01:00
Arun Kulshreshtha
a154bbaeb0 Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.

I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.

Test Plan:
See unit tests for complete commands.

1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: rmcelroy, quark, mjpieters

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

Tasks: 13651947

Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-11 17:41:07 -07:00
Adam Simpkins
89f30244e5 [phrevset] fix "invalid literal for int()" error
Summary:
Fix the revsetdiff() function to always return a revision number.

Previously if the revision information was retreived from phabricator rather
than being found locally we return a changeset string rather than a revision
number.  This fixes the code to convert the changeset string back to a revision
number.  If the specified commit does not exist in the local repository, we
throw an error indicating that the user should run "hg pull"

Test Plan:
Tested running "hg graft -r DXXXXXXX" with a diff that was not present in the
local repository yet.  Confirmed it now prints an error indicating that the
user needs to run "hg pull" to fetch this revision, whereas previously it
crashed with an "invalid literal for int()" error.

Reviewers: #sourcecontrol, durham, simonfar, quark

Reviewed By: quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Tasks: 11355408

Signature: t1:3997925:1476201895:9b5832dc28abdddaa281a848246476b78f5a9fe7
2016-10-11 11:13:58 -07:00
Arun Kulshreshtha
19db7fa2a6 Remove unused imports.
Summary:
fbamend.py has several unused imports. This is annoying since I'm actively working on this file.
This change removes and consolidates the imports.

Test Plan: All unit tests for this file (namely test-fbamend.py and test-fbamend-nextrebase.py) still pass.

Reviewers: #sourcecontrol, durham, quark, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:3965839:1475573964:e7937ce7e7bc35655d629345156c4d177f185605
2016-10-04 10:29:55 -07:00
Ryan McElroy
78f0c73d4b extension to print commit message that would be supplied to editor
Summary:
the nuclide team would like to be able to get the commit template
message without actually invoking a commit. This small extensions allows them
to do this.

Caveats: ignores subrepositories.

Test Plan: new test

Reviewers: #mercurial, most

Subscribers: mjpieters

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

Tasks: 12771006
2016-10-03 04:39:51 -07:00
Zach Amsden
2f33513a19 Log interactive time, internal command timing to scuba
Summary:
Use wrappers around ui functions to exclude interactive
and log the results to scuba.

Test Plan:
   USE_DIST_HG= FB_HG_DIAGS= CHGDISABLE= hg --config 'extensions.profiling=~/facebook-hg-rpms/fb-hgext/hgext3rd/profiling.py'  --pager=off --config profiling.enabled=False amend --edit
  chg: disabled by CHGDISABLE
  internal stats file: /tmp/scm-internal-statsx9EXSw
  hg profiling mode: SKIPPED
  stats: {
      "int": {
          "builddate": 1471281577,
          "cachehitratio": 75,
          "consumed": 425,
          "diffcachehitratio": -1,
          "elapsed": 1921,
          "errorcode": 0,
          "filesnotincachehitratio": -1,
          "interactive_time": 1534,
          "internal_time": 1701,
          "time": 1473459054
      },



Tested both with and without chg to make sure both modes work, otherwise
there are some subtle bugs that can come up under hg (timer becomes persistent
if invoked too early in uisetup).

Check out scuba table, new columns are showing up.  I still need to clean up the table as I accidentally added data as string first.

Reviewers: #sourcecontrol, ttung, quark, durham

Reviewed By: durham

Subscribers: giorgioc, mjpieters, akushner

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

Tasks: 12879683

Signature: t1:3844697:1475250469:a46aff22781e0e07596e2880d6477a62754f1397
2016-09-30 12:32:21 -07:00
Arun Kulshreshtha
bc3b0cd1c7 Make hg next --rebase intelligently obsolete/inhibit changesets
Summary:
This change updates the behavior hg next --rebase. Specifically:

  - Only one changeset can be rebased at a time. If there are multiple candidate changesets, the command aborts.
  - Each time a changeset is rebased, its precursor is marked as obsolete, inhibition markers are stripped from it and its ancestors, and its preamend bookmark is deleted, if one exists.
  - The result of this is that if no non-obsolete changesets depend on the existence of the pre-rebased changeset, that changeset and its ancestors will be stripped, resulting in a cleaner user experience.
  - This change also adds back the --evolve flag, but makes it show in error instead of working. It turns out that removing the flag outright breaks the evolve extension.

Test Plan:
See updated unit tests for the exact commands to run to test this, as well as an overview of all of the new situations where behavior was changed.

A basic test plan would be:
1. Initialize a new repository, and create a stack of 4 commits.
2. Amend the second commit in the stack.
3. Do `hg next --rebase`. It should work as before.
4. Do `hg next --rebase` again. This time, the entire old stack should "disappear" from hg sl.

Additionally, attempting to run `hg next --rebase` when there are multiple possible child changesets should fail.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: quark, mjpieters

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

Tasks: 13570554

Signature: t1:3941922:1475205056:58a8d1726cfcccbf14a38727be0220a09532ec97
2016-09-30 10:40:58 -07:00
Jun Wu
efb6a83a3e smartlog: remove unused edge when indentnonpublic is set
Summary:
This patch removes the unused line and space so it looks a bit better:

```
 .
 .
 .
 | o          o
 | |          |
 | |          |
 | o          o
 |/          /
 |          |
 o          o
 .          .
 .          .
(before)   (after)
```

Due to the current implementation of graphlog, it's a bit hacky to achieve the
above effect.

Test Plan: Run `test-smartlog*.t`

Reviewers: #mercurial, ttung, mjpieters, durham

Reviewed By: durham

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

Signature: t1:3881516:1475170264:477c66b2372d04c4e5d7c8fbb69de30599706e5d
2016-09-17 02:22:36 +01:00
Ryan McElroy
7e63ec0dce rage: use hg sl instead of smartlog to get better template
Summary:
The default template is more compact and more useful with thigns like remote
bookmarks included.

Also drop '--all' and add '--hidden' since recent commits are much more
interesting than old commits and recent hidden commits will be useful when
people have recently lost something.

Test Plan: run `hg rage`, look at paste produced

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3904646:1475171650:fc1bab0062be39c590b61492bce42236f3bb6123
2016-09-29 11:19:52 -07:00
Jun Wu
4cc05e5d24 absorb: improve rename handling
Summary:
Previously `absorb` does not care too much about copies or renames and
assumesa file path only exists in every changeset of `stack[k:len(stack)]`,
but does not exist in any of `stack[0:k]`. If this assumption is not true,
absorb will likely crash.

This patch implements copy or rename handling correctly. After this patch,
renames happens to a single file is tracked correctly. Copies are ignored
by default. For the "double move" case, like:

  hg cp a a1
  hg cp a a2
  hg rm a

We only follow the first path (sorted alphabetically). In this case, changes
to "a1" could affect the content of "a" in a previous changeset, while changes
to "a2" couldn't.

Test Plan: Added a new test

Reviewers: durham, #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3941438:1475166850:97461174619d469750146e25f6bff16dae19bd3d
2016-09-28 23:56:43 +01:00
Stanislau Hlebik
bbb7f15c99 pushrebase: cleanup
Summary: Remove unused imports + fix missing variable error in `_checkheads()`.

Test Plan: Added a new test.

Reviewers: quark, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3862724:1474283118:deceacc683bb079eb7afb2ea34fb1e196f9bb18b
2016-09-26 01:48:13 -07:00
Arun Kulshreshtha
ce03ceb66c Add hg next --rebase
Summary:
This diff adds the --rebase option to the `hg next` command by extending
the evolve extension in the fbamend extension.

The --rebase option finds any child commits of the obsolete precursor to the
current commit, and rebases them onto the current commit before performing
`hg next`. This way, one can be in the middle of a stack of commits, amend one
in the middle, and do `hg next` without running `hg amend --fixup`. The next
commit will be correctly found, rebased, and updated to.

This is equivalent to:



  hg rebase -d . -r "children(OLD_HASH)" -k && hg next

Test Plan:
I tested this command by hand and created some unit tests. The basic way to test it is:

1. `hg init` a new repository.
2. Create a chain of 3 commits.
3. Amend the 2nd commit.
4. Run `hg next --rebase` and confirm that the 3rd commit was rebased and switched to.

The exact commands to do this are in tests/test-fbamend-nextrebase.t. This file also
contains test cases in which there are multiple child commits on the precursor, and cases
where there is a rebase conflict.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters, nain

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

Tasks: 13347995

Signature: t1:3910568:1474650102:8c7dd712afb9d36f29e1e73bb781e1d8e0870371
2016-09-23 10:39:36 -07:00
Jun Wu
aaafeda370 smartlog: use graphstyle.grandparent to draw ellipsis
Summary:
Now that the graph module can draw "..." for grand parents, it's no longer
to have fake nodes for that purpose. Remove most fake node related logic.

This will make the output more compact.

Note that the fake node is still used for "indentnonpublic" and its output
is slightly changed to display an "o" node, which will be fixed in the next
diff.

Since we now rely on a recent version of mercurial, remove some "inspect"
check for ancient mercurial support.

Test Plan: Run the modified `test-smartlog.t` and other `test-smartlog*.t`.

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:3880771:1474306496:3400c70efbb569c5096e724720ead1992b87f160
2016-09-17 00:51:26 +01:00
Jun Wu
dfa3d19fc2 smartlog: add an option to indent the non-public stack at the top
Summary:
One thing that may confuse new users is that when draft changesets are on top
of public changesets:

```
o draft
|
o remote/master
```

It's unclear whether the draft changeset is already in the master branch, or not.

This diff adds an option to move the drafts to the second column to indicate they
are not part of master.

Test Plan: Run `test-smartlog.t`

Reviewers: ttung, durham, #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:3876951:1474043568:c97b26b49917f36a5197af93ea386658b91d56a4
2016-09-16 16:36:10 +01:00
Jun Wu
9fea0c3f0c doc: replace "commit" where it is used as a noun with "changeset"
Summary:
"changeset" is a more official term and let's use it. Note that this patch
only changes documentation / i18n messages visible to the users and header
comment blocks to developers. Other places like comments in the code are
untouched.

With the "dialect" extension enabled, users will still see the more friendly
term - "commit".

Test Plan:
`arc unit`. Note the remotefilelog failure is probably unrelated - seems
related to ongoing / upcoming manifest refactoring upstream.

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3900394:1474470348:6a1b5691e2599cc47df18b227d56d1f9d3c7c906
2016-09-21 15:45:25 +01:00
Jun Wu
9151f4abfb dialect: new extension to "translate" messages to a dialect
Summary:
As discussed before, we think terms like "changeset" is more official to hg,
while less known as "commit" is used more widely.

This extension replaces "changeset" with "commit" so users will get a
consistent view about the term being used, and we can use "changeset" in our
code to be more official while don't need to worry about user friendliness.

Test Plan: Run the newly added test

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3900240:1474470482:44ac6e09d58e624c539bb1336842ce8911c9dcee
2016-09-21 15:04:42 +01:00
Jun Wu
73eac46994 grpcheck: new extension to check if the user is in given groups
Summary:
We have seen issues that users have outdated groups when running hg commands,
which will probably always cause issues:

- Authentication issue, unable to ssh
- Filesystem permission issue, unable to write hgcache
- Even worse with chg server since the long-running server process will keep
  the wrong groups information

This extension is to address the above issues. It allows us to print a message
to let the user know they have group issues. Besides, it allows us to override
configs like `chgserver.idletimeout` so chg servers with wrong groups can have
a much smaller TTL and won't be long-running and causing issues.

Test Plan: Run the newly added test

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:3896628:1474454162:22785ff23e3ada75013ce5f1eead3407068ba172
2016-09-20 23:15:09 +01:00
Jun Wu
4637f4c7f2 absorb: fix insertion to an empty file
Summary:
When diffing a with b, if a is empty, we don't insert a "dummyendline" (see
line 214) because we do not have the last line to copy. In this case, if an
insertion happens, we have no "nearbylinenums" (see line 274) to visit.

The current code assumes "nearbylinenums" have at least one element, which
is wrong in the above case and will crash the program.

The fix is to add a check about whether "annotated" (aka. "a") is empty or
not.

Test Plan: Run `test-absorb-filefixupstate.py`

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: durham, mjpieters

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

Tasks: 13371265

Signature: t1:3867686:1474289020:a183e6837e6e0afb8a5d56641689e240e8cd78c9
2016-09-15 00:59:29 +01:00
Jun Wu
9d18a32174 smartlog: improve documentation
Summary:
Add docstring so `hg help -e smartlog` works and the config options are more
visible to users.

Rename "commit" to "changeset" so it sounds more official in the hg community.

Test Plan: No logic change. Code Review

Reviewers: durham, #mercurial, ttung, mjpieters

Reviewed By: mjpieters

Subscribers: simonfar, mjpieters

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

Signature: t1:3876938:1474288105:cb751cc868e70761cf3b34749eabf2a32c886a2d
2016-09-16 23:48:42 +01:00
Jun Wu
316cae170e absorb: add an interface to edit lines for all involved revisions
Summary:
This feature allows the user to choose what lines exist in what changesets
precisely, for example:

    HG: editing a
    HG: "y" means the line to the right exists in the changeset to the top
    HG:
    HG: /---- 991104c93ef1 commit 1
    HG: |/--- aa7e21df9b0b commit 2
    HG: ||/-- 05b39f5d9141 commit 3
    HG: |||
        yyy : 1
         yy : 2
          y : 3

The feature can be used to "move" lines among changesets, or generally
editing the contents in a new way. So it's not limited in the "absorb"
use-case. We may want to give it another name in the future.

Test Plan: Added a new test case

Reviewers: #mercurial, rmcelroy, ttung

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3841494:1473769708:1bb2a46c010222438ceaae69ea0dca39e37581d2
2016-09-09 14:06:16 +01:00
Kostia Balytskyi
d098615fe2 reset: make reset support -r/--rev as this is what people often expect
Differential Revision: https://phabricator.intern.facebook.com/D3869912
2016-09-15 08:49:23 -07:00
Pierre-Yves David
f1c24eddea absorb: fix a typo in output
From 'changset' to 'changeset'.
2016-09-12 18:00:54 +02:00
Jun Wu
eb9e71ef7d sshaskpass: disable echo for Password: prompt
Summary:
While on Linux, `ssh` prompts `username's password:`, the OS X uses
`Password:`. Change `_shoulddisableecho` to include that case.

Test Plan:
Run `chg push ssh://localhost//tmp/foo` on an OS X system and check echo
is disabled for the password prompt.

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3841947:1473440175:ea2c171a4bfda9d00b4de8c7c51bb00d0b7194f1
2016-09-09 17:24:23 +01:00
Jun Wu
e2c14da0b2 fbhistedit: use ui.system instead of util.system
Summary:
`chg` has some special handling on `ui.system` - if it is simple, it will
be forwarded to the client (the `chg` process) and the new process will be
a child of `chg`, which will inherit the controlling TTY correctly.

Otherwise, it will be a child of a server-side worker process, which does
not have a controlling TTY. That's the case if `util.system` is used.

Test Plan:
Insert `x sleep 1000` in the histedit plan and confirm the `sleep`
process runs as a child of the `chg` process:

```
41876 13176 pts/14   Ss   03:17   0:00  \_ zsh
 4196   732 pts/14   S+   03:20   0:00  |   \_ chg histedit
 7572   664 pts/14   S+   03:20   0:00  |       \_ sleep 1000
```

Reviewers: #mercurial, ttung, rmcelroy, simpkins

Reviewed By: simpkins

Subscribers: mjpieters

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

Tasks: 13295639

Signature: t1:3846243:1473480297:59aaf34cb3a52200321122dc7c054e2454cd3bd3
2016-09-10 03:23:12 +01:00
Jun Wu
62306f5f04 fbhistedit: fix upstream compatibility
Summary:
The upstream changed the signature of `verify` in 9ec9fba6ea06
(`histedit: move constraint verification to the 'action.verify' method`):

  -    def verify(self, prev):
  +    def verify(self, prev, expected, seen):

The upstream also moves the check about `action.node` around so
they become required and we have to set `self.node` in our histedit actions.

Test Plan:
Run histedit with the latest (8a658b) upstream code. Use `x sleep 1` and
ensure it works.

Reviewers: #mercurial, ttung, ikostia

Reviewed By: ikostia

Subscribers: ikostia, mjpieters

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

Signature: t1:3846190:1473671179:97b238748e99a5868bb84614b89360e750b529a4
2016-09-10 03:03:37 +01:00
Stanislau Hlebik
11e4d7be5a logginghelper: return repo name instead of repo root
Summary:
logginghelper extension returns full path to the repo instead of just repo name.
It makes it hard to aggregate results per repo in scuba.
Use just repo name instead of repo root.
We can get repo name either from `paths.default` config value or
a basename of the repo root.

Test Plan:
Before:
{P56637657}

After:
{P56637661}

Diff
{P56637665}

Reviewers: rmcelroy, ttung, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3827912:1473413932:5c38ca48e58a080c97b35610ee8889d66b4d5ab3
2016-09-09 08:07:56 -07:00
Stanislau Hlebik
e64b96276e logginghelper: rename reporootlog to logginghelper
Summary:
We are going to log many different pieces of information in this extensions.
Therefore the `reporootlog` is not an appropriate name anymore.
Change it to `logginghelper`.

Test Plan:
Note that repo root is still logged instead of repo name. It will be changed in subsequent diffs
{P56637657}



Reviewers: rmcelroy, quark, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3840985:1473410718:62d83f008f2973b7ed5266b0a5ebf67fe54b48c4
2016-09-09 08:04:03 -07:00
Stanislau Hlebik
92e9887bdb reporootlog: remove unused variable
Test Plan: Not tested

Reviewers: quark, rmcelroy, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3827908:1473349204:23fe6cfdf0083be701c14b3988c2a7251321b246
2016-09-08 09:39:55 -07:00
Ryan McElroy
6e5a7ab866 pushrebase: fix for upstream api change
Summary:
In upstream mercurial, 3d5e0fd41e0e changed discovery.outgoing() from taking a
changelog to taking the full repo object.

Test Plan: run tests, fewer stacktraces

Reviewers: #mercurial, ttung, durham, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3819300:1473090807:fd0e4c2956fee4ad7d45051b6b7c5be481c766f1
2016-09-05 12:02:23 -07:00
Mathias De Maré
96605a0ea5 absorb: correctly pass executable mode in getfile
getfile should return the file mode as (islink, isexec),
but it was returned as (islink, isbinary).
As a result, using 'hg absorb' removed executable mode from
the relevant changeset so the mode change showed up in the working directory.

Issue reported with test case by Thomas De Schampheleire.
2016-09-01 13:05:52 -07:00
Jun Wu
1b6413957a chistedit: workaround a Python bug
Summary:
See http://bugs.python.org/issue27666 for details.

`win.box(0, 0)` will crash python if it is built with stack check / protection
(by using hardening-wrapper with `HARDENING_STACK_CHECK=1` and
`HARDENING_STACK_PROTECTOR=2`).

Test Plan: Run `hg chistedit tip` on Arch Linux, and it does not crash instantly.

Reviewers: #sourcecontrol, ttung, jeroenv

Reviewed By: jeroenv

Subscribers: mjpieters

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

Signature: t1:3806224:1472758902:8a73645fd1ef98c9106c3b2766e368d4072a2d46
2016-09-01 20:18:36 +01:00
Jun Wu
9e1c1b0adf sshaskpass: do not import mercurial packages when running standalone
Summary:
The sshaskpass code is both an hg extension and a standalone python script.
In the latter case, it does not need to import mercurial packages (and
doing that may cause `ImportError` if `mercurial` is not in python path).

Test Plan:
Manually make the change in a Mac Mini device and check `chg pull` works
with ssh password authentication.

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:3799653:1472675282:9f7e9f4f29281db239f33cf396057ea12ff21773
2016-08-31 21:05:00 +01:00
Zach Amsden
214a35d6cb Fix statprof for upstream
Summary: Upstream mercurial has changed, breaking statprof

Test Plan: HGPROF=stat ./hg-dev  --config extensions.statprofext=~/facebook-hg-rpms/fb-hgext/hgext3rd/statprofext.py  --config profiling.enabled=True --config profiling.frequency=10000 --profile log -l 1000 --pager=off

Reviewers: durham, quark, #mercurial, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3786387:1472497930:488d7d584395ca686de4dc458c87eb05fc944282
2016-08-29 15:23:04 -07:00
Steve Fink
c6e9bfc3fb chistedit: Disable numeric 'goto' command with large number of patches.
You can jump to a patch by pressing its numeric index, but this obviously only works with up to 10 patches. Moreover, with a large number of patches the feature is dangerous, since an accidental number press will lose your place. While we could do something fancy and prompt for multi-digit input in the many-patch case, it doesn't seem worth the complexity, and simply disabling 'goto' seems good enough.
2016-08-26 06:41:26 -07:00
Steve Fink
511e685836 chistedit: fix some off-by-ones in screen height 2016-08-26 06:41:26 -07:00
Mateusz Kwapich
4913062607 check-code fixes
Test Plan: check-code passing

Reviewers: #mercurial, ttung, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:3771131:1472139248:f8ea463552fc0d2261456050e9bf513f26eb727c
2016-08-25 09:04:43 -07:00
Jun Wu
0184b72cf7 Rename "smartfixup" to "absorb"
Summary:
This seems to be an elegant choice. It does not conflict with other names,
and it does explain the concept to some extent vividly.

Credit goes to [trousers at lobste.rs](https://lobste.rs/s/nws1uj/help_us_name_new_mercurial_feature/comments/u4tsw7#c_u4tsw7).

Test Plan: Run the existing tests.

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3763992:1472049269:5bb9de3b7b3a0f0dd9587b952151fc38351bc822
2016-08-24 16:28:47 +01:00
Jun Wu
350dae5587 smartfixup: add a config option to make it a subcommand of "amend"
Summary:
Some people think this command should be a part of "amend". If you check the
meaning of the "amend" English word, that makes sense. But if you look at
the actual "amend" command, there are significant differences:

1. smartfixup rewrites a stack of changesets, and can even delete
   changesets, where amend only rewrites the working directory parent.
2. smartfixup is best-effort, i.e. does not guarantee that 100% of
   user-requested modifications will be included, where amend will just take
   100% (with "-i", it's 100% chunks selected by the user).
3. a lot of "amend" flags do not make much sense to smartfixup, like message
   editing (designed to edit a single changeset), "--addremove", "--secret",
   etc.
4. literally, smartfixup shares little code with the existing "amend" logic.
   "amend" is part of "fbamend" or "evolve". this extension should not
   depend on any of them.

So it's cleaner to be a separate command, not a part of `amend`.

However, I think it makes sense to have an option to satisfy those who want
to use "amend". So they can use "amend --related", "amend --fixups",
"amend --stack", "amend --auto" or whatever they choose. This diff adds such
a config option. We may also ship such a config option to make the command
easier for discovery.

Note the "amend" version is slightly different from the original smartfixup
command. The former targets basic users who expect amend to take all of
their changes, while the latter targets power users understanding what's
going on.

Therefore, the "amend" version will print extra information about what
changes are ignored, for example:

```
# changes not applied and left in working directory:
# M a : 1 modified chunks were ignored
# M c : unsupported file type (ex. binary or link)
# R b : removed files were ignored
```

To support the above change, `fixupstate.status` was added to avoid a second
"status" run and handles the "status" with interactive mode correctly. An
issue about symbolic links being added to `fixupstate.paths` was fixed by
the way.

Test Plan: Run the newly changed test.

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3760498:1472052376:7ddbfe763c7327d044b0d471c31a58fcb1e21dac
2016-08-24 16:28:15 +01:00
Zach Amsden
f99540d161 [fastlog-hg] Thread safety
Summary:
Sharing repo.changelog across threads is problematic in mercurial
since it may internally cache things, and clearing cache while another
thread is executing is not nice.  In particular, code such as the following
is inherently raceful when sharing changelogs (or anything derived from
revlog) across threads:

    if self._cache:
        if self._cache[0] == node:
            return self._cache[2]
        cachedrev = self._cache[1]

Reworked things a bit to make sure the spawned threads have their own
newly created changelogs and member functions internally referencing them.

Test Plan:
No longer seeing random exceptions being thrown from local log
threads (which terminates iteration)

Reviewers: rmcelroy, #mercurial, ttung, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3733592:1471908572:877b56241e56b6ea92c76023460d4fbe80a4263d
2016-08-23 11:46:34 -07:00
Zach Amsden
205a3b8a81 [fastlog-hg] Better multi-path and file support for fastlog
Summary:
The multi-path support is pretty shameful; we can
do much better by issuing multiple queries and combining
results.  File support was also missing.

Test Plan:
Ran fastlog test.  Need to update test to test files.

P56589012

Reviewers: quark, rmcelroy, durham

Reviewed By: durham

Subscribers: stash, mjpieters, jeroenv

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

Tasks: 12341014

Signature: t1:3726318:1471919354:e5e8f40a5b918b493e927c2d620da1fdefa1768c
2016-08-23 11:46:34 -07:00
Zach Amsden
fe94406e9a [fastlog-hg] Add localmatch function
Summary:
Bugfix - we were failing to check local patterns in the fastpath.
Pass a filtering function to the local log thread to limit its results.

Test Plan: Run local log

Reviewers: stash, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3727573:1471907418:37b83d6c02e61ce2705070c7a86dd815a1c1cb29
2016-08-23 11:46:34 -07:00
Zach Amsden
76529f6745 [fastlog-hg] Pass revfn
Summary: Pass revfn to the thread to unify response messages.

Test Plan: Run unit test, try fastlog

Reviewers: quark, durham, rmcelroy, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3727506:1471855144:24e622c6add0584d37539ea5ee319e3454f5313e
2016-08-23 11:46:34 -07:00
Zach Amsden
31382f23a3 [fastlog-hg] Better handling of exceptions
Summary: Without this, exceptions are super hard to debug

Test Plan: Manually force exceptions with bogus array indices on non-arrays

Reviewers: quark, #mercurial, ttung, durham

Reviewed By: durham

Subscribers: stash, mjpieters

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

Tasks: 12341014

Signature: t1:3744317:1471919239:8c8d0fce6c212fd677df8b7f94a48d17dbe64b93
2016-08-23 11:46:34 -07:00
Jun Wu
36544a8c4d smartfixup: add an interactive mode
Summary:
Like `commit -i`, this diff adds an `interactive` mode. I'd like
to reuse some patching code but they are tightly coupled about
writing files to disk - while I want to handle everything in memory.

In the future I may want to add `memorystore` and `memorybackend`
to upstream's `patch.py`. But they are not available now therefore
the "patching" logic is a re-invent. Fortunately the logic is just
about 20 lines.

Test Plan:
Manually run `hg sf -i` with some manually crafted random cases.
Also make sure it works with both `text` and `curses` interfaces.

Reviewers: #mercurial, durham, ttung

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3723179:1471582313:b10d278ca5b1a2aee6b41936f315a960edee92ed
2016-08-23 15:20:20 +01:00
Jun Wu
dea474ec1f smartfixup: add command line options to preview changes
Summary:
The `--print-changes` option will show which commit, a changed lines will be
applied to. Note it is a bit expensive so we only calculate the content when
being asked.

The `--dry-run` option will prevent the final commit operation.

Users can now use `-pn` to preview changes to understand what will be changed.

Test Plan: Run `test-smartfixup.t`

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:3719673:1471582117:7f3be3c3bf3829148c3d096d2aae6e7382449b98
2016-08-23 15:19:54 +01:00
Jun Wu
a51d83bec3 smartfixup: implement the command
Summary:
This is the last piece of the initial smartfixup implementation: the command.
A new test was added to test the command.

Test Plan: Run the newly added test

Reviewers: #mercurial, ttung, jbower, durham

Reviewed By: durham

Subscribers: akushner, simonfar, durham, jbower, mjpieters

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

Signature: t1:3717354:1471629588:202e4a5820de472eb131eb968ec73f194d2c077d
2016-08-23 15:19:29 +01:00
Jun Wu
0087ee33bf smartfixup: implement fixupstate
Summary:
If `filefixupstate` is to `filecontext`, `fixupstate` is to `context`.
This does the actual committing, creating obsmarkers, moving bookmarks work.

Test Plan: A new test will be included in the next diff

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3716954:1471639171:9891a0c64365b0592f5a4d86e3c83d521b4c5bb2
2016-08-23 15:18:36 +01:00
Jun Wu
7683c76566 smartfixup: implement filefixupstate
Summary:
The `filefixupstate` object maintains states and contains logic related to
do "smartfixup" to a single file.

Test Plan: Added a new test

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3716761:1471919159:033e79e9d12307785863959dd5d82a7c3c647ff3
2016-08-23 15:17:42 +01:00
Jun Wu
98861bc86e smartfixup: add utilities
Summary:
This series is a rewrite of D3264203, using the `linelog` instead of
`histedit`. The new version has the following advantages:

  - handle more cases where it could be a merge conflict with a traditional
    merge algorithm. the old code tries to "predict" when a merge won't
    cause conflicts. but that's just kinda stupid - comparing with the new
    code using linelog - it is just impossible to produce merge conflicts.
  - do not touch working copy - all intermediate calculations and states are
    in memory. say goodbye to the clean working copy requirement of histedit.
  - handle line numbers cleanly and confidently - the old code struggles (but
    failed) to make line numbers correct after each edits, while it is
    actually hard as the "merge" operation could change line numbers in an
    unpredictable way. the new code using linelog can just edit chunks from
    an old revision, from the latest view without checking out that old
    revision first. therefore no need to mess up with line numbers.

This diff adds utility functions and classes used later. It introduces
unused `import`s but they will be used later.

Test Plan: `arc lint`

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3716758:1471556512:0fbff8f6fe4bc02d2120c723d2cc28676895c679
2016-08-23 15:16:15 +01:00
Adam Simpkins
b1540c8b8a Fix hgext3rd/__init__.py to make sure it is a namespace package
Summary:
According to the comments hg-crew, hgext3rd is supposed to be a namespace
package, so that extensions can be found in multiple different hgext3rd
directories.

However, the hgext3rd directory in fb-hgext has an empty __init__.py file,
which turns hgext3rd into a plain package instead of a namespace package,
preventing other hgext3rd directories from being found.

This fixes the __init__.py file to perform proper namespace package
initialization, as is done in the hg-crew/hgext3rd/__init__.py file

Test Plan:
Deployed this file on my server and confirmed that extensions in other hgext3rd
directories in $PYTHONPATH are still found correctly.

Reviewers: rmcelroy, durham, quark

Reviewed By: quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Tasks: 12792845

Signature: t1:3746098:1471679643:44a274807d3598a670e1742dee4cc2654f6bad97
2016-08-22 17:39:02 -07:00
Zach Amsden
bdc73e2393 [fastlog-hg] Remove limit on threads
Summary:
Limits make no sense anymore because we may be filtering
the results further.

Test Plan: fastlog unit test, run extension against fbsource

Reviewers: quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3743974:1471906692:25f48349bd70781219acdc3cf6b98134035d6236
2016-08-22 16:23:10 -07:00
Zach Amsden
64d75b4864 [fastlog-hg] Get patterns working again
Summary:
When the restriction of only working on a single directory
was dropped, pattern support was neglected.  That has to be done through
a revset, not the looser matches() filter.

Test Plan: P56588753

Reviewers: rmcelroy, quark, stash, durham

Reviewed By: durham

Subscribers: mhammell, meisner, calcsaransh, gqchen, dzhulgakov, kerl, bnitka, mjpieters

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

Tasks: 12341014

Signature: t1:3734232:1471906628:d3995b358d683383fe590fa5848d8450a0ea05dd
2016-08-22 16:21:43 -07:00
Zach Amsden
cde79943b1 [fastlog-hg] For now, import os is still required
Summary: Accidentally removed this dependency too soon

Test Plan: Run fastlog on fbcode; broken before, now fixed

Reviewers: durham, quark, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3743884:1471853021:ce470e4e42aa1c07aed624285a81824e04e70668
2016-08-22 14:46:39 -07:00
Zach Amsden
f115cd74e9 [fastlog-hg] Remove unused imports
Summary: No need for cruft

Test Plan: Load in Atom, no more complaints about unused imports

Reviewers: durham, rmcelroy, quark

Reviewed By: quark

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3733509:1471519620:08e896aaff65b545d7d16e5d46ba6a8e2a2bc186
2016-08-19 11:59:10 -07:00
Jeremy Fitzhardinge
1fd4455c73 Implement 'hg uncommit'
Summary:
TODO:
 - fix handling of empty commit (leaves stray heads)
 - add tests

Test Plan: Add mercurial unit tests

Reviewers: #mercurial, ttung, rmcelroy, durham

Reviewed By: durham

Subscribers: quark, rmcelroy, mjpieters

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

Tasks: 12340638

Signature: t1:3610409:1471398045:355f20502d917374e99feee4681a7ef6f853ad6c
2016-08-17 13:43:25 -07:00
Zach Amsden
092d645baa Fix comment for fastlog
Summary: Document how to enable the extension

Test Plan: Set this in my actual .hgrc and confirm it works.

Reviewers: durham, rmcelroy, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3721128:1471342825:e274764e036f1c03b9f8795221af6fe587990340
2016-08-16 15:55:48 -07:00
Jun Wu
fab3975b47 sshaskpass: use mkdtemp to create temporary directory
Summary:
Before this patch, sshaskpass has a hardcoded tmp directory, which, if being
abused, can break sshaskpass from working. This diff fixes the issue by
using tempfile.mkdtemp.

Test Plan:
Run `chg push -r . ssh://root@localhost//tmp/foo -f --allow-ano` and make
sure ssh password prompt works. Also run the sshaskpass test.

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3705674:1471373405:aec54ac685b060efb616307552cebcccee5cebe8
2016-08-16 19:51:47 +01:00
Zach Amsden
f1ecf43a83 Parallel callout to scmquery through conduit
Summary:
Parallel callout to scmquery through conduit
This implements the special case of log on a single directory, preserving
follow behavior.  To do this, we backtrackfrom the current head to find
 all draft revisions along the path, then find the common public ancestor of
those.  Once we find that, we can begin paging in results from the scmquery
service.

Pretty much a working diff at this point.  Limits and boundary conditions
have not been fully tested.  Every once in a while I run into a bum query,
which I suspect to be either a bad proxy or a service router failure; still
debugging that.  Could also be an issue with conduit.  Other than that,
things seem to work.

Test Plan:
Testing log with fastest setting (no revsets), revsets (using -M), and with extension disabled (--sparse):

  [zamsden@devbig192.prn1 ~/local/fbcode] time hg log tao --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 -M > a

  real	0m1.895s
  user	0m0.003s
  sys	0m0.004s
  [zamsden@devbig192.prn1 ~/local/fbcode] time hg log tao --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 > b

  real	0m1.308s
  user	0m0.005s
  sys	0m0.001s
  [zamsden@devbig192.prn1 ~/local/fbcode] diff a b
  [zamsden@devbig192.prn1 ~/local/fbcode] time hg log tao --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 --sparse > c

  real	0m7.320s
  user	0m0.004s
  sys	0m0.003s
  [zamsden@devbig192.prn1 ~/local/fbcode] diff a c




Testing --user option:



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/dragon --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 5 -u dmitri > a

  real	0m2.765s
  user	0m0.002s
  sys	0m0.004s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/dragon --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 5 -u dmitri --sparse > b

  real	0m23.247s
  user	0m0.005s
  sys	0m0.001s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource]



Testing same output enabled / disabled for -X option:



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/lithium/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 20 -X '**TARGETS' > a

  real	0m1.292s
  user	0m0.002s
  sys	0m0.003s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/lithium/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 20 -X '**TARGETS' --sparse > b

  real	0m2.697s
  user	0m0.002s
  sys	0m0.004s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource]



Testing -k option:



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/lithium/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -k 'e' -X '**TARGETS' -l 10 > a

  real	0m1.174s
  user	0m0.003s
  sys	0m0.003s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/lithium/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -k 'e' -X '**TARGETS' -l 10 --sparse > b

  real	0m1.259s
  user	0m0.004s
  sys	0m0.002s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource]



Testing -I option:



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/scm/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 20 -I '**.py' > a

  real	0m1.473s
  user	0m0.005s
  sys	0m0.003s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/scm/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 20 -I '**.py' --sparse > b

  real	0m2.911s
  user	0m0.003s
  sys	0m0.002s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource]




Testing multiple directory output in all three modes - revset, fast filtered, and forcing original fallback with --sparse



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/hphp/hhvm fbcode/hphp/runtime/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 -M > a

  real	0m2.892s
  user	0m0.003s
  sys	0m0.006s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/hphp/hhvm fbcode/hphp/runtime/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 > b

  real	0m2.575s
  user	0m0.697s
  sys	0m0.077s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/hphp/hhvm fbcode/hphp/runtime/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 --sparse > c

  real	0m7.339s
  user	0m0.003s
  sys	0m0.004s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a c
  [zamsden@devbig192.prn1 ~/local/fbsource]

Reviewers: rmcelroy, #scmquery, #mercurial, ttung, lcharignon, durham, stash

Reviewed By: stash

Subscribers: cdykes, lcharignon, quark, stash, mjpieters, jeroenv

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

Tasks: 12341014

Signature: t1:3634075:1471039212:0989839636847a8e5da6a0ef9150035fcf5bb797
2016-08-12 15:52:50 -07:00
Jun Wu
5b0b861096 sshaskpass: make the prompt similar to systemd
Summary:
This diff makes the prompt similar to what systemd does. See the screenshot:

{F62774663}

It solves an issue that with echo disabled, the user won't know whether they
have pressed ENTER or not - the cursor won't move. Now it explicitly prints
"AUTHENTICATION COMPLETE".


Test Plan: As the screenshot, and also run the sshaskpass test.

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3705703:1471008095:863ff9820b87ea3f4631295b10472802fb5e459f
2016-08-11 21:56:31 +01:00
Jun Wu
d4366acbd5 sshaskpass: use a standalone script
Summary:
Before this patch, sshaskpass will set SSH_ASKPASS to itself, aka. `__file__`.
This won't work if sshaskpass.py gets installed by setup.py because setup.py
will remove its `+x` bit.

Test Plan:
Run `chg push -r . ssh://root@localhost//tmp/foo -f --allow-ano` and make
sure ssh password prompt works.

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3705657:1471008122:9cfa3adf078e4bbe8f6b6ba05d1fb6be513d3e71
2016-08-11 21:42:54 +01:00
Jun Wu
6015a95c00 tweakdefaults: make "bookmarks" use the unfiltered repo
Summary:
We are seeing perf issues with hidden/obsolete handling.
`hg bookmark` is a frequently used command and by making it use the unfiltered
repo, it could be 200ms-300ms faster.

Test Plan: Added a new test

Reviewers: #mercurial, mitrandir, ikostia, ttung

Reviewed By: mitrandir, ikostia

Subscribers: mitrandir, rmcelroy, akushner, mjpieters

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

Signature: t1:3692968:1470777864:72ad5d0ffb52ecfcaaa607082693b88319d778fd
2016-08-11 18:43:06 +01:00
Jun Wu
cf9686ff3a morestatus: rebase takes precedence over update
Summary:
This happens when pressing Ctrl+C during "hg rebase". We should show
"interrupted rebase" instead of "interrupted update".

Test Plan: Added a new test

Reviewers: ttung, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3697984:1470863868:acd67eeb5099c73ea7df174b3e1dbcbf9ac54944
2016-08-10 22:19:30 +01:00
Oguz Ulgen
585ede8a25 Add sync status and change the conduit call to differential.querydiffhashes
Summary:
1) Add sync status
2) Combine sync status and phab status to use one unified conduit call,
i.e. differential.querydiffhashes

Test Plan:
cd hg-crew
make local
cd ../fb-hgext
make local
cd tests
../../hg-crew/tests/run-tests.py test-phabstatus.t
../../hg-crew/tests/run-tests.py test-syncstatus.t

Reviewers: wqfish, lcharignon, #sourcecontrol, wez, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Tasks: 10100400

Signature: t1:3651915:1470340328:bf003006f6afe9b86a40f204e150e0d12350c21d
2016-08-05 11:33:36 -07:00
Jun Wu
4f1d1c3291 rage: filter "FM:" from blackbox.log
Summary:
Fastmanifest debug logs in blackbox.log are less interesting in a rage report,
but they take a lot of lines. This diff uses `grep` to filter them out from rage report.

Test Plan: `hg rage --preview`

Reviewers: #mercurial, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3676751:1470421349:3b5e0cb4118473f5550e83bf9c5e7ac27a59bcb0
2016-08-05 19:17:45 +01:00
Jun Wu
bdb47a171c ownercheck: new extension to prevent operations on repos not owned
Summary:
This is mainly to address the same issue as D3609747: prevent issues caused
by running hg as root. The difference is this extension reads owner and uid
dynamically without config when initializing of a localrepo object.

As a side effect it covers more situations like running hg in others' repos, while
being less restrictive for some other commands like `sudo hg version`.

Test Plan: Added a new test

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: ikostia, rmcelroy, mjpieters

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

Tasks: 11723374

Signature: t1:3619997:1470176448:beaf53c09fca498206767641ffa4315a744ee07e
2016-07-26 13:10:15 +01:00
Tony Tung
c0e7082b92 [reporootlog] report the repo root to the scm wrappers
Summary:
The SCM wrappers do not have a reliable and easy way of detecting the repo root.  For instance, if someone does hg log /full/path/to/repo/content, we cannot actually determine that /full/path/to/repo is the repo root.  We have to somehow integrate an overly large portion of mercurial's commmand parsing infrastrastructure to accomplish this.

However, since mercurial knows the repo root, just extract that knowledge and send it down to the client.

Test Plan:
```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' --config 'extensions.reporootlog=work/facebook-hg-rpms/fb-hgext/hgext3rd/reporootlog.py'  work/facebook-hg-rpms/smoketest.sh
chg: enabled by /etc/mercurial/usechg

<snipped for brevity>

internal stats file: /tmp/scm-internal-stats5BoW29
hg profiling mode: LSPROFILER
stats: {
    "int": {
        "builddate": 1469712764,
        "cachehitratio": 50,
        "consumed": 302,
        "diffcachehitratio": -1,
        "elapsed": 130,
        "errorcode": 0,
        "filesnotincachehitratio": -1,
        "time": 1469819716
    },
    "normal": {
        "chg": "true",
        "command": "log",
        "evolution": "createmarkers",
        "evolutionext": "-*- empty -*-",
        "fastmanifest": "-*- empty -*-",
        "filesystem": "",
        "fsmonitor_ext": "-*- not present -*-",
        "fsmonitor_mode": "on",
        "fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers --config extensions.reporootlog=work\/facebook-hg-rpms\/fb-hgext\/hgext3rd\/reporootlog.py work\/facebook-hg-rpms\/smoketest.sh",
        "generaldelta": "false",
        "host": "dev8692.prn1",
        "iftype": "disconnected",
        "interactive": "true",
        "kernel": "4.0.9-30_fbk4_2311_gd3e5a5c",
        "metrics_type": "fastmanifest-filesnotincachehitratio",
        "msg": "",
        "parent": "\/bin\/bash",
        "remotefilelog": "false",
        "repo": "work\/facebook-hg-rpms",
        "scm": "hg",
        "sid": "",
        "source": "hg",
        "sqldirstate": "false",
        "sqldirstate_enabled": "-*- not present -*-",
        "sqldirstate_loaded": "-*- empty -*-",
        "sqldirstate_upgrade": "True",
        "sshclient": "localhost",
        "tw_job_cluster": "",
        "tw_job_name": "",
        "tw_job_user": "",
        "tw_oncall_team": "",
        "tw_task_id": "",
        "user": "ttung",
        "version": "3.8.4+443-d0746b"
    }
}
[dev8692]:~>
```

Without this change, the repo would be "unknown-repo":

```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' work/facebook-hg-rpms/smoketest.sh 2>&1 | grep repo
        "fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers work\/facebook-hg-rpms\/smoketest.sh",
        "repo": "unknown-repo",
[dev8692]:~>
```

Reviewers: #mercurial, rmcelroy, quark

Reviewed By: quark

Subscribers: quark, mitrandir, mjpieters

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

Tasks: 11194713

Signature: t1:3643342:1470163958:8d56291dad575c7ea7186cf5d00420798c5303ab
2016-08-02 11:59:52 -07:00
Durham Goode
c8b5839178 statprofext: import statprof from standard python path
We temporarily changed the statprof import path when it was accidentally moved
into hgext3rd. Since we've moved it out, let's fix the import here too.
2016-08-01 12:00:18 -07:00
Jun Wu
915ce74059 sshaskpass: handle the case that __file__ ends with .pyo
Summary:
We need to get the `.py` file name from `__file__`, which could be `.pyc`
and `.pyo`. Previously only `.pyc` is handled. This diff handles `.pyo`
as well.

Test Plan: Run existing tests

Reviewers: ttung, mjpieters, #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:3627929:1469625182:1c0f5f720fe7eb4cbe3e6abd8e9407ced617d2a0
2016-07-27 14:05:16 +01:00
Jun Wu
34c0e30789 sshaskpass: enable ssh to ask password if running with chg
Summary:
During chg pull or push over ssh, ssh is started by chgserver which does not
have a controlling tty. Therefore the ssh process won't be able to ask for
passwords interactively.

This is actually a hard issue because an unprivileged process without a ctty
cannot attach to a ctty of another process.

The discussion at upstream tends to make it clear it's part of limitations
of chg. Therefore if we decide to workaround it, it has to live outside core,
thus fb-hgext.

GUI ssh-askpass is actually a good and clean choice. See D3510178 and D3515604.
However, they are for OS X but not Linux.

This diff is a very hacky solution to make ssh-askpass works in terminal.
It starts a "tty server" providing tty I/O fds and set `SSH_ASKPASS` to use a
custom script talking to the "tty server".

Test Plan:
Run the new test. Start a sshd locally and try:
```
$ hg push ssh://root@localhost/tmp
pushing to ssh://root@localhost/tmp
root@localhost's password:
remote: Permission denied (publickey,password).
abort: no suitable response from remote hg!

$ chg push ssh://root@localhost/tmp
pushing to ssh://root@localhost/tmp
==== SSH Authenticating ====
root@localhost's password:
remote: Permission denied (publickey,password).
abort: no suitable response from remote hg!
```

Reviewers: #mercurial, ttung, mpm

Reviewed By: mpm

Subscribers: durham, mpm, mjpieters

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

Tasks: 12029680

Signature: t1:3577509:1469467700:cd93565bd47e535bb4cb41fcdaa39e45dddfae28
2016-07-17 20:35:34 +01:00
Martijn Pieters
481b9898e0 Remove the journal extension, fully upstreamed
Summary:
All of hg journal is now fully upstreamed to mercurial core and remotenames.
Remove the outdated copy here.

Test Plan: --

Reviewers: #mercurial, ttung

Subscribers: mjpieters

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

Tasks: 10804988
2016-07-24 00:01:33 +01:00
Durham Goode
b3a9a1ebef statprof: move statprof out of hgext3rd
Summary:
Since statprof is not an extension, it needs to be treated like a normal python
module.

Test Plan:
```
~/local/fb-hgext> python setup.py build
~/local/fb-hgext> ls build/lib.linux-x86_64-2.6/
cfastmanifest.so  hgext3rd/         sqldirstate/
fastmanifest/     phabricator/      statprof.py
```

Reviewers: ttung, #sourcecontrol, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3607202:1469216683:9aa08aee567425c239ddc5d1bb68fd892a8cf6a9
2016-07-22 12:44:59 -07:00
Mateusz Kwapich
1d2abfa980 statprof: change the hotpath to be less biased towards IO
Summary:
Let's use deltas between the subsequent samples instead of sample count
to count the time spent.

Rationale:
When the process is IO blocked the other thread doing the sampling can be waken
up much more often (GIL is not held) causing the profiler to collect much more
samples in that state.

Test Plan:
works in my sandbox
do we have any tests for statprof.py?

Reviewers: durham

Reviewed By: durham

Subscribers: quark, mjpieters, #mercurial

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

Signature: t1:3551431:1468543377:f6b86245c957dd59d0334dbb1898f6ad0bb8c617
2016-07-20 13:41:35 -07:00
Jun Wu
b0380393f2 phrevset: do not depend on hgsubversion
Summary:
`import hgsubversion` can error out if demandimport is disabled and svn
bindings are not found. In that case, we should be able to continue and
just skip handling svn revisions.

Test Plan: Code review

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3594810:1469042572:3f9ab69f5503f6925f455769a78dac42a47087de
2016-07-20 20:09:29 +01:00
Jun Wu
8a3a99ba21 hgext: move single file extensions to hgext3rd
Summary:
Be a better citizen under system python path.

Fix all tests issues and change setup.py to use glob pattern to include
all extensions.

Test Plan:
Run tests and `make local`.
Also build and install the package and run `hg sl` in major repos.

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, durham, mjpieters

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

Signature: t1:3534311:1468275426:fe122646c8bd6c541e1889e73e9df28f86747ff2
2016-07-08 13:15:42 +01:00