Commits

anatoly techtonik  committed c0e399f

limit the scope to the list of targets in given file (for pulling shallow checkouts)

  • Participants
  • Parent commits 441f272

Comments (0)

Files changed (2)

File hgsvn/run/hgpullsvn.py

         svn_branch = options.svn_branch
 
     if options.svn_peg:
-       wc_url += "@" + str(options.svn_peg)
+        wc_url += "@" + str(options.svn_peg)
+                          
+    if options.svn_targets:
+        svn_targets = options.svn_targets
+        if not os.path.exists(svn_targets):
+           ui.status("Targets file doesn't exist %s" % svn_targets, level=ui.ERROR)
+           return
 
     # Get remote SVN info
     ui.status("Retrieving remote SVN info...", level=ui.VERBOSE)
     # Show incoming changes if in dry-run mode.
     if options.dryrun:
         ui.status("Incoming SVN revisions:")
-        for entry in run_svn_log(wc_url, next_rev, svn_greatest_rev, 100):
+        for entry in run_svn_log(wc_url, next_rev, svn_greatest_rev, 100,
+                                 targets=svn_targets):
             if entry["message"]:
                 msg = entry["message"].splitlines()[0].strip()
             else:
         run_hg(["update", "-C", "svn.%d" % current_rev])
 
     # Load SVN log starting from current rev
-    it_log_entries = iter_svn_log_entries(wc_url, next_rev, svn_greatest_rev, options.svnretry)
+    it_log_entries = iter_svn_log_entries(wc_url, next_rev, svn_greatest_rev,
+                                          options.svnretry, targets=svn_targets)
 
     try:
         try:
                       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>)")
+        help="override branch name (defaults to last path component of <SVN URL>)")
+    parser.add_option("--targets", metavar="FILE", dest="svn_targets",
+        help="limit the scope to the list of targets in given file (useful for shallow checkouts)")
     parser.add_option("--svn-retry", dest="svnretry", default=False,
                       action="store_true",
                       help="retry SVN update command on failure")

File hgsvn/svnclient.py

     args += [svn_url, checkout_dir]
     return run_svn(svn_checkout_args + args)
 
-def run_svn_log(svn_url, rev_start, rev_end, limit, stop_on_copy=False):
+def run_svn_log(svn_url, rev_start, rev_end, limit, stop_on_copy=False, targets=None):
     """
     Fetch up to 'limit' SVN log entries between the given revisions.
     """
     else:
         args = []
     args += ['-r', '%s:%s' % (rev_start, rev_end), '--limit', limit, svn_url]
+    if targets:
+        args += ['--targets', targets]
     xml_string = run_svn(svn_log_args + args)
     return parse_svn_log_xml(xml_string)
 
 log_duration_threshold = 10.0
 log_min_chunk_length = 10
 
-def iter_svn_log_entries(svn_url, first_rev, last_rev, retry):
+def iter_svn_log_entries(svn_url, first_rev, last_rev, retry, targets=None):
     """
     Iterate over SVN log entries between first_rev and last_rev.
 
         stop_rev = min(last_rev, cur_rev + int(chunk_length * chunk_interval_factor))
         ui.status("Fetching SVN log for revisions %d-%d...", cur_rev, stop_rev,
                   level=ui.VERBOSE)
-        entries = once_or_more("Fetching SVN log", retry, run_svn_log, svn_url, cur_rev, stop_rev, chunk_length)
+        entries = once_or_more("Fetching SVN log", retry, run_svn_log, svn_url,
+                               cur_rev, stop_rev, chunk_length, targets=targets)
         duration = time.time() - start_t
         if not entries:
             if stop_rev == last_rev: