[PATCH 6 of 8] largefiles: divide "_lfautocommit='rebase'" scope into small ones

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Sep 9 13:18:50 CDT 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1410286453 -32400
#      Wed Sep 10 03:14:13 2014 +0900
# Node ID 514254647d89290af5d2d036479accda1e8ea729
# Parent  99a716366e69fccab7d1f6909d6c737a24385d90
largefiles: divide "_lfautocommit='rebase'" scope into small ones

Before this patch, "_lfautocommit='rebase'" scope covers whole "hg
rebase" execution. But only committing and merging need it.

This patch divides "_lfautocommit='rebase'" scope into 2 small ones
below.

  - "rebase.concludenode()" for committing the rebased revision
    (to execute "Case 0" code path in "lfilesrepo.commit")

  - "rebase.rebasenode()" for merging target revision
    (to suppress displaying some status messages)

Wrapping functions "rebaseconcludenode" and "rebaserebasenode" are
very simple ones, because these will be replaced soon in subsequent
patches.

This patch also removes "_lfautocommit='rebase'" scope for "hg pull
--rebase", because it collides against above ones.

"try/finally" clause for "_lfautocommit='rebase'" scope is kept to
reduce changes in this patch. "pull --rebase" specific code path will
be removed in the future, because it is now equal to "orig"
invocation.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -723,7 +723,6 @@
         source = 'default'
     repo.lfpullsource = source
     if opts.get('rebase', False):
-        repo._lfautocommit = 'rebase'
         try:
             if opts.get('update'):
                 del opts['update']
@@ -742,7 +741,7 @@
             if revspostpull > revsprepull:
                 result = result or rebase.rebase(ui, repo)
         finally:
-            repo._lfautocommit = False
+            pass
     else:
         result = orig(ui, repo, source, **opts)
     revspostpull = len(repo)
@@ -817,13 +816,6 @@
 
     return result
 
-def overriderebase(orig, ui, repo, **opts):
-    repo._lfautocommit = 'rebase'
-    try:
-        return orig(ui, repo, **opts)
-    finally:
-        repo._lfautocommit = False
-
 def overridearchive(orig, repo, dest, node, kind, decode=True, matchfn=None,
             prefix=None, mtime=None, subrepos=None):
     # No need to lock because we are only reading history and
@@ -1363,3 +1355,17 @@
             repo._lfautocommit = False
 
     return orig(commandname, repo, wrapper)
+
+def rebaseconcludenode(orig, repo, *args, **kwargs):
+    repo._lfautocommit = 'rebase'
+    try:
+        return orig(repo, *args, **kwargs)
+    finally:
+        repo._lfautocommit = False
+
+def rebaserebasenode(orig, repo, *args, **kwargs):
+    repo._lfautocommit = 'rebase'
+    try:
+        return orig(repo, *args, **kwargs)
+    finally:
+        repo._lfautocommit = False
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -171,8 +171,10 @@
             extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge',
                 overrides.overridepurge)
         if name == 'rebase':
-            extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase',
-                overrides.overriderebase)
+            extensions.wrapfunction(module, 'concludenode',
+                                    overrides.rebaseconcludenode)
+            extensions.wrapfunction(module, 'rebasenode',
+                                    overrides.rebaserebasenode)
         if name == 'transplant':
             extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant',
                 overrides.overridetransplant)


More information about the Mercurial-devel mailing list