Patchwork [12,of,35] share: declare commands using decorator

login
register
mail settings
Submitter Gregory Szorc
Date May 5, 2014, 5:51 a.m.
Message ID <0765ac8ba948a2fa1dfd.1399269077@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4603/
State Accepted
Commit d2ce7a20fe8610ebc068acdbba25eb45d6931d75
Headers show

Comments

Gregory Szorc - May 5, 2014, 5:51 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1399264394 25200
#      Sun May 04 21:33:14 2014 -0700
# Branch stable
# Node ID 0765ac8ba948a2fa1dfd7c3e4f0229dfa26d289f
# Parent  cd2b984754b857109c16bfd85ebb94565089bc82
share: declare commands using decorator

Patch

diff --git a/hgext/share.py b/hgext/share.py
--- a/hgext/share.py
+++ b/hgext/share.py
@@ -1,20 +1,25 @@ 
 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
 '''share a common history between several working directories'''
 
 from mercurial.i18n import _
-from mercurial import hg, commands, util
+from mercurial import cmdutil, hg, commands, util
 
+cmdtable = {}
+command = cmdutil.command(cmdtable)
 testedwith = 'internal'
 
+@command('share',
+    [('U', 'noupdate', None, _('do not create a working copy'))],
+    _('[-U] SOURCE [DEST]'))
 def share(ui, source, dest=None, noupdate=False):
     """create a new shared repository
 
     Initialize a new repository and working directory that shares its
     history with another repository.
 
     .. note::
 
@@ -25,16 +30,17 @@  def share(ui, source, dest=None, noupdat
        with rollback, the other clone will suddenly stop working: all
        operations will fail with "abort: working directory has unknown
        parent". The only known workaround is to use debugsetparents on
        the broken clone to reset it to a changeset that still exists.
     """
 
     return hg.share(ui, source, dest, not noupdate)
 
+@command('unshare', [], '')
 def unshare(ui, repo):
     """convert a shared repository to a normal one
 
     Copy the store data to the repo and remove the sharedpath data.
     """
 
     if repo.sharedpath == repo.path:
         raise util.Abort(_("this is not a shared repo"))
@@ -56,20 +62,9 @@  def unshare(ui, repo):
         repo._writerequirements()
     finally:
         destlock and destlock.release()
         lock and lock.release()
 
     # update store, spath, sopener and sjoin of repo
     repo.unfiltered().__init__(repo.baseui, repo.root)
 
-cmdtable = {
-    "share":
-    (share,
-     [('U', 'noupdate', None, _('do not create a working copy'))],
-     _('[-U] SOURCE [DEST]')),
-    "unshare":
-    (unshare,
-    [],
-    ''),
-}
-
 commands.norepo += " share"