Patchwork [1,of,4,V2] subrepo: add shortid() method to subrepo classes

login
register
mail settings
Submitter Angel Ezquerra
Date May 10, 2014, 11:38 p.m.
Message ID <fbd38caed1830c15ed74.1399765114@Angel-PC.localdomain>
Download mbox | patch
Permalink /patch/4722/
State Accepted
Headers show

Comments

Angel Ezquerra - May 10, 2014, 11:38 p.m.
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1399414100 -7200
#      Wed May 07 00:08:20 2014 +0200
# Node ID fbd38caed1830c15ed744fe85ee6442aaf11936f
# Parent  bcddddcf0b540b1d98f0dc1f1a1bef9337e2e567
subrepo: add shortid() method to subrepo classes

This method takes an "id" (e.g. a revision id) and returns a "short" version
(e.g. a short revision id).

This will be used on the next revision to fix a small bug in the way that the
text on the promptchoice shown when a subrepo diverges is generated.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -501,6 +501,9 @@ 
             % (substate[0], substate[2]))
         return []
 
+    def shortid(self, revid):
+        return revid
+
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
@@ -866,6 +869,9 @@ 
             pats = []
         cmdutil.revert(ui, self._repo, ctx, parents, *pats, **opts)
 
+    def shortid(self, revid):
+        return revid[:12]
+
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
@@ -1561,6 +1567,9 @@ 
         deleted = unknown = ignored = clean = []
         return modified, added, removed, deleted, unknown, ignored, clean
 
+    def shortid(self, revid):
+        return revid[:7]
+
 types = {
     'hg': hgsubrepo,
     'svn': svnsubrepo,