D8043: graphlog: use '@' also for other context in merge conflict

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

D8043: graphlog: use '@' also for other context in merge conflict

martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This makes these commands' behavior consistent with `hg rebase`, which
  already shows '@' for the node it's grafting.
 
  I'm happy to use a different symbol for conflict parents if someone
  thinks that's better (and can suggest a good symbol).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/hgweb/webutil.py
  mercurial/logcmdutil.py
  mercurial/templatekw.py
  relnotes/next
  tests/test-backout.t
  tests/test-graft-interrupted.t
  tests/test-rebase-collapse.t
  tests/test-strip.t
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -254,7 +254,7 @@
   |
   @  4:d047485b3896 0:60829823a42a  b1
   |
-  | o  3:6efa171f091b 1:0786582aa4b1
+  | @  3:6efa171f091b 1:0786582aa4b1
   | |
   | | o  2:bd10386d478c
   | |/
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -598,7 +598,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:9ab35a2d17cb
+  @  changeset:   0:9ab35a2d17cb
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     a
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -762,7 +762,7 @@
   abort: edit failed: false exited with status 1
   [255]
   $ hg tglog
-  o  3: 63668d570d21 'C'
+  @  3: 63668d570d21 'C'
   |
   | @  2: 82b8abf9c185 'D'
   | |
diff --git a/tests/test-graft-interrupted.t b/tests/test-graft-interrupted.t
--- a/tests/test-graft-interrupted.t
+++ b/tests/test-graft-interrupted.t
@@ -431,7 +431,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}"
   @  6:6ec71c037d94 added x
   |
-  | o  5:36b793615f78 added foo to c
+  | @  5:36b793615f78 added foo to c
   | |
   | | o  4:863a25e1a9ea added x
   | |/
@@ -622,7 +622,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | @  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -669,7 +669,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | @  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -712,7 +712,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | @  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -103,7 +103,7 @@
   |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     grapes
   |
-  o  changeset:   1:22cb4f70d813
+  @  changeset:   1:22cb4f70d813
   |  user:        test
   |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     chair
@@ -748,7 +748,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     capital three
   |
-  o  changeset:   0:a30dd8addae3
+  @  changeset:   0:a30dd8addae3
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     initial
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -1,5 +1,10 @@
 == New Features ==
 
+ * `hg log` now defaults to using the '@' symbol not only for parents
+   of the working copy, but also for parents of unresolved merge
+   conflicts. That includes unresolved conflicts caused by e.g. `hg
+   update --merge` and `hg graft`.
+
  * New `conflictparents()` revset returns the commits that are being
    merged, when there are conflicts. Also works for conflicts caused
    by e.g. `hg graft`.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -396,26 +396,38 @@
     return templateutil.compatfileslist(context, mapping, b'file', ctx.files())
 
 
-@templatekeyword(b'graphnode', requires={b'repo', b'ctx'})
+@templatekeyword(b'graphnode', requires={b'repo', b'ctx', b'cache'})
 def showgraphnode(context, mapping):
     """String. The character representing the changeset node in an ASCII
     revision graph."""
     repo = context.resource(mapping, b'repo')
     ctx = context.resource(mapping, b'ctx')
-    return getgraphnode(repo, ctx)
+    cache = context.resource(mapping, b'cache')
+    return getgraphnode(repo, ctx, cache)
 
 
-def getgraphnode(repo, ctx):
-    return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx)
+def getgraphnode(repo, ctx, cache):
+    return getgraphnodecurrent(repo, ctx, cache) or getgraphnodesymbol(ctx)
 
 
-def getgraphnodecurrent(repo, ctx):
+def getgraphnodecurrent(repo, ctx, cache):
     wpnodes = repo.dirstate.parents()
     if wpnodes[1] == nullid:
         wpnodes = wpnodes[:1]
     if ctx.node() in wpnodes:
         return b'@'
     else:
+        merge_nodes = cache.get(b'merge_nodes', ())
+        if not merge_nodes:
+            from . import merge
+
+            mergestate = merge.mergestate.read(repo)
+            if mergestate.active():
+                merge_nodes = (mergestate.local, mergestate.other)
+            cache[b'merge_nodes'] = merge_nodes
+
+        if ctx.node() in merge_nodes:
+            return b'@'
         return b''
 
 
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -1004,7 +1004,7 @@
         ui, spec, defaults=templatekw.keywords, resources=tres
     )
 
-    def formatnode(repo, ctx):
+    def formatnode(repo, ctx, cache):
         props = {b'ctx': ctx, b'repo': repo}
         return templ.renderdefault(props)
 
@@ -1038,8 +1038,9 @@
         # experimental config: experimental.graphshorten
         state.graphshorten = ui.configbool(b'experimental', b'graphshorten')
 
+    formatnode_cache = {}
     for rev, type, ctx, parents in dag:
-        char = formatnode(repo, ctx)
+        char = formatnode(repo, ctx, formatnode_cache)
         copies = getcopies(ctx) if getcopies else None
         edges = edgefn(type, char, state, rev, parents)
         firstedge = next(edges)
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -936,5 +936,5 @@
 
 def getgraphnode(repo, ctx):
     return templatekw.getgraphnodecurrent(
-        repo, ctx
+        repo, ctx, {}
     ) + templatekw.getgraphnodesymbol(ctx)



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8043: graphlog: use '%' for other context in merge conflict

martinvonz (Martin von Zweigbergk)
martinvonz edited the summary of this revision.
martinvonz retitled this revision from "graphlog: use '@' also for other context in merge conflict" to "graphlog: use '%' for other context in merge conflict".
martinvonz updated this revision to Diff 19723.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8043?vs=19703&id=19723

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8043/new/

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

AFFECTED FILES
  hgext/beautifygraph.py
  mercurial/hgweb/webutil.py
  mercurial/logcmdutil.py
  mercurial/templatekw.py
  relnotes/next
  tests/test-backout.t
  tests/test-graft-interrupted.t
  tests/test-rebase-collapse.t
  tests/test-strip.t
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -254,7 +254,7 @@
   |
   @  4:d047485b3896 0:60829823a42a  b1
   |
-  | o  3:6efa171f091b 1:0786582aa4b1
+  | %  3:6efa171f091b 1:0786582aa4b1
   | |
   | | o  2:bd10386d478c
   | |/
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -598,7 +598,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:9ab35a2d17cb
+  %  changeset:   0:9ab35a2d17cb
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     a
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -762,7 +762,7 @@
   abort: edit failed: false exited with status 1
   [255]
   $ hg tglog
-  o  3: 63668d570d21 'C'
+  %  3: 63668d570d21 'C'
   |
   | @  2: 82b8abf9c185 'D'
   | |
diff --git a/tests/test-graft-interrupted.t b/tests/test-graft-interrupted.t
--- a/tests/test-graft-interrupted.t
+++ b/tests/test-graft-interrupted.t
@@ -431,7 +431,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}"
   @  6:6ec71c037d94 added x
   |
-  | o  5:36b793615f78 added foo to c
+  | %  5:36b793615f78 added foo to c
   | |
   | | o  4:863a25e1a9ea added x
   | |/
@@ -622,7 +622,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -669,7 +669,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -712,7 +712,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -103,7 +103,7 @@
   |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     grapes
   |
-  o  changeset:   1:22cb4f70d813
+  %  changeset:   1:22cb4f70d813
   |  user:        test
   |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     chair
@@ -748,7 +748,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     capital three
   |
-  o  changeset:   0:a30dd8addae3
+  %  changeset:   0:a30dd8addae3
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     initial
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -1,5 +1,10 @@
 == New Features ==
 
+ * `hg log` now defaults to using an '%' symbol for parents of
+    unresolved merge conflicts. That includes unresolved conflicts
+    caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
+    precedence, so when what used to be marked '@' still is.
+
  * New `conflictparents()` revset returns the commits that are being
    merged, when there are conflicts. Also works for conflicts caused
    by e.g. `hg graft`.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -396,26 +396,38 @@
     return templateutil.compatfileslist(context, mapping, b'file', ctx.files())
 
 
-@templatekeyword(b'graphnode', requires={b'repo', b'ctx'})
+@templatekeyword(b'graphnode', requires={b'repo', b'ctx', b'cache'})
 def showgraphnode(context, mapping):
     """String. The character representing the changeset node in an ASCII
     revision graph."""
     repo = context.resource(mapping, b'repo')
     ctx = context.resource(mapping, b'ctx')
-    return getgraphnode(repo, ctx)
+    cache = context.resource(mapping, b'cache')
+    return getgraphnode(repo, ctx, cache)
 
 
-def getgraphnode(repo, ctx):
-    return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx)
+def getgraphnode(repo, ctx, cache):
+    return getgraphnodecurrent(repo, ctx, cache) or getgraphnodesymbol(ctx)
 
 
-def getgraphnodecurrent(repo, ctx):
+def getgraphnodecurrent(repo, ctx, cache):
     wpnodes = repo.dirstate.parents()
     if wpnodes[1] == nullid:
         wpnodes = wpnodes[:1]
     if ctx.node() in wpnodes:
         return b'@'
     else:
+        merge_nodes = cache.get(b'merge_nodes', ())
+        if not merge_nodes:
+            from . import merge
+
+            mergestate = merge.mergestate.read(repo)
+            if mergestate.active():
+                merge_nodes = (mergestate.local, mergestate.other)
+            cache[b'merge_nodes'] = merge_nodes
+
+        if ctx.node() in merge_nodes:
+            return b'%'
         return b''
 
 
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -1004,7 +1004,7 @@
         ui, spec, defaults=templatekw.keywords, resources=tres
     )
 
-    def formatnode(repo, ctx):
+    def formatnode(repo, ctx, cache):
         props = {b'ctx': ctx, b'repo': repo}
         return templ.renderdefault(props)
 
@@ -1038,8 +1038,9 @@
         # experimental config: experimental.graphshorten
         state.graphshorten = ui.configbool(b'experimental', b'graphshorten')
 
+    formatnode_cache = {}
     for rev, type, ctx, parents in dag:
-        char = formatnode(repo, ctx)
+        char = formatnode(repo, ctx, formatnode_cache)
         copies = getcopies(ctx) if getcopies else None
         edges = edgefn(type, char, state, rev, parents)
         firstedge = next(edges)
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -936,5 +936,5 @@
 
 def getgraphnode(repo, ctx):
     return templatekw.getgraphnodecurrent(
-        repo, ctx
+        repo, ctx, {}
     ) + templatekw.getgraphnodesymbol(ctx)
diff --git a/hgext/beautifygraph.py b/hgext/beautifygraph.py
--- a/hgext/beautifygraph.py
+++ b/hgext/beautifygraph.py
@@ -71,6 +71,8 @@
         return b'\xE2\x97\x8B'  # U+25CB ○
     if node == b'@':
         return b'\xE2\x97\x8D'  # U+25CD ◍
+    if node == b'%':
+        return b'\xE2\x97\x8D'  # U+25CE ◎
     if node == b'*':
         return b'\xE2\x88\x97'  # U+2217 ∗
     if node == b'x':



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8043: graphlog: use '%' for other context in merge conflict

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 19870.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8043?vs=19723&id=19870

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8043/new/

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

AFFECTED FILES
  hgext/beautifygraph.py
  mercurial/hgweb/webutil.py
  mercurial/logcmdutil.py
  mercurial/templatekw.py
  relnotes/next
  tests/test-backout.t
  tests/test-graft-interrupted.t
  tests/test-rebase-collapse.t
  tests/test-strip.t
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -254,7 +254,7 @@
   |
   @  4:d047485b3896 0:60829823a42a  b1
   |
-  | o  3:6efa171f091b 1:0786582aa4b1
+  | %  3:6efa171f091b 1:0786582aa4b1
   | |
   | | o  2:bd10386d478c
   | |/
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -598,7 +598,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:9ab35a2d17cb
+  %  changeset:   0:9ab35a2d17cb
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     a
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -762,7 +762,7 @@
   abort: edit failed: false exited with status 1
   [255]
   $ hg tglog
-  o  3: 63668d570d21 'C'
+  %  3: 63668d570d21 'C'
   |
   | @  2: 82b8abf9c185 'D'
   | |
diff --git a/tests/test-graft-interrupted.t b/tests/test-graft-interrupted.t
--- a/tests/test-graft-interrupted.t
+++ b/tests/test-graft-interrupted.t
@@ -431,7 +431,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}"
   @  6:6ec71c037d94 added x
   |
-  | o  5:36b793615f78 added foo to c
+  | %  5:36b793615f78 added foo to c
   | |
   | | o  4:863a25e1a9ea added x
   | |/
@@ -622,7 +622,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -669,7 +669,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -712,7 +712,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -103,7 +103,7 @@
   |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     grapes
   |
-  o  changeset:   1:22cb4f70d813
+  %  changeset:   1:22cb4f70d813
   |  user:        test
   |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     chair
@@ -748,7 +748,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     capital three
   |
-  o  changeset:   0:a30dd8addae3
+  %  changeset:   0:a30dd8addae3
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     initial
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -1,5 +1,10 @@
 == New Features ==
 
+ * `hg log` now defaults to using an '%' symbol for commits involved
+    in unresolved merge conflicts. That includes unresolved conflicts
+    caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
+    precedence, so what used to be marked '@' still is.
+
  * New `conflictlocal()` and `conflictother()` revsets returns the
    commits that are being merged, when there are conflicts. Also works
    for conflicts caused by e.g. `hg graft`.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -396,26 +396,38 @@
     return templateutil.compatfileslist(context, mapping, b'file', ctx.files())
 
 
-@templatekeyword(b'graphnode', requires={b'repo', b'ctx'})
+@templatekeyword(b'graphnode', requires={b'repo', b'ctx', b'cache'})
 def showgraphnode(context, mapping):
     """String. The character representing the changeset node in an ASCII
     revision graph."""
     repo = context.resource(mapping, b'repo')
     ctx = context.resource(mapping, b'ctx')
-    return getgraphnode(repo, ctx)
+    cache = context.resource(mapping, b'cache')
+    return getgraphnode(repo, ctx, cache)
 
 
-def getgraphnode(repo, ctx):
-    return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx)
+def getgraphnode(repo, ctx, cache):
+    return getgraphnodecurrent(repo, ctx, cache) or getgraphnodesymbol(ctx)
 
 
-def getgraphnodecurrent(repo, ctx):
+def getgraphnodecurrent(repo, ctx, cache):
     wpnodes = repo.dirstate.parents()
     if wpnodes[1] == nullid:
         wpnodes = wpnodes[:1]
     if ctx.node() in wpnodes:
         return b'@'
     else:
+        merge_nodes = cache.get(b'merge_nodes', ())
+        if not merge_nodes:
+            from . import merge
+
+            mergestate = merge.mergestate.read(repo)
+            if mergestate.active():
+                merge_nodes = (mergestate.local, mergestate.other)
+            cache[b'merge_nodes'] = merge_nodes
+
+        if ctx.node() in merge_nodes:
+            return b'%'
         return b''
 
 
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -1004,7 +1004,7 @@
         ui, spec, defaults=templatekw.keywords, resources=tres
     )
 
-    def formatnode(repo, ctx):
+    def formatnode(repo, ctx, cache):
         props = {b'ctx': ctx, b'repo': repo}
         return templ.renderdefault(props)
 
@@ -1038,8 +1038,9 @@
         # experimental config: experimental.graphshorten
         state.graphshorten = ui.configbool(b'experimental', b'graphshorten')
 
+    formatnode_cache = {}
     for rev, type, ctx, parents in dag:
-        char = formatnode(repo, ctx)
+        char = formatnode(repo, ctx, formatnode_cache)
         copies = getcopies(ctx) if getcopies else None
         edges = edgefn(type, char, state, rev, parents)
         firstedge = next(edges)
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -936,5 +936,5 @@
 
 def getgraphnode(repo, ctx):
     return templatekw.getgraphnodecurrent(
-        repo, ctx
+        repo, ctx, {}
     ) + templatekw.getgraphnodesymbol(ctx)
diff --git a/hgext/beautifygraph.py b/hgext/beautifygraph.py
--- a/hgext/beautifygraph.py
+++ b/hgext/beautifygraph.py
@@ -71,6 +71,8 @@
         return b'\xE2\x97\x8B'  # U+25CB ○
     if node == b'@':
         return b'\xE2\x97\x8D'  # U+25CD ◍
+    if node == b'%':
+        return b'\xE2\x97\x8D'  # U+25CE ◎
     if node == b'*':
         return b'\xE2\x88\x97'  # U+2217 ∗
     if node == b'x':



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8043: graphlog: use '%' for other context in merge conflict

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
Herald added a subscriber: mjpieters.
martinvonz updated this revision to Diff 20095.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8043?vs=19870&id=20095

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8043/new/

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

AFFECTED FILES
  hgext/beautifygraph.py
  mercurial/hgweb/webutil.py
  mercurial/logcmdutil.py
  mercurial/templatekw.py
  relnotes/next
  tests/test-backout.t
  tests/test-graft-interrupted.t
  tests/test-rebase-collapse.t
  tests/test-strip.t
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -254,7 +254,7 @@
   |
   @  4:d047485b3896 0:60829823a42a  b1
   |
-  | o  3:6efa171f091b 1:0786582aa4b1
+  | %  3:6efa171f091b 1:0786582aa4b1
   | |
   | | o  2:bd10386d478c
   | |/
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -598,7 +598,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:9ab35a2d17cb
+  %  changeset:   0:9ab35a2d17cb
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     a
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -762,7 +762,7 @@
   abort: edit failed: false exited with status 1
   [255]
   $ hg tglog
-  o  3: 63668d570d21 'C'
+  %  3: 63668d570d21 'C'
   |
   | @  2: 82b8abf9c185 'D'
   | |
diff --git a/tests/test-graft-interrupted.t b/tests/test-graft-interrupted.t
--- a/tests/test-graft-interrupted.t
+++ b/tests/test-graft-interrupted.t
@@ -431,7 +431,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}"
   @  6:6ec71c037d94 added x
   |
-  | o  5:36b793615f78 added foo to c
+  | %  5:36b793615f78 added foo to c
   | |
   | | o  4:863a25e1a9ea added x
   | |/
@@ -622,7 +622,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -669,7 +669,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -712,7 +712,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -103,7 +103,7 @@
   |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     grapes
   |
-  o  changeset:   1:22cb4f70d813
+  %  changeset:   1:22cb4f70d813
   |  user:        test
   |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     chair
@@ -748,7 +748,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     capital three
   |
-  o  changeset:   0:a30dd8addae3
+  %  changeset:   0:a30dd8addae3
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     initial
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -3,7 +3,12 @@
  * `hg purge`/`hg clean` can now delete ignored files instead of
    untracked files, with the new -i flag.
 
- * New `conflictlocal()` and `conflictother()` revsets returns the
+ * `hg log` now defaults to using an '%' symbol for commits involved
+    in unresolved merge conflicts. That includes unresolved conflicts
+    caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
+    precedence, so what used to be marked '@' still is.
+
+ * New `conflictlocal()` and `conflictother()` revsets return the
    commits that are being merged, when there are conflicts. Also works
    for conflicts caused by e.g. `hg graft`.
 
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -396,26 +396,38 @@
     return templateutil.compatfileslist(context, mapping, b'file', ctx.files())
 
 
-@templatekeyword(b'graphnode', requires={b'repo', b'ctx'})
+@templatekeyword(b'graphnode', requires={b'repo', b'ctx', b'cache'})
 def showgraphnode(context, mapping):
     """String. The character representing the changeset node in an ASCII
     revision graph."""
     repo = context.resource(mapping, b'repo')
     ctx = context.resource(mapping, b'ctx')
-    return getgraphnode(repo, ctx)
+    cache = context.resource(mapping, b'cache')
+    return getgraphnode(repo, ctx, cache)
 
 
-def getgraphnode(repo, ctx):
-    return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx)
+def getgraphnode(repo, ctx, cache):
+    return getgraphnodecurrent(repo, ctx, cache) or getgraphnodesymbol(ctx)
 
 
-def getgraphnodecurrent(repo, ctx):
+def getgraphnodecurrent(repo, ctx, cache):
     wpnodes = repo.dirstate.parents()
     if wpnodes[1] == nullid:
         wpnodes = wpnodes[:1]
     if ctx.node() in wpnodes:
         return b'@'
     else:
+        merge_nodes = cache.get(b'merge_nodes', ())
+        if not merge_nodes:
+            from . import merge
+
+            mergestate = merge.mergestate.read(repo)
+            if mergestate.active():
+                merge_nodes = (mergestate.local, mergestate.other)
+            cache[b'merge_nodes'] = merge_nodes
+
+        if ctx.node() in merge_nodes:
+            return b'%'
         return b''
 
 
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -1004,7 +1004,7 @@
         ui, spec, defaults=templatekw.keywords, resources=tres
     )
 
-    def formatnode(repo, ctx):
+    def formatnode(repo, ctx, cache):
         props = {b'ctx': ctx, b'repo': repo}
         return templ.renderdefault(props)
 
@@ -1038,8 +1038,9 @@
         # experimental config: experimental.graphshorten
         state.graphshorten = ui.configbool(b'experimental', b'graphshorten')
 
+    formatnode_cache = {}
     for rev, type, ctx, parents in dag:
-        char = formatnode(repo, ctx)
+        char = formatnode(repo, ctx, formatnode_cache)
         copies = getcopies(ctx) if getcopies else None
         edges = edgefn(type, char, state, rev, parents)
         firstedge = next(edges)
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -936,5 +936,5 @@
 
 def getgraphnode(repo, ctx):
     return templatekw.getgraphnodecurrent(
-        repo, ctx
+        repo, ctx, {}
     ) + templatekw.getgraphnodesymbol(ctx)
diff --git a/hgext/beautifygraph.py b/hgext/beautifygraph.py
--- a/hgext/beautifygraph.py
+++ b/hgext/beautifygraph.py
@@ -71,6 +71,8 @@
         return b'\xE2\x97\x8B'  # U+25CB ○
     if node == b'@':
         return b'\xE2\x97\x8D'  # U+25CD ◍
+    if node == b'%':
+        return b'\xE2\x97\x8D'  # U+25CE ◎
     if node == b'*':
         return b'\xE2\x88\x97'  # U+2217 ∗
     if node == b'x':



To: martinvonz, #hg-reviewers
Cc: mjpieters, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8043: graphlog: use '%' for other context in merge conflict

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
Closed by commit rHG14d0e89520a2: graphlog: use '%' for other context in merge conflict (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8043?vs=20095&id=20135

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8043/new/

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

AFFECTED FILES
  hgext/beautifygraph.py
  mercurial/hgweb/webutil.py
  mercurial/logcmdutil.py
  mercurial/templatekw.py
  relnotes/next
  tests/test-backout.t
  tests/test-graft-interrupted.t
  tests/test-rebase-collapse.t
  tests/test-strip.t
  tests/test-update-branches.t

CHANGE DETAILS

diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -254,7 +254,7 @@
   |
   @  4:d047485b3896 0:60829823a42a  b1
   |
-  | o  3:6efa171f091b 1:0786582aa4b1
+  | %  3:6efa171f091b 1:0786582aa4b1
   | |
   | | o  2:bd10386d478c
   | |/
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -598,7 +598,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     b
   |
-  o  changeset:   0:9ab35a2d17cb
+  %  changeset:   0:9ab35a2d17cb
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     a
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -762,7 +762,7 @@
   abort: edit failed: false exited with status 1
   [255]
   $ hg tglog
-  o  3: 63668d570d21 'C'
+  %  3: 63668d570d21 'C'
   |
   | @  2: 82b8abf9c185 'D'
   | |
diff --git a/tests/test-graft-interrupted.t b/tests/test-graft-interrupted.t
--- a/tests/test-graft-interrupted.t
+++ b/tests/test-graft-interrupted.t
@@ -431,7 +431,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}"
   @  6:6ec71c037d94 added x
   |
-  | o  5:36b793615f78 added foo to c
+  | %  5:36b793615f78 added foo to c
   | |
   | | o  4:863a25e1a9ea added x
   | |/
@@ -622,7 +622,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -669,7 +669,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
@@ -712,7 +712,7 @@
   $ hg log -GT "{rev}:{node|short} {desc}\n"
   @  4:2aa9ad1006ff B in file a
   |
-  | o  3:09e253b87e17 A in file a
+  | %  3:09e253b87e17 A in file a
   | |
   | o  2:d36c0562f908 c
   | |
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -103,7 +103,7 @@
   |  date:        Thu Jan 01 00:00:02 1970 +0000
   |  summary:     grapes
   |
-  o  changeset:   1:22cb4f70d813
+  %  changeset:   1:22cb4f70d813
   |  user:        test
   |  date:        Thu Jan 01 00:00:01 1970 +0000
   |  summary:     chair
@@ -748,7 +748,7 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     capital three
   |
-  o  changeset:   0:a30dd8addae3
+  %  changeset:   0:a30dd8addae3
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     initial
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -3,7 +3,12 @@
  * `hg purge`/`hg clean` can now delete ignored files instead of
    untracked files, with the new -i flag.
 
- * New `conflictlocal()` and `conflictother()` revsets returns the
+ * `hg log` now defaults to using an '%' symbol for commits involved
+    in unresolved merge conflicts. That includes unresolved conflicts
+    caused by e.g. `hg update --merge` and `hg graft`. '@' still takes
+    precedence, so what used to be marked '@' still is.
+
+ * New `conflictlocal()` and `conflictother()` revsets return the
    commits that are being merged, when there are conflicts. Also works
    for conflicts caused by e.g. `hg graft`.
 
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -396,26 +396,38 @@
     return templateutil.compatfileslist(context, mapping, b'file', ctx.files())
 
 
-@templatekeyword(b'graphnode', requires={b'repo', b'ctx'})
+@templatekeyword(b'graphnode', requires={b'repo', b'ctx', b'cache'})
 def showgraphnode(context, mapping):
     """String. The character representing the changeset node in an ASCII
     revision graph."""
     repo = context.resource(mapping, b'repo')
     ctx = context.resource(mapping, b'ctx')
-    return getgraphnode(repo, ctx)
+    cache = context.resource(mapping, b'cache')
+    return getgraphnode(repo, ctx, cache)
 
 
-def getgraphnode(repo, ctx):
-    return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx)
+def getgraphnode(repo, ctx, cache):
+    return getgraphnodecurrent(repo, ctx, cache) or getgraphnodesymbol(ctx)
 
 
-def getgraphnodecurrent(repo, ctx):
+def getgraphnodecurrent(repo, ctx, cache):
     wpnodes = repo.dirstate.parents()
     if wpnodes[1] == nullid:
         wpnodes = wpnodes[:1]
     if ctx.node() in wpnodes:
         return b'@'
     else:
+        merge_nodes = cache.get(b'merge_nodes', ())
+        if not merge_nodes:
+            from . import merge
+
+            mergestate = merge.mergestate.read(repo)
+            if mergestate.active():
+                merge_nodes = (mergestate.local, mergestate.other)
+            cache[b'merge_nodes'] = merge_nodes
+
+        if ctx.node() in merge_nodes:
+            return b'%'
         return b''
 
 
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -1004,7 +1004,7 @@
         ui, spec, defaults=templatekw.keywords, resources=tres
     )
 
-    def formatnode(repo, ctx):
+    def formatnode(repo, ctx, cache):
         props = {b'ctx': ctx, b'repo': repo}
         return templ.renderdefault(props)
 
@@ -1038,8 +1038,9 @@
         # experimental config: experimental.graphshorten
         state.graphshorten = ui.configbool(b'experimental', b'graphshorten')
 
+    formatnode_cache = {}
     for rev, type, ctx, parents in dag:
-        char = formatnode(repo, ctx)
+        char = formatnode(repo, ctx, formatnode_cache)
         copies = getcopies(ctx) if getcopies else None
         edges = edgefn(type, char, state, rev, parents)
         firstedge = next(edges)
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -936,5 +936,5 @@
 
 def getgraphnode(repo, ctx):
     return templatekw.getgraphnodecurrent(
-        repo, ctx
+        repo, ctx, {}
     ) + templatekw.getgraphnodesymbol(ctx)
diff --git a/hgext/beautifygraph.py b/hgext/beautifygraph.py
--- a/hgext/beautifygraph.py
+++ b/hgext/beautifygraph.py
@@ -71,6 +71,8 @@
         return b'\xE2\x97\x8B'  # U+25CB ○
     if node == b'@':
         return b'\xE2\x97\x8D'  # U+25CD ◍
+    if node == b'%':
+        return b'\xE2\x97\x8D'  # U+25CE ◎
     if node == b'*':
         return b'\xE2\x88\x97'  # U+2217 ∗
     if node == b'x':



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