Patchwork [4,of,4] graft: show hashes in user facing messages

login
register
mail settings
Submitter Mads Kiilerich
Date Dec. 9, 2014, 3:11 a.m.
Message ID <2067bed836bb93279036.1418094718@localhost.localdomain>
Download mbox | patch
Permalink /patch/7031/
State Superseded
Headers show

Comments

Mads Kiilerich - Dec. 9, 2014, 3:11 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1418092703 -3600
#      Tue Dec 09 03:38:23 2014 +0100
# Node ID 2067bed836bb93279036da80862e2cb9821fef9b
# Parent  4cb3b2d2dc468c0bf4b293412dacc204c84a6a6b
graft: show hashes in user facing messages

Graft was in various places just showing the internal revision number in status
messges. Instead, also show the stable and more useful short hash.
Matt Mackall - Dec. 9, 2014, 6:34 p.m.
On Tue, 2014-12-09 at 04:11 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1418092703 -3600
> #      Tue Dec 09 03:38:23 2014 +0100
> # Node ID 2067bed836bb93279036da80862e2cb9821fef9b
> # Parent  4cb3b2d2dc468c0bf4b293412dacc204c84a6a6b
> graft: show hashes in user facing messages

These are queued for default, thanks.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3396,7 +3396,8 @@  def graft(ui, repo, *revs, **opts):
         # don't mutate while iterating, create a copy
         for rev in list(revs):
             if rev in ancestors:
-                ui.warn(_('skipping ancestor revision %s\n') % rev)
+                ui.warn(_('skipping ancestor revision %d:%s\n') %
+                        (rev, repo[rev]))
                 # XXX remove on list is slow
                 revs.remove(rev)
         if not revs:
@@ -3422,23 +3423,25 @@  def graft(ui, repo, *revs, **opts):
                 except error.RepoLookupError:
                     r = None
                 if r in revs:
-                    ui.warn(_('skipping revision %s (already grafted to %s)\n')
-                            % (r, rev))
+                    ui.warn(_('skipping revision %d:%s '
+                              '(already grafted to %d:%s)\n')
+                            % (r, repo[r], rev, ctx))
                     revs.remove(r)
                 elif ids[n] in revs:
                     if r is None:
-                        ui.warn(_('skipping already grafted revision %s '
-                                  '(%s also has unknown origin %s)\n')
-                                % (ids[n], rev, n))
+                        ui.warn(_('skipping already grafted revision %d:%s '
+                                  '(%d:%s also has unknown origin %s)\n')
+                                % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
                     else:
-                        ui.warn(_('skipping already grafted revision %s '
-                                  '(%s also has origin %d)\n')
-                                % (ids[n], rev, r))
+                        ui.warn(_('skipping already grafted revision %d:%s '
+                                  '(%d:%s also has origin %d:%s)\n')
+                                % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
                     revs.remove(ids[n])
             elif ctx.hex() in ids:
                 r = ids[ctx.hex()]
-                ui.warn(_('skipping already grafted revision %s '
-                                '(was grafted from %d)\n') % (r, rev))
+                ui.warn(_('skipping already grafted revision %d:%s '
+                          '(was grafted from %d:%s)\n') %
+                        (r, repo[r], rev, ctx))
                 revs.remove(r)
         if not revs:
             return -1
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -50,20 +50,20 @@  Need to specify a rev:
 Can't graft ancestor:
 
   $ hg graft 1 2
-  skipping ancestor revision 1
-  skipping ancestor revision 2
+  skipping ancestor revision 1:5d205f8b35b6
+  skipping ancestor revision 2:5c095ad7e90f
   [255]
 
 Specify revisions with -r:
 
   $ hg graft -r 1 -r 2
-  skipping ancestor revision 1
-  skipping ancestor revision 2
+  skipping ancestor revision 1:5d205f8b35b6
+  skipping ancestor revision 2:5c095ad7e90f
   [255]
 
   $ hg graft -r 1 2
-  skipping ancestor revision 2
-  skipping ancestor revision 1
+  skipping ancestor revision 2:5c095ad7e90f
+  skipping ancestor revision 1:5d205f8b35b6
   [255]
 
 Can't graft with dirty wd:
@@ -132,7 +132,7 @@  Graft out of order, skipping a merge and
 
   $ hg graft 1 5 4 3 'merge()' 2 -n
   skipping ungraftable merge revision 6
-  skipping revision 2 (already grafted to 7)
+  skipping revision 2:5c095ad7e90f (already grafted to 7:ef0ef43d49e7)
   grafting 1:5d205f8b35b6 "1"
   grafting 5:97f8bfe72746 "5"
   grafting 4:9c233e8e184d "4"
@@ -141,7 +141,7 @@  Graft out of order, skipping a merge and
   $ HGEDITOR=cat hg graft 1 5 4 3 'merge()' 2 --debug
   skipping ungraftable merge revision 6
   scanning for duplicate grafts
-  skipping revision 2 (already grafted to 7)
+  skipping revision 2:5c095ad7e90f (already grafted to 7:ef0ef43d49e7)
   grafting 1:5d205f8b35b6 "1"
     searching for copies back to rev 1
     unmatched files in local:
@@ -213,9 +213,9 @@  Graft again:
 
   $ hg graft 1 5 4 3 'merge()' 2
   skipping ungraftable merge revision 6
-  skipping revision 2 (already grafted to 7)
-  skipping revision 1 (already grafted to 8)
-  skipping revision 5 (already grafted to 9)
+  skipping revision 2:5c095ad7e90f (already grafted to 7:ef0ef43d49e7)
+  skipping revision 1:5d205f8b35b6 (already grafted to 8:6b9e5368ca4e)
+  skipping revision 5:97f8bfe72746 (already grafted to 9:1905859650ec)
   grafting 4:9c233e8e184d "4"
   merging e
   warning: conflicts during merge.
@@ -326,24 +326,24 @@  Graft again onto another branch should p
 Disallow grafting an already grafted cset onto its original branch
   $ hg up -q 6
   $ hg graft 7
-  skipping already grafted revision 7 (was grafted from 2)
+  skipping already grafted revision 7:ef0ef43d49e7 (was grafted from 2:5c095ad7e90f)
   [255]
 
 Disallow grafting already grafted csets with the same origin onto each other
   $ hg up -q 13
   $ hg graft 2
-  skipping revision 2 (already grafted to 13)
+  skipping revision 2:5c095ad7e90f (already grafted to 13:9db0f28fd374)
   [255]
   $ hg graft 7
-  skipping already grafted revision 7 (13 also has origin 2)
+  skipping already grafted revision 7:ef0ef43d49e7 (13:9db0f28fd374 also has origin 2:5c095ad7e90f)
   [255]
 
   $ hg up -q 7
   $ hg graft 2
-  skipping revision 2 (already grafted to 7)
+  skipping revision 2:5c095ad7e90f (already grafted to 7:ef0ef43d49e7)
   [255]
   $ hg graft tip
-  skipping already grafted revision 13 (7 also has origin 2)
+  skipping already grafted revision 13:9db0f28fd374 (7:ef0ef43d49e7 also has origin 2:5c095ad7e90f)
   [255]
 
 Graft with --log
@@ -641,9 +641,9 @@  All copies of a cset
 graft works on complex revset
 
   $ hg graft 'origin(13) or destination(origin(13))'
-  skipping ancestor revision 21
-  skipping ancestor revision 22
-  skipping revision 2 (already grafted to 22)
+  skipping ancestor revision 21:7e61b508e709
+  skipping ancestor revision 22:1313d0a825e2
+  skipping revision 2:5c095ad7e90f (already grafted to 22:1313d0a825e2)
   grafting 7:ef0ef43d49e7 "2"
   grafting 13:9db0f28fd374 "2"
   grafting 19:9627f653b421 "2"
@@ -653,8 +653,8 @@  graft with --force (still doesn't graft 
 
   $ hg graft 19 0 6
   skipping ungraftable merge revision 6
-  skipping ancestor revision 0
-  skipping already grafted revision 19 (22 also has origin 2)
+  skipping ancestor revision 0:68795b066622
+  skipping already grafted revision 19:9627f653b421 (22:1313d0a825e2 also has origin 2:5c095ad7e90f)
   [255]
   $ hg graft 19 0 6 --force
   skipping ungraftable merge revision 6
@@ -670,7 +670,7 @@  graft --force after backout
   reverting a
   changeset 29:484c03b8dfa4 backs out changeset 28:6c56f0f7f033
   $ hg graft 28
-  skipping ancestor revision 28
+  skipping ancestor revision 28:6c56f0f7f033
   [255]
   $ hg graft 28 --force
   grafting 28:6c56f0f7f033 "28"
@@ -708,7 +708,7 @@  but do some destructive editing of the r
   $ hg --config extensions.mq= strip 2
   saved backup bundle to $TESTTMP/a/.hg/strip-backup/5c095ad7e90f-backup.hg (glob)
   $ hg graft tmp
-  skipping already grafted revision 8 (2 also has unknown origin 5c095ad7e90f871700f02dd1fa5012cb4498a2d4)
+  skipping already grafted revision 8:9db0f28fd374 (2:ef0ef43d49e7 also has unknown origin 5c095ad7e90f)
   [255]
 
 Empty graft