[PATCH 2 of 4 RFC] largefiles: add --lfsource flag to specify largefiles pulling source

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Nov 13 09:47:01 CST 2011


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1321197968 -32400
# Branch stable
# Node ID 0044c64b84315ba79eea458c8f198309b13438b5
# Parent  5c1279816b1b11f38c3786f6b7d3ead8f9b7dfdd
largefiles: add --lfsource flag to specify largefiles pulling source

current implementation can cache largefiles only from "default-push"
or "default" path, so you should use "--config path.default=URL"
option, if you want not to set them or to choose other than them.

this style also forces you to specify full URL path instead of
nickname of it described in hgrc files.

this patch adds --lfsource flag to specify largefiles pulling source
for commands which may be trigger of caching largefiles.

and other RFC points for this patch are:

  - are there any other commands/extensions to be overrideden ?

  - name of flag: "--lfpullsource" ?

  - are there any other good ways to pass pulling source ?

  - what should this patch do for basestore.StoreError ?

    now, it shows "(no default or default-push path set in hgrc)"

diff -r 5c1279816b1b -r 0044c64b8431 hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Mon Nov 14 00:08:57 2011 +0900
+++ b/hgext/largefiles/overrides.py	Mon Nov 14 00:26:08 2011 +0900
@@ -820,3 +820,11 @@
     result = orig(ui, repo, *revs, **opts)
     lfcommands.updatelfiles(repo.ui, repo)
     return result
+
+# Hook to get --lfsource option and store it into (lfiles) repo
+# as source for pulling largefiles
+def override_openstore_trigger(orig, ui, repo, **opts):
+    lfsource = opts.pop('lfsource', None)
+    if lfsource:
+        repo.lfpullsource = ui.expandpath(lfsource)
+    return orig(ui, repo, **opts)
diff -r 5c1279816b1b -r 0044c64b8431 hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py	Mon Nov 14 00:08:57 2011 +0900
+++ b/hgext/largefiles/uisetup.py	Mon Nov 14 00:26:08 2011 +0900
@@ -121,17 +121,45 @@
     # don't die on seeing a repo with the largefiles requirement
     localrepo.localrepository.supported |= set(['largefiles'])
 
+    # list of commands which may cause pulling largefiles
+    lfsourcecmds = [
+        ('archive', commands.table),
+        ('backout', commands.table),
+        ('bisect', commands.table),
+        ('clone', commands.table),
+        ('import', commands.table),
+        ('merge', commands.table),
+        ('pull', commands.table),
+        ('push', commands.table),
+        ('revert', commands.table),
+        ('unbundle', commands.table),
+        ('update', commands.table),
+        ('verify', commands.table),
+        ]
+
     # override some extensions' stuff as well
     for name, module in extensions.extensions():
         if name == 'fetch':
-            extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch',
-                overrides.override_fetch)
+            cmdtable = getattr(module, 'cmdtable')
+            extensions.wrapcommand(cmdtable, 'fetch',
+                                   overrides.override_fetch)
+            lfsourcecmds.append(('transplant', cmdtable))
         if name == 'purge':
             extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
-                overrides.override_purge)
+                                   overrides.override_purge)
         if name == 'rebase':
-            extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
-                overrides.override_rebase)
+            cmdtable = getattr(module, 'cmdtable')
+            extensions.wrapcommand(cmdtable, 'rebase',
+                                   overrides.override_rebase)
+            lfsourcecmds.append(('rebase', cmdtable))
         if name == 'transplant':
-            extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
-                overrides.override_transplant)
+            cmdtable = getattr(module, 'cmdtable')
+            extensions.wrapcommand(cmdtable, 'transplant',
+                                   overrides.override_transplant)
+            lfsourcecmds.append(('transplant', cmdtable))
+
+    for cmd, cmdtable in lfsourcecmds:
+        entry = extensions.wrapcommand(cmdtable, cmd,
+                                       overrides.override_openstore_trigger)
+        entry[1].extend([('', 'lfsource', '',
+                          _('source of pulling largefiles'), _('REPO'))])


More information about the Mercurial-devel mailing list