Patchwork [11,of,35] relink: declare command using decorator

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

Comments

Gregory Szorc - May 5, 2014, 5:51 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1399265545 25200
#      Sun May 04 21:52:25 2014 -0700
# Branch stable
# Node ID cd2b984754b857109c16bfd85ebb94565089bc82
# Parent  d29ede43f707818fe796cb5e8fd44367de6c9e0b
relink: declare command using decorator

Patch

diff --git a/hgext/relink.py b/hgext/relink.py
--- a/hgext/relink.py
+++ b/hgext/relink.py
@@ -2,22 +2,25 @@ 
 #
 # Copyright (C) 2007 Brendan Cully <brendan@kublai.com>
 #
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
 """recreates hardlinks between repository clones"""
 
-from mercurial import hg, util
+from mercurial import cmdutil, hg, util
 from mercurial.i18n import _
 import os, stat
 
+cmdtable = {}
+command = cmdutil.command(cmdtable)
 testedwith = 'internal'
 
+@command('relink', [], _('[ORIGIN]'))
 def relink(ui, repo, origin=None, **opts):
     """recreate hardlinks between two repositories
 
     When repositories are cloned locally, their data files will be
     hardlinked so that they only use the space of a single repository.
 
     Unfortunately, subsequent pulls into either repository will break
     hardlinks for any files touched by the new changesets, even if
@@ -173,16 +176,8 @@  def do_relink(src, dst, files, ui):
             savedbytes += sz
         except OSError, inst:
             ui.warn('%s: %s\n' % (tgt, str(inst)))
 
     ui.progress(_('relinking'), None)
 
     ui.status(_('relinked %d files (%s reclaimed)\n') %
               (relinked, util.bytecount(savedbytes)))
-
-cmdtable = {
-    'relink': (
-        relink,
-        [],
-        _('[ORIGIN]')
-    )
-}