This is an archive of the discontinued Mercurial Phabricator instance.

rewriteutil: extract evolve code used to replace obsolete hashes in commits
ClosedPublic

Authored by mharbison72 on Aug 24 2020, 7:08 PM.

Details

Summary

The evolve command uses it, but there are core things like phabsend and
rebase that would also benefit.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mharbison72 created this revision.Aug 24 2020, 7:08 PM
marmoute requested changes to this revision.Aug 26 2020, 3:05 PM
marmoute added a subscriber: marmoute.

There are already a mercurial/rewriteutils.py files I think it should go there

This revision now requires changes to proceed.Aug 26 2020, 3:05 PM
mharbison72 planned changes to this revision.Aug 26 2020, 3:30 PM

There are already a mercurial/rewriteutils.py files I think it should go there

Indeed. I saw obsutil.py, but not this. I'll move it there, but what's the difference between these handful of utils (scmutil.py, obsutil.py, etc) and the stuff in the mercurial.utils package?

A mix of timing regarding policy changes and semantic. Module in utils are mostly a split of the old utils module. These modules are a generic utility module with function that might be useful in about any kind of other Mercurial code.

They are some other "utility" module that focus on quite specific part of Mercurial and should/will not be used from outside that part of Mercurial. For example the one contains inside the mercurial/revlogutils/ directory.

There are already a mercurial/rewriteutils.py files I think it should go there

So that causes a cycle:

--- c:/Users/Matt/hg/tests/test-check-module-imports.t
+++ c:/Users/Matt/hg/tests/test-check-module-imports.t.err
@@ -38,3 +38,5 @@
   > -X tests/test-imports-checker.t \
   > -X tests/test-verify-repo-operations.py \
   > | sed 's-\\-/-g' | "$PYTHON" "$import_checker" -
+  Import cycle: mercurial.cmdutil -> mercurial.rewriteutil -> mercurial.localrepo -> mercurial.extensions -> mercurial.cmdutil\r (esc)
+  [1]

That is really only used for type checking, so is that safe to move under if pycompat.TYPE_CHECKING: with the typing related imports, or is there another way to do this? Or should I just drop the type checking?

There are already a mercurial/rewriteutils.py files I think it should go there

So that causes a cycle:

--- c:/Users/Matt/hg/tests/test-check-module-imports.t
+++ c:/Users/Matt/hg/tests/test-check-module-imports.t.err
@@ -38,3 +38,5 @@
   > -X tests/test-imports-checker.t \
   > -X tests/test-verify-repo-operations.py \
   > | sed 's-\\-/-g' | "$PYTHON" "$import_checker" -
+  Import cycle: mercurial.cmdutil -> mercurial.rewriteutil -> mercurial.localrepo -> mercurial.extensions -> mercurial.cmdutil\r (esc)
+  [1]

That is really only used for type checking, so is that safe to move under if pycompat.TYPE_CHECKING: with the typing related imports, or is there another way to do this? Or should I just drop the type checking?

I am a bit confused about your question. What is "That" ?

There are already a mercurial/rewriteutils.py files I think it should go there

So that causes a cycle:

--- c:/Users/Matt/hg/tests/test-check-module-imports.t
+++ c:/Users/Matt/hg/tests/test-check-module-imports.t.err
@@ -38,3 +38,5 @@
   > -X tests/test-imports-checker.t \
   > -X tests/test-verify-repo-operations.py \
   > | sed 's-\\-/-g' | "$PYTHON" "$import_checker" -
+  Import cycle: mercurial.cmdutil -> mercurial.rewriteutil -> mercurial.localrepo -> mercurial.extensions -> mercurial.cmdutil\r (esc)
+  [1]

That is really only used for type checking, so is that safe to move under if pycompat.TYPE_CHECKING: with the typing related imports, or is there another way to do this? Or should I just drop the type checking?

I am a bit confused about your question. What is "That" ?

The mercurial.localrepo import in a subsequent patch. That import is only used for the # type: ... comment on the function.

pulkit added a subscriber: pulkit.Sep 2 2020, 12:11 PM

There are already a mercurial/rewriteutils.py files I think it should go there

So that causes a cycle:

--- c:/Users/Matt/hg/tests/test-check-module-imports.t
+++ c:/Users/Matt/hg/tests/test-check-module-imports.t.err
@@ -38,3 +38,5 @@
   > -X tests/test-imports-checker.t \
   > -X tests/test-verify-repo-operations.py \
   > | sed 's-\\-/-g' | "$PYTHON" "$import_checker" -
+  Import cycle: mercurial.cmdutil -> mercurial.rewriteutil -> mercurial.localrepo -> mercurial.extensions -> mercurial.cmdutil\r (esc)
+  [1]

That is really only used for type checking, so is that safe to move under if pycompat.TYPE_CHECKING: with the typing related imports, or is there another way to do this? Or should I just drop the type checking?

I am a bit confused about your question. What is "That" ?

The mercurial.localrepo import in a subsequent patch. That import is only used for the # type: ... comment on the function.

I believe in future we might want to call some utilities function of this new file from cmdutil.py which will create a cycle. I think we should drop the #type .. part for now as adding imports for this is going to be quite a problem since repository object is used at lot of places.

mharbison72 updated this revision to Diff 22540.Sep 4 2020, 2:19 PM
pulkit accepted this revision.Sep 8 2020, 3:28 AM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.