D8728: overlayworkingctx: rename misleadingly named `isempty()` method

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

D8728: overlayworkingctx: rename misleadingly named `isempty()` method

pulkit (Pulkit Goyal)
mjacob created this revision.
Herald added a reviewer: martinvonz.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This method is only about whether there are file changes, not about whether the
  commit will be empty or not.
 
  One user of the method was incorrectly assuming the latter meaning, leading to
  the bug for which a test case was added in D8727 <https://phab.mercurial-scm.org/D8727>. I’ve added a FIXME to the
  code.
 
  The original motivation for the rename was that I want to add
  `committablectx.isempty()`, that properly checks if a commit will be empty,
  using the exact same logic as in `repo.commit()`, and I wanted to avoid a name
  clash.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8728

AFFECTED FILES
  hgext/rebase.py
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2519,7 +2519,7 @@
     def isdirty(self, path):
         return path in self._cache
 
-    def isempty(self):
+    def nofilechanges(self):
         # We need to discard any keys that are actually clean before the empty
         # commit check.
         self._compact()
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1427,8 +1427,10 @@
 def commitmemorynode(repo, wctx, editor, extra, user, date, commitmsg):
     '''Commit the memory changes with parents p1 and p2.
     Return node of committed revision.'''
-    # Replicates the empty check in ``repo.commit``.
-    if wctx.isempty() and not repo.ui.configbool(b'ui', b'allowemptycommit'):
+    # FIXME: make empty commit check consistent with ``repo.commit``
+    if wctx.nofilechanges() and not repo.ui.configbool(
+        b'ui', b'allowemptycommit'
+    ):
         return None
 
     # By convention, ``extra['branch']`` (set by extrafn) clobbers



To: mjacob, martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel