Patchwork [2,of,2,remotefilelog] commands: tell @command decorator about arguments

login
register
mail settings
Submitter via Mercurial-devel
Date June 30, 2016, 5:18 p.m.
Message ID <996e841ae19eab36071e.1467307098@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/15671/
State Accepted
Headers show

Comments

via Mercurial-devel - June 30, 2016, 5:18 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1467306857 25200
#      Thu Jun 30 10:14:17 2016 -0700
# Node ID 996e841ae19eab36071e1fdd6ec58c853c8fc51a
# Parent  3d3cdba3b43fb1e403d860d509e8c6fb1c2761f2
commands: tell @command decorator about arguments

Before this patch, debugremotefilelog and verifyremotefilelog would
crash if not given a path. Also, many commands would accept arguments
they then ignored.
Durham Goode - July 5, 2016, 8:46 p.m.
Accepted and pushed. Thanks

On 6/30/16, 10:18 AM, "Martin von Zweigbergk" <martinvonz@google.com> wrote:

># HG changeset patch

># User Martin von Zweigbergk <martinvonz@google.com>

># Date 1467306857 25200

>#      Thu Jun 30 10:14:17 2016 -0700

># Node ID 996e841ae19eab36071e1fdd6ec58c853c8fc51a

># Parent  3d3cdba3b43fb1e403d860d509e8c6fb1c2761f2

>commands: tell @command decorator about arguments

>

>Before this patch, debugremotefilelog and verifyremotefilelog would

>crash if not given a path. Also, many commands would accept arguments

>they then ignored.

>

>diff -r 3d3cdba3b43f -r 996e841ae19e remotefilelog/__init__.py

>--- a/remotefilelog/__init__.py	Thu Jun 30 10:11:37 2016 -0700

>+++ b/remotefilelog/__init__.py	Thu Jun 30 10:14:17 2016 -0700

>@@ -749,28 +749,28 @@

> @command('debugremotefilelog', [

>     ('d', 'decompress', None, _('decompress the filelog first')),

>     ], _('hg debugremotefilelog <path>'), norepo=True)

>-def debugremotefilelog(ui, *args, **opts):

>-    return debugcommands.debugremotefilelog(ui, *args, **opts)

>+def debugremotefilelog(ui, path, **opts):

>+    return debugcommands.debugremotefilelog(ui, path, **opts)

> 

> @command('verifyremotefilelog', [

>     ('d', 'decompress', None, _('decompress the filelogs first')),

>     ], _('hg verifyremotefilelogs <directory>'), norepo=True)

>-def verifyremotefilelog(ui, *args, **opts):

>-    return debugcommands.verifyremotefilelog(ui, *args, **opts)

>+def verifyremotefilelog(ui, path, **opts):

>+    return debugcommands.verifyremotefilelog(ui, path, **opts)

> 

> @command('debugdatapack', [

>     ], _('hg debugdatapack <path>'), norepo=True)

>-def debugdatapack(ui, path, *args, **opts):

>-    return debugcommands.debugdatapack(ui, path, *args, **opts)

>+def debugdatapack(ui, path, **opts):

>+    return debugcommands.debugdatapack(ui, path)

> 

> @command('debughistorypack', [

>     ], _('hg debughistorypack <path>'), norepo=True)

>-def debughistorypack(ui, path, *args, **opts):

>-    return debugcommands.debughistorypack(ui, path, *args, **opts)

>+def debughistorypack(ui, path, **opts):

>+    return debugcommands.debughistorypack(ui, path)

> 

> @command('debugwaitonrepack', [

>     ], _('hg debugwaitonrepack'))

>-def debugwaitonrepack(ui, repo, *args, **opts):

>+def debugwaitonrepack(ui, repo, **opts):

>     return debugcommands.debugwaitonrepack(repo)

> 

> @command('prefetch', [

>diff -r 3d3cdba3b43f -r 996e841ae19e remotefilelog/debugcommands.py

>--- a/remotefilelog/debugcommands.py	Thu Jun 30 10:11:37 2016 -0700

>+++ b/remotefilelog/debugcommands.py	Thu Jun 30 10:14:17 2016 -0700

>@@ -11,9 +11,7 @@

> import datapack, historypack, shallowrepo

> import hashlib, os, lz4

> 

>-def debugremotefilelog(ui, *args, **opts):

>-    path = args[0]

>-

>+def debugremotefilelog(ui, path, **opts):

>     decompress = opts.get('decompress')

> 

>     size, firstnode, mapping = parsefileblob(path, decompress)

>@@ -138,9 +136,7 @@

>             ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))

>     ui.write("}\n")

> 

>-def verifyremotefilelog(ui, *args, **opts):

>-    path = args[0]

>-

>+def verifyremotefilelog(ui, path, **opts):

>     decompress = opts.get('decompress')

> 

>     for root, dirs, files in os.walk(path):

>@@ -193,7 +189,7 @@

> 

>     return size, firstnode, mapping

> 

>-def debugdatapack(ui, path, *args, **kwargs):

>+def debugdatapack(ui, path):

>     dpack = datapack.datapack(path)

> 

>     lastfilename = None

>@@ -207,7 +203,7 @@

>             lastfilename = filename

>         ui.write("%s  %s  %s\n" % (short(node), short(deltabase), deltalen))

> 

>-def debughistorypack(ui, path, *args, **kwargs):

>+def debughistorypack(ui, path):

>     hpack = historypack.historypack(path)

> 

>     lastfilename = None

Patch

diff -r 3d3cdba3b43f -r 996e841ae19e remotefilelog/__init__.py
--- a/remotefilelog/__init__.py	Thu Jun 30 10:11:37 2016 -0700
+++ b/remotefilelog/__init__.py	Thu Jun 30 10:14:17 2016 -0700
@@ -749,28 +749,28 @@ 
 @command('debugremotefilelog', [
     ('d', 'decompress', None, _('decompress the filelog first')),
     ], _('hg debugremotefilelog <path>'), norepo=True)
-def debugremotefilelog(ui, *args, **opts):
-    return debugcommands.debugremotefilelog(ui, *args, **opts)
+def debugremotefilelog(ui, path, **opts):
+    return debugcommands.debugremotefilelog(ui, path, **opts)
 
 @command('verifyremotefilelog', [
     ('d', 'decompress', None, _('decompress the filelogs first')),
     ], _('hg verifyremotefilelogs <directory>'), norepo=True)
-def verifyremotefilelog(ui, *args, **opts):
-    return debugcommands.verifyremotefilelog(ui, *args, **opts)
+def verifyremotefilelog(ui, path, **opts):
+    return debugcommands.verifyremotefilelog(ui, path, **opts)
 
 @command('debugdatapack', [
     ], _('hg debugdatapack <path>'), norepo=True)
-def debugdatapack(ui, path, *args, **opts):
-    return debugcommands.debugdatapack(ui, path, *args, **opts)
+def debugdatapack(ui, path, **opts):
+    return debugcommands.debugdatapack(ui, path)
 
 @command('debughistorypack', [
     ], _('hg debughistorypack <path>'), norepo=True)
-def debughistorypack(ui, path, *args, **opts):
-    return debugcommands.debughistorypack(ui, path, *args, **opts)
+def debughistorypack(ui, path, **opts):
+    return debugcommands.debughistorypack(ui, path)
 
 @command('debugwaitonrepack', [
     ], _('hg debugwaitonrepack'))
-def debugwaitonrepack(ui, repo, *args, **opts):
+def debugwaitonrepack(ui, repo, **opts):
     return debugcommands.debugwaitonrepack(repo)
 
 @command('prefetch', [
diff -r 3d3cdba3b43f -r 996e841ae19e remotefilelog/debugcommands.py
--- a/remotefilelog/debugcommands.py	Thu Jun 30 10:11:37 2016 -0700
+++ b/remotefilelog/debugcommands.py	Thu Jun 30 10:14:17 2016 -0700
@@ -11,9 +11,7 @@ 
 import datapack, historypack, shallowrepo
 import hashlib, os, lz4
 
-def debugremotefilelog(ui, *args, **opts):
-    path = args[0]
-
+def debugremotefilelog(ui, path, **opts):
     decompress = opts.get('decompress')
 
     size, firstnode, mapping = parsefileblob(path, decompress)
@@ -138,9 +136,7 @@ 
             ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
     ui.write("}\n")
 
-def verifyremotefilelog(ui, *args, **opts):
-    path = args[0]
-
+def verifyremotefilelog(ui, path, **opts):
     decompress = opts.get('decompress')
 
     for root, dirs, files in os.walk(path):
@@ -193,7 +189,7 @@ 
 
     return size, firstnode, mapping
 
-def debugdatapack(ui, path, *args, **kwargs):
+def debugdatapack(ui, path):
     dpack = datapack.datapack(path)
 
     lastfilename = None
@@ -207,7 +203,7 @@ 
             lastfilename = filename
         ui.write("%s  %s  %s\n" % (short(node), short(deltabase), deltalen))
 
-def debughistorypack(ui, path, *args, **kwargs):
+def debughistorypack(ui, path):
     hpack = historypack.historypack(path)
 
     lastfilename = None