Discussion:
[thg-dev] [PATCH 0 of 3 V2] Draw lines to obsolescence "parents"
Simon Heimberg
2013-11-22 09:18:26 UTC
Permalink
This patches draw a line to obsolescence parents in the graph.

Changes to first version:
* better subject for intro mail :-)
* improve the patches as suggested by Yuya Nishihara
* fixed typo in Patch 1
* Patch 2 imports graph module (instead of only components)
* Patch 4 is new, cleaning further up the import of graph

This is not tested, I can not do this. (But this time I run pyflakes and
pylint and tried to interpret the results.)


I guess patch 3 makes sense. At least I can create two lines manually when
I graft a changeset and manually obsolete it with the transplanted one.

The lines are enabled by the same button as the graft source. Its label
should be updated. Not sure about the text. There is no need for a
separate button because most obsolescence lines are only shown when hidden
changesets are displayed.

Greetings,
Simon
Simon Heimberg
2013-11-22 09:18:29 UTC
Permalink
# HG changeset patch
# User Simon Heimberg <***@besonet.ch>
# Date 1384903623 -3600
# Node ID 8b89e1b9f09b4368802de9c6455976622bfb3730
# Parent 2cd51a22e5d35ba3199288eade014390fb34a276
repomodel: clean up imports from graph module

diff -r 2cd51a22e5d3 -r 8b89e1b9f09b tortoisehg/hgqt/repomodel.py
--- a/tortoisehg/hgqt/repomodel.py Mon Nov 11 22:12:52 2013 +0100
+++ b/tortoisehg/hgqt/repomodel.py Mit Nov 20 00:27:03 2013 +0100
@@ -21,8 +21,6 @@
from mercurial.context import workingctx

from tortoisehg.util import hglib
-from tortoisehg.hgqt.graph import Graph
-from tortoisehg.hgqt.graph import revision_grapher
from tortoisehg.hgqt import graph
from tortoisehg.hgqt import qtlib

@@ -215,19 +213,19 @@
showgraftsource = self.showgraftsource
self.invalidateCache()
if self.revset and self.filterbyrevset:
- grapher = revision_grapher(self.repo,
+ grapher = graph.revision_grapher(self.repo,
branch=hglib.fromunicode(branch),
revset=self.revset,
showhidden=showhidden,
showgraftsource=showgraftsource)
- self.graph = Graph(self.repo, grapher, include_mq=False)
+ self.graph = graph.Graph(self.repo, grapher, include_mq=False)
else:
- grapher = revision_grapher(self.repo,
+ grapher = graph.revision_grapher(self.repo,
branch=hglib.fromunicode(branch),
allparents=allparents,
showhidden=showhidden,
showgraftsource=showgraftsource)
- self.graph = Graph(self.repo, grapher, include_mq=True)
+ self.graph = graph.Graph(self.repo, grapher, include_mq=True)
self.rowcount = 0
self.layoutChanged.emit()
self.ensureBuilt(row=0)
Simon Heimberg
2013-11-22 09:18:28 UTC
Permalink
# HG changeset patch
# User Simon Heimberg <***@besonet.ch>
# Date 1384204372 -3600
# Node ID 2cd51a22e5d35ba3199288eade014390fb34a276
# Parent 6196dddb51b87dbfd1b1213ed05a59a6b52623ba
graph: only draw one line to one parent

Because the parents originate from multiple soucres it is theoretically possible
that several point to the same revision. Only take the first of this (which is
graftsource because it is added before).

diff -r 6196dddb51b8 -r 2cd51a22e5d3 tortoisehg/hgqt/graph.py
--- a/tortoisehg/hgqt/graph.py Die Nov 05 19:11:38 2013 +0100
+++ b/tortoisehg/hgqt/graph.py Mon Nov 11 22:12:52 2013 +0100
@@ -154,6 +154,8 @@
preferred_color = curcolor
for parent, link_type in parents:
if parent not in next_revs:
+ if parent in parents_to_add:
+ continue
parents_to_add.append(parent)
links_to_add.append(link_type)
children_to_add.append((curr_rev,))
Yuya Nishihara
2013-11-23 04:14:17 UTC
Permalink
Post by Simon Heimberg
# HG changeset patch
# Date 1384204372 -3600
# Node ID 2cd51a22e5d35ba3199288eade014390fb34a276
# Parent 6196dddb51b87dbfd1b1213ed05a59a6b52623ba
graph: only draw one line to one parent
Because the parents originate from multiple soucres it is theoretically possible
that several point to the same revision. Only take the first of this (which is
graftsource because it is added before).
diff -r 6196dddb51b8 -r 2cd51a22e5d3 tortoisehg/hgqt/graph.py
--- a/tortoisehg/hgqt/graph.py Die Nov 05 19:11:38 2013 +0100
+++ b/tortoisehg/hgqt/graph.py Mon Nov 11 22:12:52 2013 +0100
@@ -154,6 +154,8 @@
preferred_color = curcolor
+ continue
It looks good to me, but please insert a brief comment describing the problem
solved by this change. Is this happen if both "graft source" and "obsolete
precursor" point to the same revision?

The other patches also look good.

Regards,

Simon Heimberg
2013-11-22 09:18:27 UTC
Permalink
# HG changeset patch
# User Simon Heimberg <***@besonet.ch>
# Date 1383675098 -3600
# Node ID 6196dddb51b87dbfd1b1213ed05a59a6b52623ba
# Parent 469859aa8e16a5f8d379cd2dbe938d148e594310
graph: own style for line to obsolescence parents

diff -r 469859aa8e16 -r 6196dddb51b8 tortoisehg/hgqt/graph.py
--- a/tortoisehg/hgqt/graph.py Die Nov 05 17:55:49 2013 +0100
+++ b/tortoisehg/hgqt/graph.py Die Nov 05 19:11:38 2013 +0100
@@ -34,6 +34,7 @@

LINE_TYPE_PARENT = 0
LINE_TYPE_GRAFT = 1
+LINE_TYPE_OBSOLETE = 2

def revision_grapher(repo, **opts):
"""incremental revision grapher
@@ -143,7 +144,7 @@
for octx in obsoleteutil.first_known_precursors(ctx):
src_rev = octx.rev()
if stop_rev <= src_rev < curr_rev and not hidden(src_rev):
- parents.append((src_rev, LINE_TYPE_GRAFT))
+ parents.append((src_rev, LINE_TYPE_OBSOLETE))
parents_to_add = []
links_to_add = []
children_to_add = []
diff -r 469859aa8e16 -r 6196dddb51b8 tortoisehg/hgqt/repomodel.py
--- a/tortoisehg/hgqt/repomodel.py Die Nov 05 17:55:49 2013 +0100
+++ b/tortoisehg/hgqt/repomodel.py Die Nov 05 19:11:38 2013 +0100
@@ -23,7 +23,7 @@
from tortoisehg.util import hglib
from tortoisehg.hgqt.graph import Graph
from tortoisehg.hgqt.graph import revision_grapher
-from tortoisehg.hgqt.graph import LINE_TYPE_GRAFT
+from tortoisehg.hgqt import graph
from tortoisehg.hgqt import qtlib

from tortoisehg.hgqt.i18n import _
@@ -75,12 +75,14 @@
return colors[n % len(colors)]

def get_style(line_type, active):
- if line_type == LINE_TYPE_GRAFT:
+ if line_type == graph.LINE_TYPE_GRAFT:
return Qt.DashLine
+ if line_type == graph.LINE_TYPE_OBSOLETE:
+ return Qt.DotLine
return Qt.SolidLine

def get_width(line_type, active):
- if line_type == LINE_TYPE_GRAFT or not active:
+ if line_type >= graph.LINE_TYPE_GRAFT or not active:
return 1
return 2
Yuya Nishihara
2013-11-23 04:11:48 UTC
Permalink
Post by Simon Heimberg
* improve the patches as suggested by Yuya Nishihara
* fixed typo in Patch 1
* Patch 2 imports graph module (instead of only components)
* Patch 4 is new, cleaning further up the import of graph
The patch 1, "graph: graph can show a line to obsolescence parents", is
missing?
Post by Simon Heimberg
This is not tested, I can not do this. (But this time I run pyflakes and
pylint and tried to interpret the results.)
I wonder why you can't test it.

Regards,
Loading...