[Svnmerge] Re: svn commit: r19116 - trunk/contrib/client-side

Daniel Rall dlr at collab.net
Mon Apr 3 11:15:15 PDT 2006


This commit did a lot for improving the encapsulation and
comprehensibility of the related code, +1.  However, it also
introduced a (fairly innocuous) bi-directional dependency between the
RevisionLog and VersionedProperty class.  Previously, the dependency
was from VersionedProperty to RevisionLog.  David and I discussed
this, and he's looking into making the dependency one-way again,
possibly by parameterizing VersionedProperty.load() to accept
RevisionLog's propchange_revs and revs members.

 - Dan

On Fri, 31 Mar 2006, djames at tigris.org wrote:

> Author: djames
> Date: Fri Mar 31 14:00:03 2006
> New Revision: 19116
> 
> Modified:
>    trunk/contrib/client-side/svnmerge.py
> 
> Log:
> Simplify usage of the RevisionLog class by adding a new 'merge_metadata'
> method to track merges. Remove 'mergeprops' global variable and update
> associated functions to use the new 'merge_metadata' method instead.
> 
> * client-side/svnmerge.py
>   (mergeprops): Remove global variable.
>   (RevisionLog.url): New instance variable, used by new merge_metadata method.
>   (RevisionLog.merge_metadata): New method.
>   (analyze_revs, action_merge): Use RevisionLog.merge_metadata.
> 
> 
> 
> Modified: trunk/contrib/client-side/svnmerge.py
> URL: http://svn.collab.net/viewvc/svn/trunk/contrib/client-side/svnmerge.py?pathrev=19116&r1=19115&r2=19116
> ==============================================================================
> --- trunk/contrib/client-side/svnmerge.py	(original)
> +++ trunk/contrib/client-side/svnmerge.py	Fri Mar 31 14:00:03 2006
> @@ -142,7 +142,6 @@
>      "commit-verbose": True,
>  }
>  logs = {}
> -mergeprops = {}
>  
>  def console_width():
>      """Get the width of the console screen (if any)."""
> @@ -277,6 +276,9 @@
>          specified URL. URL must be the URL for a directory in the repository.
>          """
>  
> +        # Save the specified URL
> +        self.url = url
> +
>          # Look for revisions
>          revision_re = re.compile(r"^r(\d+)")
>  
> @@ -302,6 +304,22 @@
>              elif srcdir_change_re.match(line):
>                  self.propchange_revs.append(rev)
>  
> +        self._merges = None
> +
> +    def merge_metadata(self):
> +        """
> +        Return a VersionedProperty object, with a cached view of the merge
> +        metadata in the range of this log.
> +        """
> +
> +        # Load merge metadata if necessary
> +        if not self._merges:
> +            self._merges = VersionedProperty(self.url, opts["prop"])
> +            self._merges.load(self)
> +
> +        return self._merges
> +
> +
>  class VersionedProperty:
>      """
>      A read-only, cached view of a versioned property.
> @@ -796,8 +814,6 @@
>              return RevisionSet(""), RevisionSet(""), RevisionSet("")
>  
>      logs[url] = RevisionLog(url, begin, end, find_reflected)
> -    mergeprops[url] = VersionedProperty(url, opts["prop"])
> -    mergeprops[url].load(logs[url])
>      revs = RevisionSet(logs[url].revs)
>  
>      if end == "HEAD":
> @@ -810,14 +826,14 @@
>      reflected_revs = []
>  
>      if find_reflected:
> -        mergeinfo = mergeprops[url]
> +        merge_metadata = logs[url].merge_metadata()
>  
>          report("checking for reflected changes in %d revision(s)"
> -               % len(mergeinfo.keys()))
> +               % len(merge_metadata.keys()))
>  
>          old_revs = None
> -        for rev in mergeinfo.keys():
> -            new_revs = mergeinfo.get(rev).get(target_dir)
> +        for rev in merge_metadata.keys():
> +            new_revs = merge_metadata.get(rev).get(target_dir)
>              if new_revs != old_revs:
>                  reflected_revs.append("%s" % rev)
>              old_revs = new_revs
> @@ -1045,11 +1061,12 @@
>      # We try to keep the number of merge operations as low as possible,
>      # because it is faster and reduces the number of conflicts.
>      old_merge_props = branch_props
> +    merge_metadata = logs[opts["head-url"]].merge_metadata()
>      for start,end in minimal_merge_intervals(revs, phantom_revs):
>  
>          # Set merge props appropriately if bidirectional support is enabled
>          if opts["bidirectional"]:
> -          new_merge_props = mergeprops[opts["head-url"]].get(start-1)
> +          new_merge_props = merge_metadata.get(start-1)
>            if new_merge_props != old_merge_props:
>                set_merge_props(branch_dir, new_merge_props)
>                old_merge_props = new_merge_props
> @@ -1603,7 +1620,6 @@
>      # Initialize default options
>      opts = default_opts.copy()
>      logs.clear()
> -    mergeprops.clear()
>  
>      optsparser = CommandOpts(global_opts, common_opts, command_table,
>                               version="%%prog r%s\n  modified: %s\n\n"
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: svn-unsubscribe at subversion.tigris.org
> For additional commands, e-mail: svn-help at subversion.tigris.org

-- 

Daniel Rall
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : /pipermail/svnmerge/attachments/20060403/15c0e273/attachment.pgp 


More information about the Svnmerge mailing list