Commit Graph

57 Commits

Author SHA1 Message Date
Jun Wu
e8b4af8f69 test-rebase-collapse: rewrite the entire test
Summary:
Rewrite the test:
- Use drawdag to create test repos.
- Use commit hash instead of revision numbers for new test cases.
- Remove unrelated test cases (ex. strip, branch heads).
- Remove use of named branch.

Differential Revision: D13993823

fbshipit-source-id: d20954dec1b39313f08699f796d5db167dfee641
2019-02-12 21:45:10 -08:00
Jun Wu
8c4a52d608 config: enable obsstore by default
Summary:
This makes tests closer to production setup and removes a bunch of "saved
backup bundle to ..." messages.

With D9236657, this should not hurt server-side performance.

Unfortunately a lot tests cannot be migrated easily, mostly because revision
numbers are used. They are left with a TODO.

Reviewed By: DurhamG

Differential Revision: D9237694

fbshipit-source-id: c993fce18f07aba09f6d70964e248af8d501575a
2018-10-26 18:54:40 -07:00
Phil Cohen
3e592b81ae filemerge: add number of textual conflicts in each file to error message
Summary:
When you get an error, let's print the number of conflicts in each file. This will give the user some sense of how much work they have to do.

The code change is entirely in `filemerge.py`, and `tests/test-merge-conflict-count.t` adds a new test.

Reviewed By: quark-zju

Differential Revision: D9815243

fbshipit-source-id: 1b73a1db293902ac7242997a7d6ae09478344068
2018-10-22 12:47:41 -07:00
Phil Cohen
917604f2f5 tests: fold tglog into tinit; standardize
Summary:
Like D9323267, hg tests commonly reinvent common aliases to render the DAG, and they often differ very slightly. This makes adding a test require more boilerplate, and reading a test in a foreign new area slightly more overhead.

Let's standardize these to reduce the copypasta.

It's necessary to define this as a shell function instead of an hgrc alias to prevent tests that list aliases from printing it. Plus that enforces a nice separation of test/stdlib logic.

Bookmarks and branches are easy enough to add since they're empty if not used. A good number added `{phase}` -- I renamed this to `tglogp`.

Reviewed By: quark-zju

Differential Revision: D9347072

fbshipit-source-id: 6aac7de3e65d2295a7ebecd2ab30901709af3ff1
2018-08-16 10:53:43 -07:00
Jun Wu
4337aee636 mq: remove the extension
Summary:
mq is already somehow problematic at D8907646. Without bandwidth supporting
it, let's remove it.

Alternative to mq would be rebase, shelve, unshelve, histedit.

Maintain "--config extensions.mq=" compatibility by marking it builtin so hg4idea
won't break by this change.

Reviewed By: phillco

Differential Revision: D9039741

fbshipit-source-id: a3a1e48a2a982ff8e8b6a6ce659c906a4e2b2b36
2018-07-30 08:49:26 -07:00
Jun Wu
af17261b14 treestate: enable by default
Summary:
Enable it by default so all tests run with it.

The test changes are mostly caused by repo requirement changes.

Reviewed By: DurhamG

Differential Revision: D8880991

fbshipit-source-id: f96cecfd85b8088098c3b55d06ab0374ee93437b
2018-07-27 18:04:56 -07:00
Jun Wu
40301faa80 test-rebase-collapse: use treestate
Summary:
The test reveals some copy handling issues in treestate:
- copyfile can be called to override a previous copyfile source information.
- drop or remove file should reset the file's copy information.

I hope we'll clean up dirstate. The main problem of it is the "setparents" API,
it changes the parents directly, leaving it to the caller to make sure the rest
of the dirstate is in sync with repo and filesystem state. And it's super
unclear what the callers are supposed to do exactly in these cases. Ideally
there is no "setparents" API on dirstate or the repo object. The low-level
building blocks (merge or clean update) would make sure the tree is in a
consistent state and nobody else (esp. rebase) can ever change dirstate parents
directly.

Reviewed By: DurhamG

Differential Revision: D8869842

fbshipit-source-id: b7882dfe60508fa6bbcfb99e30e507dc297a1d83
2018-07-17 16:06:07 -07:00
Jun Wu
7fa918cefd perftweaks: move commit head detection removal logic to core
Summary: Also change the internal API so it no longer accepts the "heads" argument.

Reviewed By: ryanmce

Differential Revision: D6745865

fbshipit-source-id: 368742be49b192f7630421003552d0a10eb0b76d
2018-04-13 21:50:52 -07:00
Matt Harbison
7d8bebd9c1 tests: remove (glob) annotations that were only for '\' matches
# skip-blame because this was mechanically rewritten the following script.  I
ran it on both *.t and *.py, but none of the *.py changes were proper.  All *.t
ones appear to be, and they run without addition failures on both Windows and
Linux.

  import argparse
  import os
  import re

  ap = argparse.ArgumentParser()
  ap.add_argument('path', nargs='+')
  opts = ap.parse_args()

  globre = re.compile(r'^(.*) \(glob\)(.*)$')

  for p in opts.path:
      tmp = p + '.tmp'
      with open(p, 'rb') as src, open(tmp, 'wb') as dst:
          for line in src:
              m = globre.match(line)
              if not m or '$LOCALIP' in line or '*' in line:
                  dst.write(line)
                  continue
              if '?' in line[:-3] or ('?' in line[:-3] and line[-3:] != '(?)'):
                  dst.write(line)
                  continue
              dst.write(m.group(1) + m.group(2) + '\n')
      os.unlink(p)
      os.rename(tmp, p)
2017-12-10 22:50:57 -05:00
Phil Cohen
86be3bceed tests: add commit hashes to log commands in rebase tests
Commit hashes are a useful way to ensure the content of commits made in the
tests are not changing, even if we don't query every aspect of every commit.
(And some properties, like extras, are rarely printed at all.)

Many of the rebase log -G calls didn't show hashes; by adding hashes to places
that weren't showing them we can help protect those tests from unwanted
changes.

Differential Revision: https://phab.mercurial-scm.org/D1650
2017-12-10 21:57:37 -08:00
Denis Laxalde
9efc7f05e3 transaction-summary: show the range of new revisions upon pull/unbundle (BC)
Upon pull or unbundle, we display a message with the range of new revisions
fetched. This revision range could readily be used after a pull to look out
what's new with 'hg log'. The algorithm takes care of filtering "obsolete"
revisions that might be present in transaction's "changes" but should not be
displayed to the end user.
2017-10-12 09:39:50 +02: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
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
Pierre-Yves David
70672e4541 rebase: backed out changeset 4bc0c14fb501
In the process of fixing issue5610 in 4.2.2, we are trying to backout
507f16f4aa51. This changeset is making changes that depend on 507f16f4aa51,
so we need to back it out first.

Since issue5610 is pretty serious regression and the next stable release is a
couple of days away, we are taking the backout route until we can figure out
something better to do.
2017-06-27 17:39:55 +02:00
Durham Goode
c54132949d rebase: use one dirstateguard for entire rebase
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.
2017-03-19 11:54:15 -07:00
Kostia Balytskyi
279f8962a7 conflicts: make spacing consistent in conflict markers
The way default marker template was defined before this patch,
the spacing before dash in conflict markes was dependent on
whether changeset is a tip one or not. This is a relevant part
of template:
    '{ifeq(tags, "tip", "", "{tags} "}'
If revision is a tip revision with no other tags, this would
resolve to an empty string, but for revisions which are not tip
and don't have any other tags, this would resolve to a single
space string. In the end this causes weirdnesses like the ones
you can see in the affected tests.

This is a not a big deal, but double spacing may be visually
less pleasant.

Please note that test changes where commit hashes change are
the result of marking files as resolved without removing markers.
2016-11-19 15:41:37 -08:00
liscju
6f96ec5bd7 rebase: adds storing collapse message (issue4792)
Before this patch collapse message wasn't stored so when
you ran into the merge conflict while rebasing, running
rebase --continue didn't remember the message and
always opened editor to fill commit message.

This patch adds saving collapse message in
.hg/last-message.txt and restoring it later
when needed.
2016-02-17 22:45:01 +01:00
Pierre-Yves David
7a525b7661 tests: add an explicit destination in some rebase tests
As we will make 'rebase' behave more like 'merge', it will no longer pick
'max(branch(.))' as the default destination. We have to hard code the expected
destination is multiple tests where it matters. After a careful inspection none
of theses tests really cares about the default destination behavior and just
omitted one out of laziness.
2016-02-08 14:03:45 +01:00
Mads Kiilerich
58681faacf rebase: fix wrong 'no changes to commit' when using --collapse
--collapse will do that rebase doesn't commit until the final commit. The lack
of a new commit would make it look like the rebase didn't contribute any
changes.

Instead, only warn about no commits when not using --collapse.
2015-10-19 16:29:35 +02:00
Matt Mackall
1b6a04b2ec branch: don't warn about branches if repository has multiple branches already
This warning exists to prevent git users from prematurely polluting
their namespace when trying out Mercurial. But for repos that already
have multiple branches, understanding what branches are is not
optional so we should just shut up.
2015-05-22 17:08:59 -05:00
Durham Goode
2591767a70 bundles: do not overwrite existing backup bundles (BC)
Previously, a backup bundle could overwrite an existing bundle and cause user
data loss. For instance, if you have A<-B<-C and strip B, it produces backup
bundle B-backup.hg. If you then hg pull -r B B-backup.hg and strip it again, it
overwrites the existing B-backup.hg and C is lost.

The fix is to add a hash of all the nodes inside that bundle to the filename.
Fixed up existing tests and added a new test in test-strip.t
2015-01-09 10:52:14 -08:00
Mads Kiilerich
046399e6dc rebase: show warning when rebase creates no changes to commit
Similar to graft:
  note: rebase of 6:eea13746799a created no changes to commit
2014-12-10 06:20:35 +01:00
Mads Kiilerich
0419ad5c23 rebase: show more useful status information while rebasing
Show status messages while rebasing, similar to what graft do:
  rebasing 12:2647734878ef "fork" (tip)

This gives more context for the user when resolving conflicts.
2014-12-09 03:45:26 +01:00
Mads Kiilerich
b3802652b5 tests: make 'saved backup' globbing less narrow in rebase tests
Globbing the hash made it harder to maintain tests with run-tests -i when it
was so far by the generated test output.

The hashes are stable and we just need to add a (glob).
2014-12-07 20:04:45 +01:00
Matt Mackall
a44416ab0f dirstate: properly clean-up some more merge state on setparents 2014-10-10 13:05:50 -05:00
FUJIWARA Katsunori
e51e2fef65 rebase: use "rebase.collapse" as "editform" for "--collapse" always
Before this patch, if both "--message" and "--collapse" are specified
for "hg rebase", "rebaes.normal" is used as "editform" unexpectedly.

Unlike patches before and after in this series for improvement, this
is bug fix patch.
2014-08-15 23:05:53 +09:00
Mads Kiilerich
a0f70f6a56 merge: keep destination filename as key in filemerge actions
Gives more readable debug output and makes it possible to compare/merge actions
later.
2014-03-02 18:52:16 +01:00
FUJIWARA Katsunori
3a5dd1f5ac rebase: use "commitforceeditor" instead of "ui.edit()" for "--collapse"
Before this patch, "rebase --collapse --edit" without "--message" and
"--logfile" invokes editor twice unexpectedly:

  1. explicit "ui.edit()" invocation in rebase extension itself

  2. indirect invocation in "localrepository.commit()" with "editor =
     commitforceeditor" assigned by "--edit" option

This patch uses indirect "commitforceeditor" invocation instead of
"ui.edit()" for "--collapse" without "--message" and "--logfile" to:

  - suppress redundant the former invocation
  - ensure editor invocation even when "--edit" is not specified
2014-03-19 01:07:41 +09:00
Brodie Rao
a446720e09 branchmap: cache open/closed branch head information
This lets us determine the open/closed state of a branch without
reading from the changelog (which can be costly over NFS and/or with
many branches).
2013-09-16 01:08:29 -07:00
Martin Geisler
7316194bdf tests: don't load unnecessary graphlog extension
Since graphlog is in core, we can use 'hg log -G' instead.
2013-11-22 19:14:17 +01:00
Durham Goode
e692055e06 rebase: fix working copy location after a --collapse (issue4080)
Rebasing with --collapse would leave the working copy on the parent of the
collapsed commit, instead of on the collapsed commit.  This fixes that.  Also
fixes a few tests that already covered this area but had bad data.

This also fixes issue3716 where bookmarks are not kept across rebases with
--collapse. I updated the test to cover that case as well.
2013-11-01 17:08:06 -07:00
Mads Kiilerich
0f5241006f rebase: improve error message for more than one external parent 2013-10-23 23:42:13 +08:00
Pierre-Yves David
a9b7960ae6 rebase: preserve working directory parent (BC)
Prior to this changeset, rebase always left the working directory as a parent of
the last rebased changeset. The is dubious when, before the rebase, the working
directory was not a parent of the tip most rebased changeset.

With this changeset, we move the working directory back to its original parent.
If the original parent was rebased, we use it's successors.

This is a step toward solving issue3813 (rebase loses active bookmark if it's
not on a head)
2013-10-14 16:12:29 +02:00
Pierre-Yves David
681ea926e5 tests: prepare rebase test for wc parent preservation
In the way to solving issue3813 we'll preserve the working directory parent
after the rebase. Multiple rebases test expect the working directory parent to
be tip after rebase. We patches them before the actual change to prevent
confusion.
2013-10-14 16:49:54 +02:00
Durham Goode
474ac2b31e rebase: fix --collapse when a file was added then removed
When a series of commits first adds a file and then removes it,
hg rebase --collapse prompts whether to keep the file or delete it. This is
due to it reusing the branch merge code. In a noninteractive terminal it
defaults to keeping the file, which results in a collapsed commit that is
has a file that should be deleted. This bug resulted in developers accidentally
commiting unintentional changes to our repo twice today, so it's fairly
important to get fixed.

This change allows rebase --collapse to tell the merge code to accept the
latest version every time without prompting.

Adds a test as well.
2013-03-15 11:23:29 -07:00
Mads Kiilerich
ef317883c7 export: show 'Date' header in a format that also is readable for humans
'export' is the official export format and used by patchbomb, but it would only
show date as a timestamp that most humans might find it hard to relate to. It
would be very convenient when reviewing a patch to be able to see what
timestamp the patch will end up with.

Mercurial has always used util.parsedate for parsing these headers. It can
handle 'all' date formats, so we could just as well use a readable one.

'export' will now use the format used by 'log' - which is the format described
as 'Unix date format' in the templating help. We assume that all parsers of '#
HG changeset patch'es can handle that.
2013-02-08 22:54:17 +01:00
Durham Goode
fe6e42c6ab bookmark: don't allow integers as bookmark/branch/tag names
Bookmarks/branches/tags shouldn't be allowed to be integers because that
overlaps with revision numbers.  Right now if a user created one they can't
use it anyway because the revision numbers take precedence.

The check only happens when creating a new bookmark/etc from a command so it
shouldn't affect existing bookmarks/branches/tags or importing branches from
git.

This fix was prompted by us having a user create a bookmark named "404" then
accidentally checkout a very old version of our repository.
2013-02-05 16:22:53 -08:00
Pierre-Yves David
f72cabb4c0 destroyed: drop complex branchcache rebuilt logic
The strip code used a trick to lower the cost of branchcache update after a
strip. However is less necessary since we have branchcache collaboration.
Invalid branchcache are likely to be cheaply rebuilt again a near subset of the
repo.

Moreover, this trick would need update to be relevant in the now filtered
repository world. It currently update the unfiltered branchcache that few people
cares about. Make it smarter on that aspect would need complexes update of the
calling logic


So this mechanism is:
- Arguably needed,
- Currently irrelevant,
- Hard to update
and I'm dropping it.

We now update the branchcache in all case by courtesy of the read only reader.

This changeset have a few expected impact on the testsuite are different cache
are updated.
2013-01-16 00:09:26 +01:00
Kevin Bullock
93f9cb7f25 filtering: rename filters to their antonyms
Now that changelog filtering is in place, it's become evident that
naming the filters according to the set of revs _not_ included in the
filtered changelog is confusing. This is especially evident in the
collaborative branch cache scheme.

This changes the names of the filters to reflect the revs that _are_
included:

  hidden -> visible
  unserved -> served
  mutable -> immutable
  impactable -> base

repoview.filteredrevs is renamed to filterrevs, so that callers read a
bit more sensibly, e.g.:

  filterrevs('visible') # filter revs according to what's visible
2013-01-13 01:39:16 -06:00
Pierre-Yves David
01b68ae973 branchmap: allow to use cache of subset
Filtered repository are *subset* of unfiltered repository. This means that a
filtered branchmap could be use to compute the unfiltered version.

And filtered version happen to be subset of each other:
- "all() - unserved()" is a subset of "all() - hidden()"
- "all() - hidden()" is a subset of "all()"

This means that branchmap with "unfiltered" filter can be used as a base for
"hidden" branchmap that itself could be used as a base for unfiltered
branchmap.

   unserved < hidden < None

This changeset implements this mechanism. If the on disk branchcache is not valid
we use the branchcache of the nearest subset as base instead of computing it from
scratch. Such fallback can be cascaded multiple time is necessary.

Note that both "hidden" and "unserved" set are a bit volatile. We will add more
stable filtering in next changesets.

This changeset enables collaboration between no filtering and "unserved"
filtering. Fixing performance regression introduced by 7bff5f37cb97
2013-01-07 17:23:25 +01:00
Mads Kiilerich
c6829a39d5 tests: add missing 'backup bundle' path glob in test-rebase-collapse.t
Introduced by f071275fac59.
2012-06-22 02:39:52 +02:00
Joshua Redstone
fe77ca6b46 strip: incrementally update the branchheads cache after a strip
This function augments strip to incrementally update the branchheads cache
rather than recompute it from scratch.  This speeds up the performance of strip
and rebase on repos with long history.  The performance optimization only
happens if the revisions stripped are all on the same branch and the parents of
the stripped revisions are also on that same branch.

This adds a few test cases, particularly one that reproduces the extra heads
that mpm observed.
2012-05-18 12:45:47 -07:00
Pierre-Yves David
aa99ac6df5 rebase: do not add second parent to rebased changeset (drop detach option) (BC)
Rebase now behaves as if --detach was always passed. Non-merges are
rebased as non-merges, regardless of their parent being an ancestor of
the destination. Merges will usually be rebased as merges unless both of
their parents are ancestors of the destination, or one of their parents
is pruned when rebased.

This only alters the behavior of rebase when using the --source/--rev
options. --detach option is deprecated.

All test changes were carefully validated.
2012-06-20 20:08:57 +02:00
Patrick Mezard
de32ec835b test-rebase-collapse: fix Windows path separator 2012-05-13 14:29:05 +02:00
Patrick Mezard
d99bfab018 rebase: allow collapsing branches in place (issue3111)
We allow rebase plus collapse, but not collapse only? I imagine people would
rebase first then collapse once they are sure the rebase is correct and it is
the right time to finish it.

I was reluctant to submit this patch for reasons detailed below, but it
improves rebase --collapse usefulness so much it is worth the ugliness.

The fix is ugly because we should be fixing the collapse code path rather than
the merge. Collapsing by merging changesets repeatedly is inefficient compared
to what commit --amend does: commitctx(), update, strip. The problem with the
latter is, to generate the synthetic changeset, copy records are gathered with
copies.pathcopies(). copies.pathcopies() is still implemented with merging in
mind and discards information like file replaced by the copy of another,
criss-cross copies and so forth. I believe this information should not be lost,
even if we decide not to interpret it fully later, at merge time.

The second issue with improving rebase --collapse is the option should not be
there to begin with. Rebasing and collapsing are orthogonal and a dedicated
command would probably enable a better, simpler ui. We should avoid advertizing
rebase --collapse, but with this fix it becomes the best shipped solution to
collapse changesets.

And for the record, available techniques are:
- revert + commit + strip: lose copies
- mq/qfold: repeated patching() (mostly correct, fragile)
- rebase: repeated merges (mostly correct, fragile)
- collapse: revert + tag rewriting wizardry, lose copies
- histedit: repeated patching() (mostly correct, fragile)
- amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 15:14:58 +02:00
Patrick Mezard
2c65c226cf localrepo: add setparents() to adjust dirstate copies (issue3407)
The fix introduced in 3509b9cf8f86 was only partially successful. It is correct
to turn dirstate 'm' merge records into normal/dirty ones but copy records are
lost in the process. To adjust them as well, we need to look in the first
parent manifest to know which files were added and preserve only related
records. But the dirstate does not have access to changesets, the logic has to
moved at another level, in localrepo.
2012-04-29 22:25:55 +02:00
Thomas Arendsen Hein
21bb7c4cdc tests: make tests work if directory contains special characters
With this quoting tests will work e.g. in "/tmp/foo bar/mercurial/".
2012-04-03 19:06:35 +02:00
Augie Fackler
68e234d364 test-rebase-collapse: Add test for rebase regression introduced in 5f0e8de75b35 2012-01-23 12:26:01 -06:00
Alain Leufroy
fd923bd6e3 rebase: fix phases movement
Rebase now try to keep the phases of source changesets.
2012-01-17 09:12:14 +01:00
Pierre-Yves David
7e4f710bf6 phases: prevent rebase to rebase immutable changeset. 2011-12-27 00:11:22 +01:00