0

How can I use the pysvn.client merge related functions to achieve the cherry-pick merge,

merge specific revisions (or revision ranges) from one branch to another,

svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]

Now I'm use pysvn.Client.merge_peg2(http://pysvn.tigris.org/docs/pysvn_prog_ref.html#pysvn_client_merge_peg2), no warning and errors but cannot work.

I'm so confuse about the merge_peg2 and its parameters

    merge_peg2(sources,
    ranges_to_merge,
    peg_revision,
    tareget_wcpath,
    depth=depth,
    notice_ancestry=False,
    force=False,
    dry_run=False,
    record_only=True,
    merge_options=[] )

sources         # the source repo url which merge from?
ranges_to_merge #"a list of tuples with the start and end revisions to be merged"?how can I generate this revision range?
peg_revision    #pysvn.Revision(pysvn.opt_revision_kind.unspecified) is ok?
tareget_wcpath  #I fill this with the dest local repo

any suggestions, examples or other solution?

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
nullscu
  • 1
  • 1

1 Answers1

2

This is what I do to do cherry-pick merging. Sort the revisions you pick and iterate over this.

def merge_to_wc(r):
  WC_PATH = '.'
  FROM_URL = 'https:/svn.somewhere.org/my_project/branches/1.0'

  pysvn.merge_peg(
    FROM_URL,
    pysvn.Revision(pysvn.opt_revision_kind.number, r-1),
    pysvn.Revision(pysvn.opt_revision_kind.number, r),
    pysvn.Revision(pysvn.opt_revision_kind.head),
    WC_PATH)

This method found by trial and error, searching the internet, guesswork, and much gnashing of teeth.