D8724: commit: check branch change on to-be-committed changeset

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

D8724: commit: check branch change on to-be-committed changeset

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

REVISION SUMMARY
  This makes a difference when a branch name is passed via the `extra` argument,
  which will be used as the branch name for the created changeset. The empty
  commit check should use that branch name instead of whatever was set on the
  working directory.
 
  Besides fixing the bug for which a test case was extended, it enables to remove
  a workaround in the rebase extension, which will be done in a follow-up patch.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/localrepo.py
  tests/test-rebase-emptycommit.t

CHANGE DETAILS

diff --git a/tests/test-rebase-emptycommit.t b/tests/test-rebase-emptycommit.t
--- a/tests/test-rebase-emptycommit.t
+++ b/tests/test-rebase-emptycommit.t
@@ -129,7 +129,16 @@
   > B
   > EOS
 
-  $ hg rebase -r '(A::)-(B::)-A' -d H
+Previously, there was a bug where the empty commit check compared the parent
+branch name with the wdir branch name instead of the actual branch name (which
+should stay unchanged if --keepbranches is passed), and erroneously assumed
+that an otherwise empty changeset should be created because of the incorrectly
+assumed branch name change.
+
+  $ hg update H -q
+  $ hg branch foo -q
+
+  $ hg rebase -r '(A::)-(B::)-A' -d H --keepbranches
   rebasing 2:dc0947a82db8 "C" (BOOK-C)
   note: not rebasing 2:dc0947a82db8 "C" (BOOK-C), its destination already has all its changes
   rebasing 3:b18e25de2cf5 "D" (BOOK-D)
@@ -137,6 +146,7 @@
   rebasing 4:86a1f6686812 "E" (BOOK-E E)
   note: not rebasing 4:86a1f6686812 "E" (BOOK-E E), its destination already has all its changes
   saved backup bundle to $TESTTMP/merge1/.hg/strip-backup/b18e25de2cf5-1fd0a4ba-rebase.hg
+  $ hg update null -q
 
   $ hg log -G -T '{rev} {desc} {bookmarks}'
   o  4 H BOOK-C BOOK-D BOOK-E
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2980,7 +2980,7 @@
 
             # internal config: ui.allowemptycommit
             allowemptycommit = (
-                wctx.branch() != wctx.p1().branch()
+                cctx.branch() != cctx.p1().branch()
                 or extra.get(b'close')
                 or merge
                 or cctx.files()



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