Commits

stef...@intel.com  committed 6ba6a1f Merge

Merge with current tip.

  • Participants
  • Parent commits 009c38c, 1e09be7

Comments (0)

Files changed (9)

 
 To read the documentation, either type `pydoc hgsvn`,
 or go to the following Web page:
-http://cheeseshop.python.org/pypi/hgsvn
+http://pypi.python.org/pypi/hgsvn

File hgsvn/__init__.py

 Install
 -------
 
-Just type ``easy_install hgsvn``. If easy_install is not available on your
-computer, download and uncompress the source tarball, then type ``python
-setup.py install``.
+Just type ``easy_install hgsvn``. If easy_install is not available on
+your computer, download and uncompress the source tarball, then type
+``python setup.py install``. Type ``python setup.py install --help``
+for additional options.
 
 *Note:* hgsvn makes use of the ElementTree library. It is bundled by default
 with Python 2.5, and the setup script should install it automatically for you
 History
 -------
 
+Development
+-----------
+
+Improvements:
+
+* ``hgimportsvn --branch=myname`` imports the SVN repository to a
+  named Mercurial branch other than 'default' (patch by Matthias
+  Benkmann).
+
+
 hgsvn 0.1.8
 -----------
 

File hgsvn/common.py

 
 locale_encoding = locale.getpreferredencoding()
 
+def get_encoding():
+    return locale_encoding
+
 def shell_quote(s):
     if os.name == "nt":
         q = '"'

File hgsvn/run/hgimportsvn.py

         default=True, help="Don't autogenerate .hgignore")
     parser.add_option("--local-only", action="store_true", default=False,
         help="Don't use the server, just build from a local checkout")
+    parser.add_option("--branch", type="string", dest="svn_branch",
+        help="Override branch name (defaults to last path component of <SVN URL>)")
     (options, args) = run_parser(parser, __doc__)
     if not 1 <= len(args) <= 2:
         display_parser_error(parser, "incorrect number of arguments")
     svn_path = actual_svn_url[len(repos_url):]
     # e.g. 'xmpp-subprotocols-2178-2'
     svn_branch = actual_svn_url.split("/")[-1]
+
+    # if --branch was passed, override the branch name derived above
+    if options.svn_branch:
+        svn_branch = options.svn_branch
+
     svn_greatest_rev = svn_info['last_changed_rev']
     if options.svn_peg:
        actual_svn_url += "@" + str(options.svn_peg)
 
     if not local_repo:
-        local_repo = svn_branch
+        local_repo = actual_svn_url.split("/")[-1]
     if os.path.exists(local_repo):
         if not os.path.isdir(local_repo):
             raise ValueError("%s is not a directory" % local_repo)

File hgsvn/run/hgpullsvn.py

 def real_main(options, args):
     if check_for_applied_patches():
         print ("There are applied mq patches. Put them aside before "
-               "running hgpsuhsvn.")
+               "running hgpullsvn.")
         return 1
     svn_wc = "."
     svn_peg_wc = svn_wc
     wc_base = wc_url[len(repos_url):]
     # e.g. 'xmpp-subprotocols-2178-2'
     svn_branch = wc_url.split("/")[-1]
+
+    # if --branch was passed, override the branch name derived above
+    if options.svn_branch:
+        svn_branch = options.svn_branch
+
     if options.svn_peg:
        wc_url += "@" + str(options.svn_peg)
 
         ui.status("No revisions after %s in SVN repo, nothing to do",
                   svn_greatest_rev)
         return
+    elif options.svn_rev != None:
+        if options.svn_rev < next_rev:
+            ui.status("All revisions up to %s are already pulled in, "
+                      "nothing to do",
+                      options.svn_rev)
+            return
+        svn_greatest_rev = options.svn_rev
 
     # Show incoming changes if in dry-run mode.
     if options.dryrun:
         ui.status("Incoming SVN revisions:")
-        for entry in run_svn_log(repos_url, next_rev, svn_greatest_rev,
-                                 100):
+        for entry in run_svn_log(svn_peg_wc, next_rev, svn_greatest_rev, 100):
             if entry["message"]:
                 msg = entry["message"].splitlines()[0].strip()
             else:
                 msg = ""
             line = "[%d] %s (%s)" % (entry["revision"], msg, entry["author"])
-            # TODO: Line stripping should be done by some simple UI interface.
-            if len(line) > 79:
-                line = line[:77]+"..."
             ui.status(line)
         return
 
 
 def main():
     # Defined as entry point. Must be callable without arguments.
-    usage = "usage: %prog [-p SVN peg rev] [--help]"
+    usage = "usage: %prog [-p SVN_PEG] [--help]"
     parser = OptionParser(usage)
+    parser.add_option("-r", type="int", dest="svn_rev",
+       help="limit pull up to specified revision")
     parser.add_option("-p", "--svn-peg", type="int", dest="svn_peg",
        help="SVN peg revision to locate checkout URL")
     parser.add_option("-n", "--dry-run", dest="dryrun", default=False,
                       action="store_true",
                       help="show incoming changesets without pulling them")
+    parser.add_option("--branch", type="string", dest="svn_branch",
+        help="Override branch name (defaults to last path component of <SVN URL>)")
     parser.add_option("--svn-retry", dest="svnretry", default=False,
                       action="store_true",
                       help="retry SVN update command on failure")

File hgsvn/run/hgpushsvn.py

 from hgsvn import ui
 from hgsvn.common import (
     run_hg, run_svn, hg_switch_branch, hgsvn_private_dir,
-    check_for_applied_patches,
+    check_for_applied_patches, get_encoding
     )
 from hgsvn.errors import ExternalCommandFailed, EmptySVNLog
 from hgsvn.run.common import run_parser, display_parser_error
             old_lc_all = os.getenv('LC_ALL')
             os.environ['LC_ALL'] = 'C'
             try:
-                out = run_svn(["commit", "-F", fname])
+                out = run_svn(["commit", "-F", fname, "--encoding",
+                               get_encoding()])
             finally:
                 if old_lc_all:
                     os.environ['LC_ALL'] = old_lc_all
         return 1
     if check_for_applied_patches():
         print ("There are applied mq patches. Put them aside before "
-               "running hgpsuhsvn.")
+               "running hgpushsvn.")
         return 1
     svn_info = get_svn_info(".")
     svn_current_rev = svn_info["last_changed_rev"]

File hgsvn/svnclient.py

         l.append(d)
     return l
 
-def parse_svn_status_xml(xml_string, base_dir=None):
+def parse_svn_status_xml(xml_string, base_dir=None, ignore_externals=False):
     """
     Parse the XML output from an "svn status" command and extract useful info
     as a list of dicts (one per status entry).
         d['path'] = path
         wc_status = entry.find('wc-status')
         if wc_status.get('item') == 'external':
+            if ignore_externals:
+                continue
             d['type'] = 'external'
         elif wc_status.get('revision') is not None:
             d['type'] = 'normal'
     else:
         args += ['-v']
     xml_string = run_svn(svn_status_args + args)
-    return parse_svn_status_xml(xml_string, svn_wc)
+    return parse_svn_status_xml(xml_string, svn_wc, ignore_externals=True)
 
 def get_svn_versioned_files(svn_wc):
     """
     The following keyword arguments are allowed:
       level    : One of DEFAULT, VERBOSE or DEBUG.
       linebreak: If True a new line is appended to msg (default: True).
-      trunkate : Trunkate output if larger then term width (default: True).
+      truncate : Truncate output if larger then term width (default: True).
     """
     global _level
     level = kwargs.get('level', DEFAULT)
         stream = sys.stderr
     else:
         stream = sys.stdout
-    if kwargs.get('trunkate', True) and level != ERROR:
+    if kwargs.get('truncate', True) and level != ERROR:
         add_newline = msg.endswith('\n')
-        msg = os.linesep.join(x[:width] for x in msg.splitlines())
+        msglines = msg.splitlines()
+        for no, line in enumerate(msglines):
+            if len(line) > width:
+                msglines[no] = line[:width-3]+"..."
+        msg = os.linesep.join(msglines)
         if add_newline:
             msg = '%s%s' % (msg, os.linesep)
     if isinstance(msg, unicode):
 extra_cmds = {}
 try:
     import py2exe
+    import sys
+
+    # ModuleFinder can't handle runtime changes to __path__, but win32com uses
+    # them, particularly for people who build from sources.  Hook this in.
+    import modulefinder
+    import win32com
+    for p in win32com.__path__[1:]:
+        modulefinder.AddPackagePath("win32com", p)
+    __import__("win32com.shell")
+    m = sys.modules["win32com.shell"]
+    for p in m.__path__[1:]:
+        modulefinder.AddPackagePath("win32com.shell", p)
+
     extra_cmds['console'] = ["hgimportsvn.py", "hgpullsvn.py",
                              "hgpushsvn.py"]
+    extra_cmds['zipfile'] = "hgsvnlib.zip"
 except ImportError:
     pass
 
     ),
     long_description = long_description,
     license = 'GNU GPL',
-    homepage = 'http://bitbucket.org/andialbrecht/hgsvn',
+    url = 'http://bitbucket.org/andialbrecht/hgsvn',
 
     # *Next* version, not previous!
     version = base_version,
         'Programming Language :: Python',
         'Topic :: Software Development :: Version Control',
     ],
+    options=dict(py2exe=dict(bundle_files=1)),
     **extra_cmds
 )