Patchwork D8980: repoview: pin revisions for `local` and `other` when a merge is active

login
register
mail settings
Submitter phabricator
Date Sept. 4, 2020, 9:44 p.m.
Message ID <differential-rev-PHID-DREV-jxrrg5skipqoub7uyxll-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47089/
State Superseded
Headers show

Comments

phabricator - Sept. 4, 2020, 9:44 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I've hit this a couple of times, where pulling with a dirty `wdir` obsoletes
  `p1` and updating to the successor results in merge conflicts.  The problem was
  resolving them failed immediately, complaining that the old checkout was
  filtered.
  
  The change in `test-rebase-obsolete.t` is because there's an outstanding merge
  conflict in a rebase operation.  The summary prompt to merge seems incorrect for
  this scenario, but that's an existing issue.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/repoview.py
  tests/test-rebase-check-restore.t
  tests/test-rebase-obsolete.t

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -1795,6 +1795,8 @@ 
   $ hg log -G
   @  2:b18e25de2cf5 D
   |
+  | %  1:2ec65233581b B (pruned using prune)
+  |/
   o  0:426bada5c675 A
   
   $ hg summary
@@ -1802,8 +1804,8 @@ 
    D
   branch: default
   commit: 1 modified, 1 added, 1 unknown, 1 unresolved
-  update: (current)
-  phases: 2 draft
+  update: 1 new changesets, 2 branch heads (merge)
+  phases: 3 draft
   rebase: 0 rebased, 2 remaining (rebase --continue)
 
   $ hg rebase --abort
diff --git a/tests/test-rebase-check-restore.t b/tests/test-rebase-check-restore.t
--- a/tests/test-rebase-check-restore.t
+++ b/tests/test-rebase-check-restore.t
@@ -153,5 +153,29 @@ 
   |/
   o  0:draft 'A'
   
+  $ cat >> .hg/hgrc << EOF
+  > [experimental]
+  > evolution.createmarkers=True
+  > EOF
+
+When updating away from a dirty, obsolete wdir, don't complain that the old p1
+is filtered and requires --hidden.
+
+  $ echo conflict > A
+  $ hg debugobsolete 071d07019675449d53b7e312c65bcf28adbbdb64 965c486023dbfdc9c32c52dc249a231882fd5c17
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg update -r 2 --config ui.merge=internal:merge --merge
+  merging A
+  warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
+  1 files updated, 0 files merged, 1 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ hg resolve A
+  merging A
+  warning: conflicts while merging A! (edit, then use 'hg resolve --mark')
+  [1]
+
+  $ hg up -C -q .
 
   $ cd ..
diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -62,6 +62,17 @@ 
         rev = cl.index.get_rev
         pinned.update(rev(t[0]) for t in tags.values())
         pinned.discard(None)
+
+    # Avoid cycle: mercurial.filemerge -> mercurial.templater ->
+    # mercurial.templatefuncs -> mercurial.revset -> mercurial.repoview ->
+    # mercurial.mergestate -> mercurial.filemerge
+    from . import mergestate
+
+    ms = mergestate.mergestate.read(repo)
+    if ms.active():
+        pinned.add(ms.localctx.rev())
+        pinned.add(ms.otherctx.rev())
+
     return pinned