ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

922 commits

Author SHA1 Message Date
Martin von Zweigbergk
352ca72314 tests: make helpers create non-legacy trees
Extracted and modified from #3746 by @ilyagr.
2024-07-24 14:33:05 +02:00
Yuya Nishihara
bafb357209 git: on abandoning unreachable commits, don't count HEAD ref
This basically reverts 20eb9ecec1 "git: don't abandon HEAD commit when it
loses a branch." I think the new behavior is more consistent because the Git
HEAD is equivalent to @- in jj, so it shouldn't be considered a named ref.

Note that we've made old HEAD branch not considered at 92cfffd843 "git: on
external HEAD move, do not abandon old branch."

#4108
2024-07-24 21:22:26 +09:00
Yuya Nishihara
ddc601fbf9 str_util: add regex pattern
This patch adds minimal support for the regex pattern. We might have to add
"regex-i:" for completeness, but it can be achieved by "regex:'(?i)..'".
2024-07-22 12:00:52 +09:00
Ilya Grigoriev
e2f12d91cc conflicts: switch to multi-line regex, fix minor bug
The multi-line regex will be used for other purposes soon.
2024-07-18 18:42:40 -07:00
Ilya Grigoriev
d095570718 conflicts: demo minor bug 2024-07-18 18:42:40 -07:00
Ilya Grigoriev
f3de66e603 conflicts: demo failure to materialize if conflicts don't end in a newline
#3968
2024-07-18 18:42:40 -07:00
Matt Kulukundis
6ffe05290d copy-tracking: move unit tests into backend specific file 2024-07-18 05:44:56 -04:00
Yuya Nishihara
895eead4b8 revset: add diff_contains(text[, files]) to search diffs
The text pattern is applied prior to comparison as we do in Mercurial. This
might affect hunk selection, but is much faster than computing diff of full
file contents. For example, the following hunk wouldn't be caught by
diff_contains("a") because the line "b\n" is filtered out:

    - a
      b
    + a

Closes #2933
2024-07-18 01:01:16 +09:00
Matt Kulukundis
3043b83a8f copy-tracking: add get_copy_records to Store 2024-07-16 13:18:49 -04:00
Yuya Nishihara
a757fddcf1 revset: parse file() argument as fileset expression
Since fileset and revset languages are syntactically close, we can reparse
revset expression as a fileset. This might sound a bit scary, but helps
eliminate nested quoting like file("~glob:'*.rs'"). One oddity exists in alias
substitution, though. Another possible problem is that we'll need to add fake
operator parsing rules if we introduce incompatibility in fileset, or want to
embed revset expressions in a fileset.

Since "file(x, y)" is equivalent to "file(x|y)", the former will be deprecated.
I'll probably add a mechanism to collect warnings during parsing.
2024-07-16 10:18:57 +09:00
Matt Kulukundis
df021083c9 diff: add unit tests for copy tracking in the git backend 2024-07-15 16:49:10 -04:00
Scott Taylor
2dd75b5c53 revset: add tracked/untracked_remote_branches()
Adds support for revset functions `tracked_remote_branches()` and
`untracked_remote_branches()`. I think this would be especially useful
for configuring `immutable_heads()` because rewriting untracked remote
branches usually wouldn't be desirable (since it wouldn't update the
remote branch). It also makes it easy to hide branches that you don't
care about from the log, since you could hide untracked branches and
then only track branches that you care about.
2024-07-13 10:43:21 -05:00
Tim Janik
11f56800fa test_gpg: fix warnings ending up on stdout
Signed-off-by: Tim Janik <timj@gnu.org>
2024-07-12 10:32:13 +09:00
Yuya Nishihara
415c831e30 revset: flatten union nodes in AST to save recursion stack
Maybe it'll also be good to keep RevsetExpression::Union(_) flattened, but
that's not needed to get around stack overflow. The constructed expression
tree is balanced.

test_expand_symbol_alias() is slightly adjusted since there are more than
one representation for "a|b|c" now.

Fixes #4031
2024-07-11 11:20:25 +09:00
Emily
93d76e5d8f str_util: support case‐insensitive string patterns
Partially resolve a 1.5‐year‐old TODO comment.

Add opt‐in syntax for case‐insensitive matching, suffixing the
pattern kind with `-i`. Not every context supports case‐insensitive
patterns (e.g. Git branch fetch settings). It may make sense to make
this the default in at least some contexts (e.g. the commit signature
and description revsets), but it would require some thought to avoid
more confusing context‐sensitivity.

Make `mine()` match case‐insensitively unconditionally, since email
addresses are conventionally case‐insensitive and it doesn’t take
a pattern anyway.

This currently only handles ASCII case folding, due to the complexities
of case‐insensitive Unicode comparison and the `glob` crate’s lack
of support for it. This is unlikely to matter for email addresses,
which very rarely contain non‐ASCII characters, but is unfortunate
for names and descriptions. However, the current matching behaviour is
already seriously deficient for non‐ASCII text due to the lack of any
normalization, so this hopefully shouldn’t be a blocker to adding the
interface. An expository comment has been left in the code for anyone
who wants to try and address this (perhaps a future version of myself).
2024-07-10 05:58:34 +01:00
Emily
a146145adb revset: fix mine() test comments 2024-07-10 05:58:34 +01:00
Emily
3567cba8c9 revset: fix email matching tests
The comments say “Can find a unique match by either name or email”,
but these weren’t checking for an email match.
2024-07-10 05:58:34 +01:00
Scott Taylor
54877e1f79 workspace: abandon discardable working copy on forget
Forgetting a workspace removes its working-copy commit, so it makes
sense for it to be abandoned if it is discardable just like editing a
new commit will cause the old commit to be abandoned if it is
discardable.
2024-07-04 19:37:56 -05:00
Scott Taylor
622b606bfb repo: abandon working copy only if no other workspaces reference it
Currently, if two workspaces are editing the same discardable commit and
one of them switches to editing a different commit, it is abandoned even
though the other workspace is still editing it. This commit treats
workspaces as referencing their working-copy commits so that they won't
be abandoned.
2024-07-04 19:37:56 -05:00
Ilya Grigoriev
1b658ea80e lib id_prefix: look for divergent changes outside short prefix set
Fixes #2476.

Previously, if there was a change id match within the short prefix
lookup set, `jj` would not look for commits with that same change id
outside the short prefix set. So, it wouldn't find the conflicted
commits for a commit with a divergent (AKA conflicted) change id.
2024-06-29 11:44:26 -07:00
Ilya Grigoriev
360a2b6a8b lib id_prefix: demo bug #2476 in a test 2024-06-29 11:44:26 -07:00
Scott Taylor
1eebbe57c0 commit_builder: reset author timestamp on discardable commits
It's common to create empty working-copy commits while using jj, and
currently the author timestamp for a commit is only set when it is first
created. If you create an empty commit, then don't work on a repo for a
few days, and then start working on a new feature without abandoning the
working-copy commit, the author timestamp will remain as the time the
commit was created rather than being updated to the time that work began
or finished.

This commit changes the behavior so that discardable commits (empty
commits with no description) by the current user have their author
timestamps reset when they are rewritten, meaning that the author
timestamp will become finalized whenever a commit is given a description
or becomes non-empty.
2024-06-29 08:35:53 -05:00
Yuya Nishihara
c240313c4b view: remove has_branch() which is called only from tests
Since we've split (local, remotes) branches to (locals, remotes { branches }),
.has_branch() API no longer makes much sense. Callers often need to check if
a remote branch is tracked.
2024-06-28 10:29:06 +09:00
Martin von Zweigbergk
f8a5ad0c7a conflicts: propagate error from conflict materialization 2024-06-17 14:33:29 +09:00
Matt Kulukundis
8aa71f58f3 feat: add an option to monitor the filesystem asynchronously
- make an internal set of watchman extensions until the client api gets
  updates with triggers
- add a config option to enable using triggers in watchman

Co-authored-by: Waleed Khan <me@waleedkhan.name>
2024-06-16 23:24:22 -04:00
Benjamin Tan
716ec37560 test_local_working_copy: add test for snapshotting of edited materialized simplified conflict 2024-06-15 06:05:06 +08:00
Benjamin Tan
9be33724dc conflicts: materialize simplified file conflicts 2024-06-15 06:05:06 +08:00
Benjamin Tan
7106f6fd49 conflicts: handle parsing of simplified conflicts 2024-06-15 06:05:06 +08:00
Benjamin Tan
f74991c2e1 tests: add tests showing that individual file conflicts are not simplified/deduplicated 2024-06-15 06:05:06 +08:00
Kyle J Strand
03a0921e12 give descendants a range arg 2024-06-13 18:54:57 -06:00
Martin von Zweigbergk
bfa0573cab repo/workspace: drop support for old repo formats
It's been more than 6 months since we added support for dynamically
selecting the working copy implementation. This patch drops support
for selecting the default implementation of that and other stores.
2024-06-11 22:03:20 +09:00
Martin von Zweigbergk
65a988e3d2 merged_tree: make tree builder attempt to resolve conflicts
As we discovered in the `jj fix` tests,
`MergedTreeBuilder::write_tree()` doesn't try to resolve conflicts,
not even trivial ones. This patch fixes that.
2024-06-08 20:29:30 +09:00
Martin von Zweigbergk
776b2d981f merged_tree: make resolve() return a MergedTree
It seems like a method on `MergedTree` should return another
`MergedTree` when reasonable. I'm not sure why I made it return a
`Merge<Tree>` instead.
2024-06-08 20:29:30 +09:00
Yuya Nishihara
5e7cb3435e git: unset unborn HEAD ref on export
Otherwise, newly created default branch would be re-imported as a new Git HEAD.
This could be addressed by cmd_git_init(), but the same situation can be
crafted by using "git checkout -b".
2024-06-01 11:01:16 +09:00
Martin von Zweigbergk
404f31cbc1 backend: add error variant for access denied, handle when diffing
Some backends, like the one we have at Google, can restrict access to
certain files. For such files, if they return a regular
`BackendError::ReadObject`, then that will terminate iteration in many
cases (e.g. when diffing or listing files). This patch adds a new
error variant for them to return instead, plus handling of such errors
in diff output and in the working copy.

In order to test the feature, I added a new commit backend that
returns the new `ReadAccessDenied` error when the caller tries to read
certain objects.
2024-05-30 18:27:38 -07:00
Benjamin Tan
e0e123873b revset_graph: rename to graph and make generic over graph node type 2024-05-31 02:39:34 +08:00
Martin von Zweigbergk
3090adfd5c repo: consider empty and undescribed merge commits as discardable 2024-05-29 06:54:30 -07:00
Martin von Zweigbergk
5d2c0347a2 MutableRepo: add test of updating away from empty merge commit
Merge commits are very similar to non-merge commits in jj. An empty
merge commit with no description is not really different from an empty
non-merge commit with no description. As we discussed on
https://github.com/martinvonz/jj/issues/2859, we should not treat
merge commits differently when updating away from them. This patch
adds test for the current behavior (which is to leave the merge commit
in place).
2024-05-29 06:54:30 -07:00
Martin von Zweigbergk
28050e9da1 repo: update some stale mentions of MutableRepo::check_out() 2024-05-29 06:54:30 -07:00
Martin von Zweigbergk
e02622b143 repo: when abandoning a working copy that a merge, recreate it
I recently needed to test something on top of a two branches at the
same time, so I created a new commit on top of both of them (i.e. a
merge commit). I then ran tests and made some adjustments to the
code. These adjustments belonged in one of the parent branches, so I
used `jj squash --into` to squash it in there. Unfortunately, that
meant that my working copy became a single-parent commit based on one
of the branches only. We already had #2859 for tracking this issue.

This patch changes the behavior so we create a new working-copy commit
with all of the previous parents.
2024-05-29 06:54:30 -07:00
Ilya Grigoriev
12081166f6 test_git.rs: delete now-useless test 2024-05-28 21:38:26 -07:00
Ilya Grigoriev
777da99533 jj git push: always force-push, all safety logic now in push_negotiation
This should be a no-op, though that is not necessarily obvious in corner
cases.

Note that libgit2 already performs the push negotiation even when
pushing without force (without `+` in the refspec).
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
8d3dd17b51 jj git push: safety checks in push negotiation, "force-with-lease"
As explained in the commit, our logic is a bit more complicated than
that of `git push --force-with-lease`. This is to match the behavior of
`jj git fetch` and branch conflict resolution rules.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
b0306eb742 jj git push: no-op push negotiation, plumb data to it
Hopefully, splitting the no-op portion will make the following commits
easier to review.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
b54d962d58 test_git.rs: add two more commits to PushSetup, rename them
The new names are a bit clearer. Soem tests already use a
`sideways_commit`, `parent_of_main_commit` will be needed in
an upcoming test.
2024-05-28 21:38:26 -07:00
Martin von Zweigbergk
1e3b49abf5 revset: use FsRepoPathUiConverter in RevsetWorkspaceContext 2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
7e6a968415 conflicts: consider the empty tree a non-legacy tree
Since we no longer depend on legacy trees being preserved when we
build new trees or merge trees, we can consider the root tree a
non-legacy tree.
2024-05-27 06:25:27 -07:00
mlcui
a075a5c6ca git: Only reset Git index if non-empty
In chromium/src.git, this gives an approximate ~0.83s speedup for
commands if the Git index is empty, and a ~0.14s slowdown if the Git
index is non-empty.

As most users using jj will likely be using jj to write to a colocated
repo - and therefore avoid modifying the Git index - this should be a
general speedup for most colocated checkouts.
2024-05-27 11:35:13 +10:00
Martin von Zweigbergk
07bb1d81b7 tree_builder: propagate errors from write_tree() 2024-05-22 06:46:38 -07:00
Martin von Zweigbergk
1970ddef15 tree: propagate errors from sub_tree()/path_value() 2024-05-22 06:46:38 -07:00