[PATCH 12 of 35] share: declare commands using decorator
Gregory Szorc
gregory.szorc at gmail.com
Mon May 5 00:51:17 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at 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
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 at 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'
+ at 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)
+ at 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"
More information about the Mercurial-devel
mailing list