Commit Graph

6401 Commits

Author SHA1 Message Date
Gregory Szorc
519ece1048 sparse: move code for clearing rules to core
This is a pretty straightforward port.
2017-07-08 13:19:38 -07:00
Gregory Szorc
2689134340 sparse: move post commit actions into core
Instead of wrapping committablectx.markcommitted(), we inline
the call into workingctx.markcommitted().

Per smf's review, workingctx is the proper location for this
code, as committablectx is the shared base class for it and
memctx. Since this code touches the working directory, it belongs
in workingctx.
2017-07-07 11:51:10 -07:00
Jun Wu
ec32c2f725 histedit: use scmutil.cleanupnodes (BC)
This is marked as BC because the strip backup file name has changed.
2017-07-08 16:50:31 -07:00
Jun Wu
f9577750a4 histedit: unify strip backup files on success (BC)
Previously we wrote two different strip backup files on success. This patch
unifies them. It will make scmutil.cleanupnodes migration more smooth.
2017-07-08 16:50:31 -07:00
Jun Wu
94f02e40d4 histedit: pass multiple nodes to strip (BC)
Previously, histedit.cleanupnode pass root nodes one by one. Since
repair.strip takes multiple nodes and can handle them just fine, pass all
strip roots at once.

This is BC because the number of strip backup files may change from N to 1.
2017-07-08 16:50:31 -07:00
Jun Wu
491b12c96e histedit: remove "name" parameter from cleanupnode functions
The "name" parameter is not used any longer so let's remove it.
2017-07-08 16:50:31 -07:00
Jun Wu
83e4cd62fc histedit: remove "should strip" debug message
The debug message was not used anywhere. Removed it to make
scmutil.cleanupnodes migration easier to reason about.
2017-07-08 16:50:31 -07:00
Jun Wu
4019f12521 histedit: move topmost bookmark movement to a separate function
histedit treats topmost bookmark movement specially. The rest of the
bookmark movement could be handled by scmutil.cleanupnodes. So let's move
the special logic out to make the patch easier to review.
2017-07-08 16:47:25 -07:00
Jun Wu
e9417ea1fc histedit: remove moving bookmarks message on verbose (BC)
This is more consistent with other commands, like "commit -v" won't show
bookmark movement messages.

It will make migrating to scmutil.cleanupnodes easier.
2017-07-08 16:04:21 -07:00
Jun Wu
8046e7f0bb rebase: remove "if True"
The "if True" block was to make the last patch easier to review. This patch
removes "if True" and unindents the block.
2017-07-07 19:03:03 -07:00
Jun Wu
936199e02d rebase: use scmutil.cleanupnodes (issue5606) (BC)
This patch migrates rebase to use scmutil.cleanupnodes API. It simplifies
the code and makes rebase code reusable inside a transaction.

This is a BC because the backup file is no longer strip-backup/*-backup.hg,
but strip-backup/*-rebase.hg. The latter looks more reasonable since the
directory name is "strip-backup" so there is no need to repeat "backup".

I think the backup file name change is probably fine as a BC, since we have
changed it before (2e51c9a7a08f) and didn't get complains. The end result
of this series will be a much more consistent and unified backup names:

  command  | old backup file suffix       | new backup file suffix
  -------------------------------------------------------------------
  amend    | amend-backup.hg              | amend.hg
  histedit | backup.hg (could be 2 files) | histedit.hg (single file)
  rebase   | backup.hg                    | rebase.hg
  strip    | backup.hg                    | backup.hg

(note: backup files are under .hg/strip-backup)

It also fixes issue5606 as a side effect because the new "delayedstrip" code
path will carefully examine nodes (safestriproots) to make sure orphaned
changesets won't get stripped by accident.

Some warning messages are changed to the new "warning: orphaned descendants
detected, not stripping HASHES", which provides more information about
exactly what changesets are left behind.

Another minor behavior change is when there is an obsoleted changeset with a
successor in the destination branch, bookmarks pointing to that obsoleted
changeset will not be moved. I have commented in test-rebase-obsolete.t
explaining why that is more desirable.
2017-07-07 18:51:46 -07:00
Gregory Szorc
793c8fb431 sparse: move working directory refreshing into core
This is a pretty straightforward move of the code.

I converted the "force" argument to a keyword argument.

Like other recent changes, this code is tightly coupled with
working directory update code in merge.py. I suspect the code
will become more tightly coupled over time, possibly even moved
to merge.py. For now, let's get the code in core.
2017-07-06 14:53:08 -07:00
Gregory Szorc
7fec603f86 sparse: refactor update actions filtering and call from core
merge.calculateupdates() now filters the update actions through sparse
by default.

The filtering no-ops if sparse isn't enabled or no sparse config
is defined.

The function has been refactored to behave more like a filter
instead of a wrapper of merge.calculateupdates().

We should arguably take sparse into account earlier in
merge.calculateupdates(). This patch preserves the old behavior
of applying sparse at the end of update calculation, which is the
simplest and safest approach.
2017-07-06 16:29:31 -07:00
Gregory Szorc
7fff0417c9 sparse: move update action filtering into core
This is a relatively straight port of the function. It is pretty large.
So refactoring will be postponed to a subsequent commit.
2017-07-06 16:17:35 -07:00
Gregory Szorc
6dce563cd3 sparse: move pruning of temporary includes into core
This was our last method on the custom repo type, meaning we could
remove that custom type and inline the 2 lines of code into
reposetup().

As part of the move, instead of wrapping merge.update() from
the sparse extension, we inline the function call. The ported
function now no-ops if sparse isn't enabled, making it safe to
always call.

The call site in update() may not be the most appropriate. But
it matches the previous behavior, which is the safest thing
to do. It can be improved later.
2017-07-06 14:33:18 -07:00
Gregory Szorc
26fd8a7af7 sparse: move function for resolving sparse matcher into core
As part of the move, the function arguments changed so revs are
passed as a list instead of *args. This allows us to use keyword
arguments properly.

Since the plan is to integrate sparse into core and have it
enabled by default, we need to prepare for a sparse matcher
to always be obtained and operated on. As part of the move,
we inserted code that returns an always matcher if sparse
isn't enabled. Some callers in the sparse extension take this
into account and conditionally perform matching depending on
whether the special always matcher is seen. I /think/ this
may have sped up some operations where the extension is
installed but no sparse config is activated.

One thing I'm ensure of in this code is whether os.path.dirname()
is semantically correct. os.posixpath.dirname() (which is
exported as pathutil.dirname) might be a better choise because
all patterns should be using posix directory separators (/)
instead of Windows (\). There's an inline comment that implies
Windows was tested. So hopefully it won't be a problem. We
can improve this in a follow-up. I've added a TODO to track it.
2017-07-06 17:41:45 -07:00
Gregory Szorc
16c192411d match: move matchers from sparse into core
The sparse extension contains some matcher types that are
generic and can exist in core.

As part of the move, the classes now inherit from basematcher.
always(), files(), and isexact() have been dropped because
they match the default implementations in basematcher.
2017-07-06 17:39:24 -07:00
Gregory Szorc
0338e1f32a sparse: move config signature logic into core
This is a pretty straightforward port. It will be cleaned up in
a subsequent commit.
2017-07-06 16:11:56 -07:00
Gregory Szorc
35151669b9 sparse: remove custom hash matcher
With the recent change to always use repr(), this function was
functionally identical to the version in fsmonitor it was
replacing. So remove it.
2017-07-06 17:31:33 -07:00
Martin von Zweigbergk
585fc127ad sparse: override __repr__ in matchers
sparse.py in FB's hg-experimental repo switched to using __repr__ for
non-sparse matchers soon after hg core started overriding __repr__ in
the matchers in match.py (because the core matchers also stopped
having "includepat" and other attributes that sparse used to depend
on). Let's finish that migration by implementing __repr__ in the
sparse matchers as well. That also lets us remove the special handling
of them in _hashmatcher().
2017-07-06 16:37:36 -07:00
Phil Cohen
118b410351 largefiles: force an on-disk merge
Largefiles isn't a good candidate for in-memory merge (it uses a custom
dirstate, matcher, and the files might not fit in memory) so have it always
run an old-style merge.

Differential Revision: https://phab.mercurial-scm.org/D683
2017-09-14 13:14:32 -07:00
Jun Wu
c55a3b0058 blackbox: move _openlogfile to a separate method
This removes several `stat` syscalls for accessing `_bbvfs` and makes `ui`
object cleaner.

Differential Revision: https://phab.mercurial-scm.org/D769
2017-09-21 11:10:20 -07:00
Jun Wu
a18c4e0d85 blackbox: do not prevent 'chg init' from working
Previously, blackbox always appends to blackbox.log and creates the
directory for that file on demand. That could be an issue if:

  1. chg starts from `$REPO` directory, so `ui._bbrepo` is set.
  2. `rm -rf $REPO`.
  3. `chg init $REPO`, blackbox writes something and `init` will fail
     because `$REPO` directory is non-empty.

This patch fixes that by verifying whether vfs exists before re-using it.

Differential Revision: https://phab.mercurial-scm.org/D768
2017-09-21 11:03:37 -07:00
Martin von Zweigbergk
307606e338 rebase: also include other namespaces in changeset description
This makes use of the generic method of listing bookmarks and tags, so
other extensions that add other namespaces will get their names added
too.

This does mean that bookmarks will come before tags, just like we
apparently decided to order them in the "hg log" output. It doesn't
seem like people would be parsing the rebase output anyway. We also
did 9461eb4ff93e (rebase: use _ctxdesc in one more place, 2017-08-29)
recently, so now seems like a good time.

Differential Revision: https://phab.mercurial-scm.org/D741
2017-09-19 22:06:26 -07:00
Pulkit Goyal
00565cf47d uncommit: add an experimental.uncommitondirtywdir config
There are people who wants to do `hg uncommit` on dirty working directory, so
this patch adds a config which can be used to the achieve that.

Adds tests for the same.

Differential Revision: https://phab.mercurial-scm.org/D735
2017-09-20 02:40:25 +05:30
Pulkit Goyal
060e15ae30 uncommit: don't allow bare uncommit on dirty working directory
As per IRC discussion and suggestion by Augie, we should not allow bare `hg
uncommit` on dirty working directory.

Differential Revision: https://phab.mercurial-scm.org/D734
2017-09-20 02:18:01 +05:30
Pulkit Goyal
cbd5fda657 uncommit: rename the flag 'empty' to 'keep' which retains empty changeset
This patch renames the flag 'empty' which retains the empty changeset if all
the files are uncommitted to 'keep'.

Differential Revision: https://phab.mercurial-scm.org/D726
2017-09-16 02:34:13 +05:30
Jun Wu
042b7a7361 blackbox: set lastui even if ui.log is not called (issue5518)
`lastui` decides where (where is the `.hg`) to use if the current `ui`
object does not have a `_bbrepo` associated. Previously it only gets set in
`ui.log`, which means unless a `ui` with repo associated calls `log` with
tracked event, blackbox does not know where to write its log. This patch
makes `reposetup` set `lastui` so it so we could log some more events (see
test changes).

Differential Revision: https://phab.mercurial-scm.org/D655
2017-09-18 16:01:03 -07:00
Jun Wu
941088675f blackbox: unindent a try block
The try block is no longer necessary.

Differential Revision: https://phab.mercurial-scm.org/D654
2017-09-06 21:23:38 -07:00
Jun Wu
332711dbe5 blackbox: simplify ui states
It seems cleaner to just remove `_partialinit`, `copy`, `__init__`. This
patch makes it so by using `getattr` in `log` so those fields do not need to
be existed.

Differential Revision: https://phab.mercurial-scm.org/D652
2017-09-18 15:56:08 -07:00
Boris Feld
01eaec495b configitems: register the 'web.description' config 2017-06-30 03:45:43 +02:00
Pulkit Goyal
64bd8ed9ad uncommit: move fb-extension to core which uncommits a changeset
uncommit extension in fb-hgext adds a uncommit command which by default
uncommits a changeset and move all the changes to the working directory. If
file names are passed, uncommit moves the changes from those files to the
working directory and left the changeset with remaining committed files.

The uncommit extension in fb-hgext does not creates an empty commit like the one
in evolve extension unless user has specified ui.alllowemptycommit to True.

The test file added is a combination of tests from test-uncommit.t,
test-uncommit-merge.t and test-uncommit-bookmark.t from fb-hgext.

.. feature::

   A new uncommit extension which provides `hg uncommit` using which one can
   uncommit part or all of the changeset. This command undoes the effect of a
   local commit, returning the affected files to their uncommitted state.

Differential Revision: https://phab.mercurial-scm.org/D529
2017-08-24 22:55:56 +05:30
Gregory Szorc
545ec2de44 show: use consistent (and possibly shorter) node lengths
`hg show` makes heavy use of shortest() to limit the length of the node
hash.

For the "stack" and "work" views, you are often looking at multiple
lines of similar output for "lines" of work. It is visually appeasing
for things to vertically align. A naive use of {shortest(node, N)}
could result in variable length nodes and for the first character of
the description to vary by a column or two.

We implement a function to determine the longest shortest prefix for
a set of revisions. The new function is used to determine the printed
node length for all `hg show` views.

.. feature::

   show: use consistent node length in views

Our previous shortest node length of 5 was arbitrarily chosen.

shortest() already does the work of ensuring that a partial node
isn't ambiguous with an integer revision, which is our primary risk
of a collision for very short nodes. It should be safe to go with the
shortest node possible.

Existing code is also optimized to handle nodes as short as 4.

So, we decrease the minimum hash length from 5 to 4.

We also add a test demonstrating that prefix collisions increase the
node length.

.. feature::

   show: decrease minimum displayed hash length from 5 to 4

Differential Revision: https://phab.mercurial-scm.org/D558
2017-09-13 21:15:46 -07:00
Gregory Szorc
f95c9311db show: pass the minimum length for nodes as a template keyword
This will allow us to make the displayed length configurable
and/or dynamic.

Differential Revision: https://phab.mercurial-scm.org/D556
2017-08-03 21:51:34 -07:00
Boris Feld
5de8ff4a6a configitems: register the 'win32text.warn' config 2017-06-30 03:45:56 +02:00
Boris Feld
4345bf1f3c configitems: register the 'mq.secret' config 2017-06-30 03:43:17 +02:00
Boris Feld
470745da2b configitems: register the 'mq.plain' config 2017-06-30 03:43:16 +02:00
Boris Feld
c931b71704 configitems: register the 'mq.keepchanges' config 2017-06-30 03:43:15 +02:00
Boris Feld
96e05f8397 configitems: register the 'mq.git' config 2017-06-30 03:43:14 +02:00
Boris Feld
6c523b26e1 configitems: register the 'win32mbcs.encoding' config 2017-06-30 03:45:54 +02:00
Boris Feld
f1a318b57c configitems: register the 'convert.svn.startrev' config 2017-06-30 03:36:46 +02:00
Boris Feld
65dddb9921 configitems: register the 'convert.svn.debugsvnlog' config 2017-06-30 03:36:36 +02:00
Boris Feld
bfd6a094b8 configitems: register the 'convert.skiptags' config 2017-06-30 03:36:28 +02:00
Boris Feld
167f67866c configitems: register the 'convert.p4.startrev' config 2017-06-30 03:36:20 +02:00
Boris Feld
84900c1583 configitems: register the 'convert.localtimezone' config 2017-06-30 03:36:00 +02:00
Boris Feld
cb1096bc89 configitems: register the 'convert.ignoreancestorcheck' config 2017-06-30 03:35:55 +02:00
Boris Feld
1f2741adc0 configitems: register the 'convert.hg.usebranchnames' config 2017-06-30 03:35:48 +02:00
Boris Feld
4b94346048 configitems: register the 'convert.hg.tagsbranch' config 2017-06-30 03:35:38 +02:00
Boris Feld
fc4e98f098 configitems: register the 'convert.hg.startrev' config 2017-06-30 03:35:29 +02:00
Boris Feld
8185f63ed5 configitems: register the 'convert.hg.sourcename' config 2017-06-30 03:35:22 +02:00
Boris Feld
0e74ab2663 configitems: register the 'convert.hg.saverev' config 2017-06-30 03:35:12 +02:00
Boris Feld
4285533e9f configitems: register the 'convert.hg.revs' config 2017-06-30 03:34:58 +02:00
Boris Feld
796bce4006 configitems: register the 'convert.hg.ignoreerrors' config 2017-06-30 03:34:49 +02:00
Boris Feld
5222300c2f configitems: register the 'convert.hg.clonebranches' config 2017-06-30 03:34:45 +02:00
Boris Feld
16cc412230 configitems: register the 'convert.git.skipsubmodules' config 2017-06-30 03:34:32 +02:00
Boris Feld
1d68ca2454 configitems: register the 'convert.git.similarity' config 2017-06-30 03:34:23 +02:00
Boris Feld
66b082d31c configitems: register the 'convert.git.saverev' config 2017-06-30 03:34:14 +02:00
Boris Feld
1f1b9ffd32 configitems: register the 'convert.git.renamelimit' config 2017-06-30 03:34:06 +02:00
Boris Feld
928c7aa1bb configitems: register the 'convert.git.remoteprefix' config 2017-06-30 03:34:00 +02:00
Boris Feld
6621aa529f configitems: register the 'convert.git.findcopiesharder' config 2017-06-30 03:33:51 +02:00
Boris Feld
6186c0bccf configitems: register the 'convert.git.extrakeys' config 2017-06-30 03:33:41 +02:00
Boris Feld
7c75720e99 configitems: register the 'convert.git.committeractions' config 2017-06-30 03:33:29 +02:00
Boris Feld
c19e6a920f configitems: register the 'convert.cvsps.mergeto' config 2017-06-30 03:33:25 +02:00
Boris Feld
ad979210fc configitems: register the 'convert.cvsps.mergefrom' config 2017-06-30 03:33:15 +02:00
Boris Feld
f6e4ab41d9 configitems: register the 'convert.cvsps.fuzz' config 2017-06-30 03:33:06 +02:00
Boris Feld
fc15e4e927 configitems: register the 'convert.cvsps.cache' config
The convert extensions has code a bit all around, but it seems simpler to use a
central declaration of options at the root first.
2017-06-30 03:32:53 +02:00
Yuya Nishihara
6de6cb029d doctest: upgrade old-style "except" clause 2017-09-03 15:16:01 +09:00
Yuya Nishihara
dcc07e5503 doctest: use print_function and convert bytes to unicode where needed 2017-09-03 14:56:31 +09:00
Yuya Nishihara
a71f259bd2 doctest: bulk-replace string literals with b'' for Python 3
Our code transformer can't rewrite string literals in docstrings, and I
don't want to make the transformer more complex.
2017-09-03 14:32:11 +09:00
Phil Cohen
a1eba8f292 merge: pass wctx to premerge, filemerge
In the in-memory merge branch. we'll need to call a function (``flushall``) on
the wctx inside of _xmerge.

This prepares the way so it can be done without hacks like ``fcd.ctx()``.

Differential Revision: https://phab.mercurial-scm.org/D449
2017-09-11 13:03:27 -07:00
Augie Fackler
85e2672134 merge with stable 2017-09-12 11:18:35 -04:00
Boris Feld
ee14b96e6f configitems: register the 'eol.only-consistent' config 2017-06-30 03:39:32 +02:00
Boris Feld
a15108d159 configitems: register the 'eol.native' config 2017-06-30 03:39:26 +02:00
Boris Feld
486110b0f4 configitems: register the 'eol.fix-trailing-newline' config 2017-06-30 03:39:21 +02:00
Boris Feld
21b0f2024e configitems: register the 'patchbomb.publicurl' config 2017-06-30 03:43:43 +02:00
Boris Feld
b7f48a76b1 configitems: register the 'patchbomb.intro' config 2017-06-30 03:43:41 +02:00
Boris Feld
9eb3cb7909 configitems: register the 'patchbomb.from' config 2017-06-30 03:43:40 +02:00
Boris Feld
a72f2bfb21 configitems: register the 'patchbomb.flagtemplate' config 2017-06-30 03:43:39 +02:00
Boris Feld
956178d827 configitems: register the 'patchbomb.confirm' config 2017-06-30 03:43:38 +02:00
Boris Feld
b7bafc583d configitems: register the 'patchbomb.bundletype' config 2017-06-30 03:43:37 +02:00
Jun Wu
6192c1e941 blackbox: remove _bbvfs state
`_bbvfs` is redundant because it could be calcualted from `_bbrepo`.

Differential Revision: https://phab.mercurial-scm.org/D651
2017-09-06 21:12:27 -07:00
Jun Wu
0b73011081 blackbox: do not cache file objects
Having the blackbox file objects cached in `ui._bbfp` could in theory be
troublesome if multiple processes (ex. chg servers) have file objects
referring to a same file. (Although I spent some time and failed to build a
convincing test case)

This patch makes blackbox re-open the file every time to make the situation
better. Ideally we also need proper locking.

The caching logic traces back to the commit introducing blackbox
(18242716a). That commit does not have details about why caching is
necessary.  Consider the fact that blackbox logs are not many, it seems fine
to remove the fp cache to be more confident.

Differential Revision: https://phab.mercurial-scm.org/D650
2017-09-06 21:08:59 -07:00
Jun Wu
38ee36031d blackbox: inline _bbwrite
There is no need to make it a separate method. This makes the next change
easier to read.

Differential Revision: https://phab.mercurial-scm.org/D649
2017-09-06 20:54:53 -07:00
Jun Wu
a97d2d42cb blackbox: fix rotation with chg
The added test will show:

  $ $PYTHON showsize.py .hg/blackbox*
  .hg/blackbox.log: < 500
  .hg/blackbox.log.1: < 500
  .hg/blackbox.log.2: < 500
  .hg/blackbox.log.3: < 500
  .hg/blackbox.log.4: < 500
  .hg/blackbox.log.5: >= 500

with previous code.

The issue is caused by blackbox caching file objects *by path*, and the
rotation size check could run on a wrong file object (i.e. it should check
"blackbox.log", but `filehandles["blackbox.log"]` contains a file object
that has been renamed to "blackbox.log.5").

This patch removes the "filehandlers" global cache added by 39bd7b0c79fe to
solve the issue.

I think the original patch was trying to make different ui objects use a same
file object if their blackbox.log path is the same. In theory it could also
be problematic in the rotation case. Anyway, that should become unnecessary
after D650.

Differential Revision: https://phab.mercurial-scm.org/D648
2017-09-06 19:27:30 -07:00
Durham Goode
394bc74c72 changegroup: replace changegroupsubset with makechangegroup
As part of getting rid of all the permutations of changegroup creation, let's
remove changegroupsubset and call makechangegroup instead. This moves the
responsibility of creating the outgoing set to the caller, but that seems like a
relatively reasonable unit of functionality for the caller to have to care about
(i.e. what commits should be bundled).

Differential Revision: https://phab.mercurial-scm.org/D665
2017-09-10 18:43:59 -07:00
Jun Wu
9a0daf2508 rebase: remove unnecessary '.unfiltered()' calls
Now we have a clear centric place to control whether `rbsrt.repo` is
unfiltered or not, we can drop `unfiltered()` in other places.

Differential Revision: https://phab.mercurial-scm.org/D645
2017-09-06 16:17:04 -07:00
Jun Wu
1392df8e4d rebase: remove complex unhiding code
This is similar to Martin von Zweigbergk's previous patch [1].

Previous patches are adding more `.unfiltered()` to the rebase code. So I
wonder: are we playing whack-a-mole regarding on `unfiltered()` in rebase?

Thinking about it, I believe most of the rebase code *should* just use an
unfiltered repo. The only exception is before we figuring out a
`rebasestate`. This patch makes it so. See added comment in code for why
that's more reasonable.

This would make the code base cleaner (not mangling the `repo` object),
faster (no need to invalidate caches), simpler (less LOC), less error-prone
(no need to think about what to unhide, ex. should we unhide wdir p2? how
about destinations?), and future proof (other code may change visibility in
an unexpected way, ex.  directaccess may make the destination only visible
when it's in "--dest" revset tree).

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/094277.html

Differential Revision: https://phab.mercurial-scm.org/D644
2017-09-06 16:13:04 -07:00
Jun Wu
9bfa16c243 rebase: use unfiltered repo when loading state
Before this patch, `rebase --abort` may fail to do the cleanup:

  $ hg rebase --abort
  rebase aborted (no revision is removed, only broken state is cleared)

The added test case makes sure `--abort` works in this case.

Differential Revision: https://phab.mercurial-scm.org/D643
2017-09-06 15:23:19 -07:00
Jun Wu
8b33f0c213 rebase: do not crash rebasing merge with a parent having hidden successor
The added test will crash with previous code.

Differential Revision: https://phab.mercurial-scm.org/D640
2017-09-06 12:40:00 -07:00
Saurabh Singh
63cd1bdef8 cmdutil: remove redundant commitfunc parameter in amend (API)
Since the redundant commit during the amend has been been removed, there is no
need for commit callback function in amend now. Therefore, this commit removes
the unused parameter "commmitfunc" which was being used for this purpose.

Test Plan:
Ensured that all the tests pass

Differential Revision: https://phab.mercurial-scm.org/D635
2017-09-01 12:34:36 -07:00
Martin von Zweigbergk
cb8b36b8aa cleanup: rename "matchfn" to "match" where obviously a matcher
We usually call matchers either "match" or "m" and reserve "matchfn"
for functions.

Differential Revision: https://phab.mercurial-scm.org/D641
2017-09-05 15:06:45 -07:00
Martin von Zweigbergk
7bcdc77ac9 largefiles: remove unused assignments from wrapfunction()
The return values from wrapfunction() were never used here. Using the
value is also a little tricky and wrappedfunction() should be
preferred, so let's just delete the assignments.

There's also a bunch of return values from wrapcommand() being
assigned to a variable here, but at least that value can be (and is
used after some of the assignments).

Differential Revision: https://phab.mercurial-scm.org/D618
2017-08-31 22:39:10 -07:00
Michael Bolin
094c271fff editor: use an unambiguous path suffix for editor files
Changes the API of `ui.edit()` to take an optional `action` argument,
which is used when constructing the suffix of the temp file.
Previously, it was possible to set the suffix by specifying a `suffix` to the
optional `extra` dict that was passed to `ui.edit()`, but the goal is to
drop support for `extra.suffix` and make `action` a required argument.
To this end, `ui.edit()` now yields a `develwarn()` if `action` is not set
or if `extra.suffix` is set.

I updated all calls to `ui.edit()` I could find in `hg-crew` to specify the
appropriate `action`. This means that when creating a commit, instead
of the path to the editor file being something like:

`/tmp/hg-editor-XXXXXX.txt`

it is now something like:

`/tmp/hg-editor-XXXXXX.commit.hg.txt`

Some editors (such as Atom) make it possible to statically define a [TextMate]
grammar for files with a particular suffix. For example, because Git reliably
uses `.git/COMMIT_EDITMSG` and `.git/MERGE_MSG` as the paths for commit-type
messages, it is trivial to define a grammar that is applied when files of
either name are opened in Atom:

https://github.com/atom/language-git/blob/v0.19.1/grammars/git%20commit%20message.cson#L4-L5

Because Hg historically used a generic `.txt` suffix, it was much harder to
disambiguate whether a file was an arbitrary text file as opposed to one
created for the specific purpose of authoring an Hg commit message.

This also makes it easier to add special support for `histedit`, as it has its own
suffix that is distinct from a commit:

`/tmp/hg-histedit-XXXXXX.histedit.hg.txt`

Test Plan:
Added an integration test: `test-editor-filename.t`.

Manually tested: ran `hg ci --amend` for this change and saw that it
used `/tmp/hg-editor-ZZjcz0.commit.hg.txt` as the path instead of
`/tmp/hg-editor-ZZjcz0.txt` as the path.

Verified `make tests` passes.

Differential Revision: https://phab.mercurial-scm.org/D464
2017-08-30 20:25:56 +00:00
Augie Fackler
e2774d9258 python3: wrap all uses of <exception>.strerror with strtolocal
Our string literals are bytes, and we mostly want to %-format a
strerror into a one of those literals, so this fixes a ton of issues.
2017-08-22 20:03:07 -04:00
Jun Wu
0bba32af82 rebase: use _ctxdesc in one more place
This simplifies the code.

Differential Revision: https://phab.mercurial-scm.org/D566
2017-08-29 17:51:54 -07:00
Jun Wu
4e250e8aa3 rebase: move working parent and bookmark for obsoleted revs (BC)
Previously, obsoleted revs with successors in destination are completely
ignored. That caused some inconvenience when working copy is obsoleted. Most
commands avoid working copy being obsoleted, but `hg pull` is an exception.

This patch makes rebase able to move bookmarks or working parent for those
obsoleted revs. It does so by keeping the obsoleted revs in `state` and
marking them as "skipped, rebased to desired destination" during run-time.

This reverts part of the behavior change of 80d53a39fbcc and D24.

Differential Revision: https://phab.mercurial-scm.org/D527
2017-08-27 02:47:47 -07:00
Jun Wu
fc9e88f730 rebase: remove an unnecessary adjustdest in clearrebased
`rev` being "skipped" could currently be caused by moving `rev` does not
create a new commit. In this case, `state[rev]` is already changed to `p1`,
and is a sane destination for bookmark or working parent movement. Therefore
an additional destination adjustment is unnecessary.

Differential Revision: https://phab.mercurial-scm.org/D565
2017-08-29 17:49:13 -07:00
Jun Wu
3d0b72dc6a rebase: sort destmap topologically
Previously rebase source and destination could not overlap. But with the
multi-destination support, source and destination could reasonably partially
overlap. That requires another topological sort on `{sourcerev: destrev}`
graph (destmap). This patch implements that.

If a revision's destination is itself, the error message gets changed from
"source is ancestor of destination" to "source and destination form a
cycle". Not marking as BC since automation should depend on exit code, not
error message.

Differential Revision: https://phab.mercurial-scm.org/D470
2017-08-21 20:22:07 -07:00
Jun Wu
973c4f76d4 rebase: initial support for multiple destinations
This patch defines `SRC` (a single source revision) and `ALLSRC` (all source
revisions) to be valid names in  `--dest` revset if `--src` or `--rev` is
used. So destination could be defined differently according to source
revisions. The names are capitalized to make it clear they are "dynamically
defined", distinguishable from normal revsets (Thanks Augie for the
suggestion).

This is useful, for example, `-r 'orphan()' -d 'calc-dest(SRC)'` to solve
instability, which seems to be a highly wanted feature.

The feature is not completed, namely if `-d` overlaps with `-r`, things
could go wrong. A later patch will handle that case.

The feature is also gated by `experimental.rebase.multidest` config option
which is default off.

Differential Revision: https://phab.mercurial-scm.org/D469
2017-08-29 17:27:37 -07:00
Jun Wu
4706eacb8d rebase: change internal format to support destination map
A later patch will add multiple destination support. This patch changes
internal state and the rebase state file format to support that. But the
external interface still only supports single destination.

A test was added to make sure rebase still supports legacy state file.

The new state file is incompatible with old clients. We had done similar
state file format change before: 5eac7ab, 92409f8, and 72412af. The state
file is transient, so the impact of incompatibility is limited. Besides,
the old client won't support multiple destinations anyway so it does not
really make sense to make the file format compatible with them.

Differential Revision: https://phab.mercurial-scm.org/D348
2017-08-11 00:32:19 -07:00
Jun Wu
7eaa8f29d7 rebase: rewrite _computeobsoletenotrebased
The old code stores successors of all related nodes together, which works
fine if destination is unique. A future patch would make destination
non-unique so let's change the implementation to test successors for
rebaseset separately.

Differential Revision: https://phab.mercurial-scm.org/D347
2017-08-11 00:31:52 -07:00
Rishabh Madan
f35bfd559f releasenotes: view admonition titles using -l flag
Since this extension is fairly new for almost all the contributors, remembering
the admonition (with titles) is difficult. The list (-l) flag provides
a list of all the active admonitions along with titles.

For usage, hg releasenotes -l returns the list.

Differential Revision: https://phab.mercurial-scm.org/D454
2017-08-28 04:11:58 +05:30
Jun Wu
00a74fd4f2 journal: do not use atomictemp (issue5338)
Writing journal files using `atomictemp` leads to quadratic performance that
could be problematic if automation runs many commands. Other logs like
blackbox does not use atomictemp, and journal logs are not critical for repo
correctness. So let's make them non-atomictemp.

Differential Revision: https://phab.mercurial-scm.org/D517
2017-08-24 21:43:54 -07:00
Rishabh Madan
973eda14de releasenotes: add check flag for use of admonitions and its validity
While using releasenotes extension, we will be using admonitions in commit messages.
The check (-c) flag will look for an admonition within the message. If it exists, it will
verify if it is stated under default or custom admonition. The check fails if the
admonition is not present in any of them. It also suggests similar admonitions
in case the admonition is invalid.

Differential Revision: https://phab.mercurial-scm.org/D368
2017-08-13 19:58:45 +05:30
Jun Wu
d84c305f2a rebase: only change self.state when collapsing in _finishrebase
When the code executes to _finishrebase, self.state should be populated with
correct destinations and do not need to be written to a node. The code was
introduced by 8dc45c9059, which seems to avoid setting state values to None
but it didn't provide more details.

Differential Revision: https://phab.mercurial-scm.org/D346
2017-08-11 01:34:11 -07:00
Jun Wu
13f8aae09c rebase: choose merge base without unwanted revisions
Previously, when there are 2 merge base candidates, we choose p1 blindly,
which may make the merge result to have "unwanted content". This patch makes
rebase smarter - choose a merge base that does not have "unwanted revs" if
possible. Since we don't really have a good solution when there are
"unwanted revs", abort in that case.

Differential Revision: https://phab.mercurial-scm.org/D340
2017-08-10 22:17:15 -07:00
Jun Wu
7c75b06935 rebase: optimize "source" calculation in adjustdest
The "source" variable is calculated inside a loop but it does not depend on
loop variables. Therefore move it outside the loop.

Differential Revision: https://phab.mercurial-scm.org/D345
2017-08-11 01:08:07 -07:00
Jun Wu
7793d2cdf5 rebase: remove "state >= revtodo" condition
Now the minimal value of state is revtodo, that condition is always true,
therefore removed.

Differential Revision: https://phab.mercurial-scm.org/D344
2017-08-11 01:36:59 -07:00
Jun Wu
0c8152cb4c rebase: remove self.destancestors
The state is no longer used after calculating "self.external", therefore
removed.

Differential Revision: https://phab.mercurial-scm.org/D343
2017-08-11 01:05:47 -07:00
Jun Wu
e1a6ae2bac rebase: remove rebaseset from _checkobsrebase
The parameter is not used. Therefore removed.

Differential Revision: https://phab.mercurial-scm.org/D85
2017-07-14 09:01:45 -07:00
Jun Wu
79f323ea22 rebase: remove revignored and nullmerge states
They are no longer necessary to make rebase behavior correct. Therefore
remove them to make the code cleaner and easier to reason about.

Differential Revision: https://phab.mercurial-scm.org/D26
2017-07-10 12:18:32 -07:00
Jun Wu
075caa84b6 rebase: remove messages for nullmerge and revignored (BC)
These states will be removed to make the code cleaner and more robust.
Remove their messages first to make review easier.

Differential Revision: https://phab.mercurial-scm.org/D25
2017-07-08 20:38:34 -07:00
Jun Wu
0f5023c94c rebase: remove revprecursor and revpruned states (BC)
Those states are no longer necessary for rebase to function properly. Remove
them to make the code cleaner.

Marked as BC because in a corner case where working parent is obsoleted, and
is skipped for rebase, we no longer move working parent after rebase
completes. That is better since if working parent is obsoleted, it should be
the user moving working parent back there (after a rebase) explicitly, in
that case, we shouldn't move working parent again.

Differential Revision: https://phab.mercurial-scm.org/D24
2017-07-08 20:38:34 -07:00
Jun Wu
d763d13686 rebase: move obsoleted not rebased messages earlier (BC)
A later patch will clean up those states. This patch moves the messages
earlier.

Marked as BC since the order of message has changed.

Differential Revision: https://phab.mercurial-scm.org/D23
2017-07-08 20:14:33 -07:00
Jun Wu
5fe54ecae3 rebase: extract ctx description logic to a function
The function will be used in a later patch.

Differential Revision: https://phab.mercurial-scm.org/D22
2017-07-08 20:05:52 -07:00
Augie Fackler
a80f148d0c py3: introduce a wrapper for __builtins__.{raw_,}input()
In order to make this work, we have to wrap the io streams in a
TextIOWrapper so that __builtins__.input() can do unicode IO on Python
3. We can't just restore the original (unicode) sys.std* because we
might be running a cmdserver, and if we blindly restore sys.* to the
original values then we end up breaking the cmdserver. Sadly,
TextIOWrapper tries to close the underlying stream during its __del__,
so we have to make a sublcass to prevent that.

If you see errors like:

TypeError: a bytes-like object is required, not 'str'

On an input() or print() call on Python 3, the substitution of
sys.std* is probably the root cause.

A previous version of this change tried to put the bytesinput() method
in pycompat - it turns out we need to do some encoding handling, so we
have to be in a higher layer that's allowed to use
mercurial.encoding.encoding. As a result, this is in util for now,
with the TextIOWrapper subclass hiding in encoding.py. I'm not sure of
a better place for the time being.

Differential Revision: https://phab.mercurial-scm.org/D299
2017-07-24 14:38:40 -04:00
FUJIWARA Katsunori
d3e11740a0 largefiles: fix help text to avoid warning at "make update-pot"
This change helps hggettext to find out help text in original source,
because it assumes that backslash ('\') is doubled in docstring.
2017-08-02 01:15:07 +09:00
Jun Wu
7a9096496d rebase: change "result would have 3 parent" error message (BC)
The old error message "cannot use revision REV as base, result would have 3
parents" is confusing - why use REV as base? why add a new parent?.

This patch changes it to "cannot move parent", which seems better.

Differential Revision: https://phab.mercurial-scm.org/D342
2017-08-12 21:01:06 -07:00
Jun Wu
87f820de49 rebase: rewrite core algorithm (issue5578) (issue5630)
"defineparents" is the core algorithm of rebase. The old code has too many
tech debts (like outdated comments, confusing assertions, etc) and is very
error-prone to be improved. This patch rewrites "defineparents" to make the
code easier to reason about, and solve a bunch of issues, including:

  - Assertion error: no base found (demonstrated by D212, issue5578)
  - Asymmetric result (demonstrated by D211, "F with one parent")
  - Wrong new parent (demonstrated by D262, "C':A'A'")
  - "revlog index out of range" (demonstrated by D262, issue5630)
  - "nothing to merge" (demonstrated by D262)

As a side effect, merge base decision has been made more solid - rebase now
prints out explicitly what could go wrong when it cannot find a unique
suitable merge base.

.. fix:: Issue 5578, Issue 5630

   Core rebase algorithm has been rewritten to be more robust.

Differential Revision: https://phab.mercurial-scm.org/D21
2017-08-10 21:30:31 -07:00
Rishabh Madan
4829d3de30 releasenotes: minor bug fix for index error while serializing
Differential Revision: https://phab.mercurial-scm.org/D356
2017-08-12 09:21:42 +05:30
Jun Wu
c218b8b432 fsmonitor: correct an error message
Without the change, the error looks like:

  warning: Watchman unavailable: "watchman" executable not in PATH (%s),
  while executing [Errno 2] No such file or directory

With the change, it now looks like:

  warning: Watchman unavailable: "watchman" executable not in PATH
  ([Errno 2] No such file or directory)

Differential Revision: https://phab.mercurial-scm.org/D322
2017-08-10 09:37:50 -07:00
Gregory Szorc
ad1ddbea6f largefiles: remove remotestore.batch()
This method was added in 6fb54510b150. AFAICT it didn't do anything at
inception. If it did, there was no test coverage for it because
changing it to raise doesn't fail any tests at that revision.

3bcb9f9a4a63 later refactored all remote.batch() calls to
remote.iterbatch(). So if this was somehow used, it isn't called
any more because there are no calls to .batch() remaining in the
repo.

I suspect the original patch author got confused by the distinction
between the peer/remote interface and the largefiles store. The lf
store is a gateway to a peer instance. It exposes additional
lf-specific methods to execute against a peer. However, it is not
a peer and doesn't need to implement batch() because peer itself
does that.

Differential Revision: https://phab.mercurial-scm.org/D316
2017-08-09 21:04:03 -07:00
André Klitzing
fb861bea86 histedit: check first changeset for verb "roll" or "fold" (issue5498)
If someone changes "pick" to "roll" or "fold" for the first
changeset in a histedit rule Mercurial could remove a wrong
changeset if the phase is non-public.

roll or fold for the first changeset should be invalid.
2017-08-11 15:20:41 +02:00
Boris Feld
b1539c55c0 configitems: register the 'notify.test' config 2017-06-30 03:43:31 +02:00
Boris Feld
a40deebbae configitems: register the 'notify.template' config 2017-06-30 03:43:30 +02:00
Boris Feld
540c73467b configitems: register the 'notify.style' config 2017-06-30 03:43:29 +02:00
Boris Feld
a8dced4101 configitems: register the 'notify.strip' config 2017-06-30 03:43:28 +02:00
Boris Feld
f3bd1de48b configitems: register the 'notify.sources' config 2017-06-30 03:43:27 +02:00
Boris Feld
d32ccbab59 configitems: register the 'notify.merge' config 2017-06-30 03:43:26 +02:00
Boris Feld
43c3734660 configitems: register the 'notify.mbox' config 2017-06-30 03:43:25 +02:00
Boris Feld
a8548941d5 configitems: register the 'notify.maxsubject' config 2017-06-30 03:43:24 +02:00
Boris Feld
183f3607c4 configitems: register the 'notify.maxdiff' config 2017-06-30 03:43:23 +02:00
Boris Feld
9400d81aec configitems: register the 'notify.fromauthor' config 2017-06-30 03:43:22 +02:00
Boris Feld
0e80269f91 configitems: register the 'notify.domain' config 2017-06-30 03:43:20 +02:00
Boris Feld
77b5c0d17a configitems: register the 'notify.diffstat' config 2017-06-30 03:43:19 +02:00
Boris Feld
16425ec90a configitems: register the 'notify.config' config 2017-06-30 03:43:18 +02:00
Augie Fackler
ef945af30b merge with stable 2017-08-10 18:55:33 -04:00
Augie Fackler
9a0febea27 merge with stable 2017-08-10 14:23:41 -04:00
Rishabh Madan
0c4fe49845 releasenotes: add similarity check function to compare incoming notes
It is possible that the incoming note fragments have some similar content as the
existing release notes. In case of a bug fix, we match for issueNNNN in the
existing notes. For other general cases, it makes use of fuzzywuzzy library to get
a similarity score. If the score is above a certain threshold, we ignore the
fragment, otherwise add it. But the score might be misleading for small commit
messages. So, it uses similarity function only if the length of string (in words)
is above a certain value. The patch adds tests related to its usage. But it needs
improvement in the sense of combining incoming notes. We can use interactive mode
for adding notes. Maybe we can do this if similarity is under a certain range.
2017-08-05 05:25:36 +05:30
Kostia Balytskyi
ebe8e04f0d sparse: treat paths as cwd-relative
This commit makes it so sparse treats passed paths as CWD-relative,
not repo-root-realive. This is a more intuitive behavior in my (and some
other FB people's) opinion.

This is breaking change however. My hope here is that since sparse is
experimental, it's ok to introduce BCs.

The reason (glob)s are needed in the test is this: in these two cases we
do not supply path together with slashes, but `os.path.join` adds them, which
means that under Windows they can be backslashes. To demonstrate this behavior,
one could remove the (glob)s and run `./run-tests.py test-sparse.t` from
MinGW's terminal on Windows.
2017-08-04 05:38:22 -07:00
Durham Goode
87e4b5267e rebase: use one dirstateguard for when using rebase.singletransaction
This was previously landed as 4bc0c14fb501 but backed out in b63351f6a2 because
it broke hooks mid-rebase and caused conflict resolution data loss in the event
of unexpected exceptions. This new version adds the behavior back but behind a
config flag, since the performance improvement is notable in large repositories.

The old commit message was:

Recently we switched rebases to run the entire rebase inside a single
transaction, which dramatically improved the speed of rebases in repos with
large working copies. Let's also move the dirstate into a single dirstateguard
to get the same benefits. This let's us avoid serializing the dirstate after
each commit.

In a large repo, rebasing 27 commits is sped up by about 20%.

I believe the test changes are because us touching the dirstate gave the
transaction something to actually rollback.
(grafted from 9e3dc3a1638b9754b58a0cb26aaa75d868058109)
(grafted from 7d38b41d2266d9a02a15c64229fae0da5738dcec)

Differential Revision: https://phab.mercurial-scm.org/D135
2017-07-20 01:30:41 -07:00
Martin von Zweigbergk
e9ccfc8938 shelve: don't reimplement mergestate.unresolved() 2015-12-01 09:19:54 -08:00
Gregory Szorc
fa7c02cef4 sparse: move some temporary includes functions into core
Functions for reading and writing the tempsparse file have been
moved. prunetemporaryincludes() will be moved separately
because it is non-trivial.
2017-07-06 14:48:16 -07:00
Gregory Szorc
23bd6434bf sparse: move config file writing into core
The code was refactored during the move to be more procedural
instead of using string formatting. This has the benefit of not
writing empty sections, which changed tests.
2017-07-06 12:24:55 -07:00
Gregory Szorc
0cd417305b localrepo: add sparse caches
The sparse extension maintains caches for the sparse files
to a signature and a signature to a matcher. This allows the
sparse matchers to be resolved quickly, which is apparently
something that can occur in loops.

This patch ports the sparse caches to the localrepo class
pretty much as-is. There is potentially room to improve the
caching mechanism. But that can be done as a follow-up.

The default invalidatecaches() now clears the relevant sparse
cache. invalidatesignaturecache() has been moved to sparse.py.
2017-07-06 12:20:53 -07:00
Gregory Szorc
82797a75d4 sparse: move active profiles function into core
Also includes some light formatting changes.
2017-07-06 12:26:04 -07:00
Gregory Szorc
b77eafa212 sparse: move resolving of sparse patterns for rev into core
This method is reasonably well-contained and simple to move.

As part of the move, some light formatting was performed.

A "working copy" reference in an error message was changed to
"working directory."

The biggest change was to _refreshoncommit() in sparse.py. It
was previously checking for the existence of an attribute on
the repo instance. Since the moved function now returns empty
data if sparse isn't enabled, we unconditionally call the
new function. However, we do have to protect another method
call in that function. This will all be unhacked eventually.
2017-07-06 12:15:14 -07:00
Gregory Szorc
19d9143b89 sparse: variable to track if sparse is enabled
Currently, the sparse extension sniffs repo instances for
attributes defined by the sparse extension to determine if
sparse is enabled. As we move code away from repo instances,
these checks will be a bit more brittle.

We introduce a module-level variable to track whether sparse is
enabled as a temporary workaround.
2017-07-06 12:06:37 -07:00
Gregory Szorc
c16ee0ee8c sparse: move profile reading into core
One more step towards weaning off methods on repo instances and
moving code to core. While this function is only used once and
is simple, it needs to exist on its own so Facebook can monkeypatch
it to enable simplecache integration.
2017-07-06 12:14:12 -07:00
Gregory Szorc
2316ea9a38 sparse: move config parsing into core
This patch marks the beginning of moving code from the sparse
extension into core. The goal is to move as much of the
functionality as possible into core, where it will be an
experimental feature. The extension will likely continue to
exist to enable the feature and provide UI elements.

As part of the move, the repo method was converted to a module
function. It doesn't need to exist on repos.

An error message was also updated to reflect that an error isn't
necessarily from the .hg/sparse file. The API should be updated
later to pass in a filename so the error can be more descriptive.

Copyright of the added file was copied from the sparse extension.
2017-07-06 12:14:03 -07:00