changeset 181:e37f9d3fd5e7

remove decorators (compat with python2.3)
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Tue, 13 Jan 2009 13:59:50 +0100
parents 3f1e8a5ec9dd
children 47d25d61abfa
files diff_cmd.py fetch_command.py hg_delta_editor.py push_cmd.py rebuildmeta.py svncommand.py svnwrap/svn_ctypes_wrapper.py svnwrap/svn_swig_wrapper.py utility_commands.py
diffstat 9 files changed, 42 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/diff_cmd.py
+++ b/diff_cmd.py
@@ -24,7 +24,6 @@ def filterdiff(diff, base_revision):
     return diff
 
 
-@util.register_subcommand('diff')
 def diff_command(ui, repo, hg_repo_path, **opts):
     """Show a diff of the most recent revision against its parent from svn.
     """
@@ -47,3 +46,4 @@ def diff_command(ui, repo, hg_repo_path,
                                                   'text': False,
                                                   }))
     ui.write(filterdiff(''.join(it), base_rev))
+diff_command = util.register_subcommand('diff')(diff_command)
--- a/fetch_command.py
+++ b/fetch_command.py
@@ -21,7 +21,6 @@ def print_your_svn_is_old_message(ui): #
               "as good a job. You should really upgrade your server.\n")
 
 
-@util.register_subcommand('pull')
 def fetch_revisions(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None,
                     tag_locations='tags',
                     authors=None,
@@ -107,6 +106,7 @@ def fetch_revisions(ui, svn_url, hg_repo
                     else:
                         raise
     merc_util._encoding = old_encoding
+fetch_revisions = util.register_subcommand('pull')(fetch_revisions)
 
 
 def cleanup_file_handles(svn, count):
--- a/hg_delta_editor.py
+++ b/hg_delta_editor.py
@@ -632,50 +632,49 @@ class HgChangeReceiver(delta.Editor):
                     % (filemapfile, line.rstrip()))
         f.close()
 
-    @property
     def meta_data_dir(self):
         return os.path.join(self.path, '.hg', 'svn')
+    meta_data_dir = property(meta_data_dir)
 
     def meta_file_named(self, name):
         return os.path.join(self.meta_data_dir, name)
 
-    @property
     def revmap_file(self):
         return self.meta_file_named('rev_map')
+    revmap_file = property(revmap_file)
 
-    @property
     def svn_url_file(self):
         return self.meta_file_named('url')
+    svn_url_file = property(svn_url_file)
 
-    @property
     def uuid_file(self):
         return self.meta_file_named('uuid')
+    uuid_file = property(uuid_file)
 
-    @property
     def last_revision_handled_file(self):
         return self.meta_file_named('last_rev')
+    last_revision_handled_file = property(last_revision_handled_file)
 
-    @property
     def branch_info_file(self):
         return self.meta_file_named('branch_info')
+    branch_info_file = property(branch_info_file)
 
-    @property
     def tag_info_file(self):
         return self.meta_file_named('tag_info')
+    tag_info_file = property(tag_info_file)
 
-    @property
     def tag_locations_file(self):
         return self.meta_file_named('tag_locations')
+    tag_locations_file = property(tag_locations_file)
 
-    @property
     def url(self):
         return open(self.svn_url_file).read()
+    url = property(url)
 
-    @property
     def authors_file(self):
         return self.meta_file_named('authors')
+    authors_file = property(authors_file)
 
-    @stash_exception_on_self
     def delete_entry(self, path, revision_bogus, parent_baton, pool=None):
         br_path, branch = self._path_and_branch_for_path(path)
         if br_path == '':
@@ -700,8 +699,8 @@ class HgChangeReceiver(delta.Editor):
                     if f_p not in self.current_files:
                         self.delete_file(f_p)
             self.delete_file(path)
+    delete_entry = stash_exception_on_self(delete_entry)
 
-    @stash_exception_on_self
     def open_file(self, path, parent_baton, base_revision, p=None):
         self.current_file = 'foobaz'
         fpath, branch = self._path_and_branch_for_path(path)
@@ -713,6 +712,7 @@ class HgChangeReceiver(delta.Editor):
             else:
                 self.base_revision = None
             self.should_edit_most_recent_plaintext = True
+    open_file = stash_exception_on_self(open_file)
 
     def aresamefiles(self, parentctx, childctx, files):
         """Assuming all files exist in childctx and parentctx, return True
@@ -738,7 +738,6 @@ class HgChangeReceiver(delta.Editor):
         # parentctx is not an ancestor of childctx, files are unrelated
         return False
 
-    @stash_exception_on_self
     def add_file(self, path, parent_baton, copyfrom_path,
                  copyfrom_revision, file_pool=None):
         self.current_file = 'foobaz'
@@ -774,8 +773,8 @@ class HgChangeReceiver(delta.Editor):
                 parentctx = self.repo.changectx(parentid)
                 if self.aresamefiles(parentctx, ctx, [from_file]):
                     self.copies[path] = from_file
+    add_file = stash_exception_on_self(add_file)
 
-    @stash_exception_on_self
     def add_directory(self, path, parent_baton, copyfrom_path,
                       copyfrom_revision, dir_pool=None):
         self.dir_batons[path] = path
@@ -832,36 +831,36 @@ class HgChangeReceiver(delta.Editor):
                 if self.aresamefiles(parentctx, cp_f_ctx, copies.values()):
                     self.copies.update(copies)
         return path
+    add_directory = stash_exception_on_self(add_directory)
 
-    @stash_exception_on_self
     def change_file_prop(self, file_baton, name, value, pool=None):
         if name == 'svn:executable':
             self.current_files_exec[self.current_file] = bool(value is not None)
         elif name == 'svn:special':
             self.current_files_symlink[self.current_file] = bool(value is not None)
+    change_file_prop = stash_exception_on_self(change_file_prop)
 
-    @stash_exception_on_self
     def change_dir_prop(self, dir_baton, name, value, pool=None):
         if dir_baton is None:
             return
         path = self.dir_batons[dir_baton]
         if name == 'svn:externals':
             self.externals[path] = value
+    change_dir_prop = stash_exception_on_self(change_dir_prop)
 
-    @stash_exception_on_self
     def open_directory(self, path, parent_baton, base_revision, dir_pool=None):
         self.dir_batons[path] = path
         p_, branch = self._path_and_branch_for_path(path)
         if p_ == '':
             self.commit_branches_empty[branch] = False
         return path
+    open_directory = stash_exception_on_self(open_directory)
 
-    @stash_exception_on_self
     def close_directory(self, dir_baton, dir_pool=None):
         if dir_baton is not None:
             del self.dir_batons[dir_baton]
+    close_directory = stash_exception_on_self(close_directory)
 
-    @stash_exception_on_self
     def apply_textdelta(self, file_baton, base_checksum, pool=None):
         base = ''
         if not self._is_path_valid(self.current_file):
@@ -913,6 +912,7 @@ class HgChangeReceiver(delta.Editor):
                 self._exception_info = sys.exc_info()
                 raise
         return txdelt_window
+    apply_textdelta = stash_exception_on_self(apply_textdelta)
 
 class MissingPlainTextError(Exception):
     """Exception raised when the repo lacks a source file required for replaying
--- a/push_cmd.py
+++ b/push_cmd.py
@@ -11,8 +11,6 @@ import fetch_command
 import utility_commands
 
 
-@util.register_subcommand('push')
-@util.register_subcommand('dcommit') # for git expats
 def push_revisions_to_subversion(ui, repo, hg_repo_path, svn_url,
                                  stupid=False, **opts):
     """Push revisions starting at a specified head back to Subversion.
@@ -91,6 +89,9 @@ def push_revisions_to_subversion(ui, rep
         svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys()))
     merc_util._encoding = oldencoding
     return 0
+push_revisions_to_subversion = util.register_subcommand('push')(push_revisions_to_subversion)
+# for git expats
+push_revisions_to_subversion = util.register_subcommand('dcommit')(push_revisions_to_subversion)
 
 def _isdir(svn, branchpath, svndir):
     try:
--- a/rebuildmeta.py
+++ b/rebuildmeta.py
@@ -6,7 +6,6 @@ from mercurial import node
 import svnwrap
 import util
 
-@util.register_subcommand('rebuildmeta')
 def rebuildmeta(ui, repo, hg_repo_path, args, **opts):
     """Rebuild hgsubversion metadata using values stored in revisions.
     """
@@ -108,6 +107,7 @@ def rebuildmeta(ui, repo, hg_repo_path, 
     tagsinfofile = open(os.path.join(svnmetadir, 'tag_info'), 'w')
     pickle.dump(tagsinfo, tagsinfofile)
     tagsinfofile.close()
+rebuildmeta = util.register_subcommand('rebuildmeta')(rebuildmeta)
 
 
 def determinebranch(branch):
--- a/svncommand.py
+++ b/svncommand.py
@@ -54,7 +54,6 @@ def svncmd(ui, repo, subcommand, *args, 
             raise
 
 
-@register_subcommand('help')
 def help_command(ui, args=None, **opts):
     """Get help on the subsubcommands.
     """
@@ -77,8 +76,8 @@ def help_command(ui, args=None, **opts):
         ui.status(doc.strip(), '\n')
         return
     ui.status(generate_help())
+help_command = register_subcommand('help')(help_command)
 
-@register_subcommand('up')
 def update(ui, args, repo, clean=False, **opts):
     """Update to a specified Subversion revision number.
     """
@@ -101,9 +100,9 @@ def update(ui, args, repo, clean=False, 
         ui.status('\n'.join(['%s on %s' % (node.hex(a[0]), a[1]) for a in
                              answers]+['']))
     return 1
+update = register_subcommand('up')(update)
 
 
-@register_subcommand('verify_revision')
 def verify_revision(ui, args, repo, force=False, **opts):
     """Verify a single converted revision.
     Note: This wipes your working copy and then exports the corresponding
@@ -139,8 +138,8 @@ def verify_revision(ui, args, repo, forc
             ui.status('OK.\n')
             return 0
     return 1
+verify_revision = register_subcommand('verify_revision')(verify_revision)
 
-@register_subcommand('verify_all_revisions')
 def verify_all_revisions(ui, args, repo, **opts):
     """Verify all the converted revisions
     optionally starting at a revision.
@@ -168,3 +167,4 @@ def verify_all_revisions(ui, args, repo,
             print revnum, 'failed'
             return 1
     return 0
+verify_all_revisions = register_subcommand('verify_all_revisions')(verify_all_revisions)
--- a/svnwrap/svn_ctypes_wrapper.py
+++ b/svnwrap/svn_ctypes_wrapper.py
@@ -39,27 +39,27 @@ class SubversionRepo(object):
         # TODO(augie) need to figure out a way to do auth
         self.repo = repos.RemoteRepository(self.svn_url)
 
-    @property
     def HEAD(self):
         raise NotImplementedError
+    HEAD = property(HEAD)
 
-    @property
     def START(self):
         return 0
+    START = property(START)
 
-    @property
     def branches(self):
         """Get the branches defined in this repo assuming a standard layout.
         """
         raise NotImplementedError
+    branches = property(branches)
 
-    @property
     def tags(self):
         """Get the current tags in this repo assuming a standard layout.
 
         This returns a dictionary of tag: (source path, source rev)
         """
         raise NotImplementedError
+    tags = property(tags)
 
     def _get_copy_source(self, path, cached_head=None):
         """Get copy revision for the given path, assuming it was meant to be
--- a/svnwrap/svn_swig_wrapper.py
+++ b/svnwrap/svn_swig_wrapper.py
@@ -146,15 +146,14 @@ class SubversionRepo(object):
         self.ra = ra.open2(self.svn_url.encode('utf-8'), callbacks,
                            svn_config, self.pool)
 
-    @property
     def HEAD(self):
         return ra.get_latest_revnum(self.ra, self.pool)
+    HEAD = property(HEAD)
 
-    @property
     def START(self):
         return 0
+    START = property(START)
 
-    @property
     def branches(self):
         """Get the branches defined in this repo assuming a standard layout.
         """
@@ -173,14 +172,15 @@ class SubversionRepo(object):
             if source is not None and source_rev is not None:
                 branch_info[b] = (source, source_rev, hist.revnum)
         return branch_info
+    branches = property(branches)
 
-    @property
     def tags(self):
         """Get the current tags in this repo assuming a standard layout.
 
         This returns a dictionary of tag: (source path, source rev)
         """
         return self.tags_at_rev(self.HEAD)
+    tags = property(tags)
 
     def tags_at_rev(self, revision):
         try:
--- a/utility_commands.py
+++ b/utility_commands.py
@@ -6,16 +6,15 @@ from hgext import rebase
 import util
 import hg_delta_editor
 
-@util.register_subcommand('url')
 def print_wc_url(ui, repo, hg_repo_path, **opts):
     """Url of Subversion repository.
     """
     hge = hg_delta_editor.HgChangeReceiver(hg_repo_path,
                                            ui_=ui)
     ui.status(hge.url, '\n')
+print_wc_url = util.register_subcommand('url')(print_wc_url)
 
 
-@util.register_subcommand('info')
 def run_svn_info(ui, repo, hg_repo_path, **opts):
     """Like svn info details.
     """
@@ -57,9 +56,9 @@ Last Changed Date: %(date)s\n''' %
                'date': mutil.datestr(workingctx.date(),
                                      '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
               })
+run_svn_info = util.register_subcommand('info')(run_svn_info)
 
 
-@util.register_subcommand('parent')
 def print_parent_revision(ui, repo, hg_repo_path, **opts):
     """Display hg hash and svn revision of nearest svn parent.
     """
@@ -78,9 +77,9 @@ def print_parent_revision(ui, repo, hg_r
     else:
         ui.status('Working copy seems to have no parent svn revision.\n')
     return 0
+print_parent_revision = util.register_subcommand('parent')(print_parent_revision)
 
 
-@util.register_subcommand('rebase')
 def rebase_commits(ui, repo, hg_repo_path, extrafn=None, sourcerev=None, **opts):
     """Rebases current unpushed revisions onto Subversion head.
 
@@ -128,9 +127,9 @@ def rebase_commits(ui, repo, hg_repo_pat
     return rebase.rebase(ui, repo, dest=node.hex(target_rev.node()),
                          base=node.hex(sourcerev),
                          extrafn=extrafn)
+rebase_commits = util.register_subcommand('rebase')(rebase_commits)
 
 
-@util.register_subcommand('outgoing')
 def show_outgoing_to_svn(ui, repo, hg_repo_path, **opts):
     """Show changesets not yet pushed to SVN.
     """
@@ -145,3 +144,4 @@ def show_outgoing_to_svn(ui, repo, hg_re
     displayer = cmdutil.show_changeset(ui, repo, opts, buffered=False)
     for node in reversed(o_r):
         displayer.show(repo[node])
+show_outgoing_to_svn = util.register_subcommand('outgoing')(show_outgoing_to_svn)