示例#1
0
def svn_mkfile(path):
    "Make and add a file with some default content, and keyword expansion."
    path = local_path(path)
    dirname, filename = os.path.split(path)
    main.file_write(path, "This is the file '" + filename + "'.\n" + "Last changed in '$Revision$'.\n")
    actions.run_and_verify_svn(None, [], "add", path)
    actions.run_and_verify_svn(None, [], "propset", "svn:keywords", "Revision", path)
示例#2
0
def noninheritable_mergeinfo_test_set_up(sbox):
    """Starting with standard greek tree, copy 'A' to 'branch' in r2 and
  then made a file edit to A/B/lambda in r3.
  Return (expected_output, expected_mergeinfo_output, expected_elision_output,
          expected_status, expected_disk, expected_skip) for a merge of
  r3 from ^/A/B to branch/B."""

    sbox.build()
    wc_dir = sbox.wc_dir

    lambda_path = sbox.ospath("A/B/lambda")
    B_branch_path = sbox.ospath("branch/B")

    # r2 - Branch ^/A to ^/branch.
    main.run_svn(None, "copy", sbox.repo_url + "/A", sbox.repo_url + "/branch", "-m", "make a branch")

    # r3 - Make an edit to A/B/lambda.
    main.file_write(lambda_path, "trunk edit.\n")
    main.run_svn(None, "commit", "-m", "file edit", wc_dir)
    main.run_svn(None, "up", wc_dir)

    expected_output = wc.State(B_branch_path, {"lambda": Item(status="U ")})
    expected_mergeinfo_output = wc.State(B_branch_path, {"": Item(status=" U"), "lambda": Item(status=" U")})
    expected_elision_output = wc.State(B_branch_path, {"lambda": Item(status=" U")})
    expected_status = wc.State(
        B_branch_path,
        {
            "": Item(status=" M"),
            "lambda": Item(status="M "),
            "E": Item(status="  "),
            "E/alpha": Item(status="  "),
            "E/beta": Item(status="  "),
            "F": Item(status="  "),
        },
    )
    expected_status.tweak(wc_rev="3")
    expected_disk = wc.State(
        "",
        {
            "": Item(props={SVN_PROP_MERGEINFO: "/A/B:3"}),
            "lambda": Item("trunk edit.\n"),
            "E": Item(),
            "E/alpha": Item("This is the file 'alpha'.\n"),
            "E/beta": Item("This is the file 'beta'.\n"),
            "F": Item(),
        },
    )
    expected_skip = wc.State(B_branch_path, {})

    return (
        expected_output,
        expected_mergeinfo_output,
        expected_elision_output,
        expected_status,
        expected_disk,
        expected_skip,
    )
示例#3
0
def svn_mkfile(path):
  "Make and add a file with some default content, and keyword expansion."
  path = local_path(path)
  dirname, filename = os.path.split(path)
  main.file_write(path, "This is the file '" + filename + "'.\n" +
                                "Last changed in '$Revision$'.\n")
  actions.run_and_verify_svn(None, [], 'add', path)
  actions.run_and_verify_svn(None, [], 'propset',
                                     'svn:keywords', 'Revision', path)
示例#4
0
def noninheritable_mergeinfo_test_set_up(sbox):
    '''Starting with standard greek tree, copy 'A' to 'branch' in r2 and
  then made a file edit to A/B/lambda in r3.
  Return (expected_output, expected_mergeinfo_output, expected_elision_output,
          expected_status, expected_disk, expected_skip) for a merge of
  r3 from ^/A/B to branch/B.'''

    sbox.build()
    wc_dir = sbox.wc_dir

    lambda_path = sbox.ospath('A/B/lambda')
    B_branch_path = sbox.ospath('branch/B')

    # r2 - Branch ^/A to ^/branch.
    main.run_svn(None, 'copy', sbox.repo_url + '/A', sbox.repo_url + '/branch',
                 '-m', 'make a branch')

    # r3 - Make an edit to A/B/lambda.
    main.file_write(lambda_path, "trunk edit.\n")
    main.run_svn(None, 'commit', '-m', 'file edit', wc_dir)
    main.run_svn(None, 'up', wc_dir)

    expected_output = wc.State(B_branch_path, {
        'lambda': Item(status='U '),
    })
    expected_mergeinfo_output = wc.State(B_branch_path, {
        '': Item(status=' U'),
        'lambda': Item(status=' U'),
    })
    expected_elision_output = wc.State(B_branch_path, {
        'lambda': Item(status=' U'),
    })
    expected_status = wc.State(
        B_branch_path, {
            '': Item(status=' M'),
            'lambda': Item(status='M '),
            'E': Item(status='  '),
            'E/alpha': Item(status='  '),
            'E/beta': Item(status='  '),
            'F': Item(status='  '),
        })
    expected_status.tweak(wc_rev='3')
    expected_disk = wc.State(
        '', {
            '': Item(props={SVN_PROP_MERGEINFO: '/A/B:3'}),
            'lambda': Item("trunk edit.\n"),
            'E': Item(),
            'E/alpha': Item("This is the file 'alpha'.\n"),
            'E/beta': Item("This is the file 'beta'.\n"),
            'F': Item(),
        })
    expected_skip = wc.State(B_branch_path, {})

    return expected_output, expected_mergeinfo_output, expected_elision_output, \
      expected_status, expected_disk, expected_skip
示例#5
0
def noninheritable_mergeinfo_test_set_up(sbox):
  '''Starting with standard greek tree, copy 'A' to 'branch' in r2 and
  then made a file edit to A/B/lambda in r3.
  Return (expected_output, expected_mergeinfo_output, expected_elision_output,
          expected_status, expected_disk, expected_skip) for a merge of
  r3 from ^/A/B to branch/B.'''

  sbox.build()
  wc_dir = sbox.wc_dir

  lambda_path   = sbox.ospath('A/B/lambda')
  B_branch_path = sbox.ospath('branch/B')

  # r2 - Branch ^/A to ^/branch.
  main.run_svn(None, 'copy', sbox.repo_url + '/A',
                       sbox.repo_url + '/branch', '-m', 'make a branch')

  # r3 - Make an edit to A/B/lambda.
  main.file_write(lambda_path, "trunk edit.\n")
  main.run_svn(None, 'commit', '-m', 'file edit', wc_dir)
  main.run_svn(None, 'up', wc_dir)

  expected_output = wc.State(B_branch_path, {
    'lambda' : Item(status='U '),
    })
  expected_mergeinfo_output = wc.State(B_branch_path, {
    ''       : Item(status=' U'),
    'lambda' : Item(status=' U'),
    })
  expected_elision_output = wc.State(B_branch_path, {
    'lambda' : Item(status=' U'),
    })
  expected_status = wc.State(B_branch_path, {
    ''        : Item(status=' M'),
    'lambda'  : Item(status='M '),
    'E'       : Item(status='  '),
    'E/alpha' : Item(status='  '),
    'E/beta'  : Item(status='  '),
    'F'       : Item(status='  '),
    })
  expected_status.tweak(wc_rev='3')
  expected_disk = wc.State('', {
    ''          : Item(props={SVN_PROP_MERGEINFO : '/A/B:3'}),
    'lambda'  : Item("trunk edit.\n"),
    'E'       : Item(),
    'E/alpha' : Item("This is the file 'alpha'.\n"),
    'E/beta'  : Item("This is the file 'beta'.\n"),
    'F'       : Item(),
    })
  expected_skip = wc.State(B_branch_path, {})

  return expected_output, expected_mergeinfo_output, expected_elision_output, \
    expected_status, expected_disk, expected_skip
示例#6
0
def set_up_branch(sbox, branch_only = False, nbr_of_branches = 1):
  '''Starting with standard greek tree, copy 'A' NBR_OF_BRANCHES times
  to A_COPY, A_COPY_2, A_COPY_3, and so on.  Then, unless BRANCH_ONLY is
  true, make four modifications (setting file contents to "New content")
  under A:
    r(2 + NBR_OF_BRANCHES) - A/D/H/psi
    r(3 + NBR_OF_BRANCHES) - A/D/G/rho
    r(4 + NBR_OF_BRANCHES) - A/B/E/beta
    r(5 + NBR_OF_BRANCHES) - A/D/H/omega
  Return (expected_disk, expected_status).'''

  # With the default parameters, the branching looks like this:
  #
  #   A         -1-----3-4-5-6--
  #                \
  #   A_COPY        2-----------

  wc_dir = sbox.wc_dir

  expected_status = actions.get_virginal_state(wc_dir, 1)
  expected_disk = main.greek_state.copy()

  def copy_A(dest_name, rev):
    expected = verify.UnorderedOutput(
      ["A    " + os.path.join(wc_dir, dest_name, "B") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "B", "lambda") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "B", "E") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "B", "E", "alpha") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "B", "E", "beta") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "B", "F") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "mu") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "C") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "gamma") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "G") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "G", "pi") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "G", "rho") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "G", "tau") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "H") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "H", "chi") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "H", "omega") + "\n",
       "A    " + os.path.join(wc_dir, dest_name, "D", "H", "psi") + "\n",
       "Checked out revision " + str(rev - 1) + ".\n",
       "A         " + os.path.join(wc_dir, dest_name) + "\n"])
    expected_status.add({
      dest_name + "/B"         : Item(status='  ', wc_rev=rev),
      dest_name + "/B/lambda"  : Item(status='  ', wc_rev=rev),
      dest_name + "/B/E"       : Item(status='  ', wc_rev=rev),
      dest_name + "/B/E/alpha" : Item(status='  ', wc_rev=rev),
      dest_name + "/B/E/beta"  : Item(status='  ', wc_rev=rev),
      dest_name + "/B/F"       : Item(status='  ', wc_rev=rev),
      dest_name + "/mu"        : Item(status='  ', wc_rev=rev),
      dest_name + "/C"         : Item(status='  ', wc_rev=rev),
      dest_name + "/D"         : Item(status='  ', wc_rev=rev),
      dest_name + "/D/gamma"   : Item(status='  ', wc_rev=rev),
      dest_name + "/D/G"       : Item(status='  ', wc_rev=rev),
      dest_name + "/D/G/pi"    : Item(status='  ', wc_rev=rev),
      dest_name + "/D/G/rho"   : Item(status='  ', wc_rev=rev),
      dest_name + "/D/G/tau"   : Item(status='  ', wc_rev=rev),
      dest_name + "/D/H"       : Item(status='  ', wc_rev=rev),
      dest_name + "/D/H/chi"   : Item(status='  ', wc_rev=rev),
      dest_name + "/D/H/omega" : Item(status='  ', wc_rev=rev),
      dest_name + "/D/H/psi"   : Item(status='  ', wc_rev=rev),
      dest_name                : Item(status='  ', wc_rev=rev)})
    expected_disk.add({
      dest_name                : Item(),
      dest_name + '/B'         : Item(),
      dest_name + '/B/lambda'  : Item("This is the file 'lambda'.\n"),
      dest_name + '/B/E'       : Item(),
      dest_name + '/B/E/alpha' : Item("This is the file 'alpha'.\n"),
      dest_name + '/B/E/beta'  : Item("This is the file 'beta'.\n"),
      dest_name + '/B/F'       : Item(),
      dest_name + '/mu'        : Item("This is the file 'mu'.\n"),
      dest_name + '/C'         : Item(),
      dest_name + '/D'         : Item(),
      dest_name + '/D/gamma'   : Item("This is the file 'gamma'.\n"),
      dest_name + '/D/G'       : Item(),
      dest_name + '/D/G/pi'    : Item("This is the file 'pi'.\n"),
      dest_name + '/D/G/rho'   : Item("This is the file 'rho'.\n"),
      dest_name + '/D/G/tau'   : Item("This is the file 'tau'.\n"),
      dest_name + '/D/H'       : Item(),
      dest_name + '/D/H/chi'   : Item("This is the file 'chi'.\n"),
      dest_name + '/D/H/omega' : Item("This is the file 'omega'.\n"),
      dest_name + '/D/H/psi'   : Item("This is the file 'psi'.\n"),
      })

    # Make a branch A_COPY to merge into.
    actions.run_and_verify_svn(None, expected, [], 'copy',
                                       sbox.repo_url + "/A",
                                       os.path.join(wc_dir,
                                                    dest_name))

    expected_output = wc.State(wc_dir, {dest_name : Item(verb='Adding')})
    actions.run_and_verify_commit(wc_dir,
                                          expected_output,
                                          expected_status,
                                          None,
                                          wc_dir)
  for i in range(nbr_of_branches):
    if i == 0:
      copy_A('A_COPY', i + 2)
    else:
      copy_A('A_COPY_' + str(i + 1), i + 2)

  if branch_only:
    return expected_disk, expected_status

  # Make some changes under A which we'll later merge under A_COPY:

  # r(nbr_of_branches + 2) - modify and commit A/D/H/psi
  main.file_write(sbox.ospath('A/D/H/psi'),
                          "New content")
  expected_output = wc.State(wc_dir, {'A/D/H/psi' : Item(verb='Sending')})
  expected_status.tweak('A/D/H/psi', wc_rev=nbr_of_branches + 2)
  actions.run_and_verify_commit(wc_dir, expected_output,
                                        expected_status, None, wc_dir)
  expected_disk.tweak('A/D/H/psi', contents="New content")

  # r(nbr_of_branches + 3) - modify and commit A/D/G/rho
  main.file_write(sbox.ospath('A/D/G/rho'),
                          "New content")
  expected_output = wc.State(wc_dir, {'A/D/G/rho' : Item(verb='Sending')})
  expected_status.tweak('A/D/G/rho', wc_rev=nbr_of_branches + 3)
  actions.run_and_verify_commit(wc_dir, expected_output,
                                        expected_status, None, wc_dir)
  expected_disk.tweak('A/D/G/rho', contents="New content")

  # r(nbr_of_branches + 4) - modify and commit A/B/E/beta
  main.file_write(sbox.ospath('A/B/E/beta'),
                          "New content")
  expected_output = wc.State(wc_dir, {'A/B/E/beta' : Item(verb='Sending')})
  expected_status.tweak('A/B/E/beta', wc_rev=nbr_of_branches + 4)
  actions.run_and_verify_commit(wc_dir, expected_output,
                                        expected_status, None, wc_dir)
  expected_disk.tweak('A/B/E/beta', contents="New content")

  # r(nbr_of_branches + 5) - modify and commit A/D/H/omega
  main.file_write(sbox.ospath('A/D/H/omega'),
                          "New content")
  expected_output = wc.State(wc_dir, {'A/D/H/omega' : Item(verb='Sending')})
  expected_status.tweak('A/D/H/omega', wc_rev=nbr_of_branches + 5)
  actions.run_and_verify_commit(wc_dir, expected_output,
                                        expected_status, None, wc_dir)
  expected_disk.tweak('A/D/H/omega', contents="New content")

  return expected_disk, expected_status
示例#7
0
def set_up_branch(sbox, branch_only=False, nbr_of_branches=1):
    '''Starting with standard greek tree, copy 'A' NBR_OF_BRANCHES times
  to A_COPY, A_COPY_2, A_COPY_3, and so on.  Then, unless BRANCH_ONLY is
  true, make four modifications (setting file contents to "New content")
  under A:
    r(2 + NBR_OF_BRANCHES) - A/D/H/psi
    r(3 + NBR_OF_BRANCHES) - A/D/G/rho
    r(4 + NBR_OF_BRANCHES) - A/B/E/beta
    r(5 + NBR_OF_BRANCHES) - A/D/H/omega
  Return (expected_disk, expected_status).'''

    # With the default parameters, the branching looks like this:
    #
    #   A         -1-----3-4-5-6--
    #                \
    #   A_COPY        2-----------

    wc_dir = sbox.wc_dir

    expected_status = actions.get_virginal_state(wc_dir, 1)
    expected_disk = main.greek_state.copy()

    def copy_A(dest_name, rev):
        expected = verify.UnorderedOutput([
            "A    " + os.path.join(wc_dir, dest_name, "B") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "B", "lambda") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "B", "E") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "B", "E", "alpha") +
            "\n", "A    " + os.path.join(wc_dir, dest_name, "B", "E", "beta") +
            "\n", "A    " + os.path.join(wc_dir, dest_name, "B", "F") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "mu") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "C") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D", "gamma") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D", "G") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D", "G", "pi") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D", "G", "rho") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D", "G", "tau") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D", "H") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D", "H", "chi") + "\n",
            "A    " + os.path.join(wc_dir, dest_name, "D", "H", "omega") +
            "\n", "A    " + os.path.join(wc_dir, dest_name, "D", "H", "psi") +
            "\n", "Checked out revision " + str(rev - 1) + ".\n",
            "A         " + os.path.join(wc_dir, dest_name) + "\n"
        ])
        expected_status.add({
            dest_name + "/B":
            Item(status='  ', wc_rev=rev),
            dest_name + "/B/lambda":
            Item(status='  ', wc_rev=rev),
            dest_name + "/B/E":
            Item(status='  ', wc_rev=rev),
            dest_name + "/B/E/alpha":
            Item(status='  ', wc_rev=rev),
            dest_name + "/B/E/beta":
            Item(status='  ', wc_rev=rev),
            dest_name + "/B/F":
            Item(status='  ', wc_rev=rev),
            dest_name + "/mu":
            Item(status='  ', wc_rev=rev),
            dest_name + "/C":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/gamma":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/G":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/G/pi":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/G/rho":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/G/tau":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/H":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/H/chi":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/H/omega":
            Item(status='  ', wc_rev=rev),
            dest_name + "/D/H/psi":
            Item(status='  ', wc_rev=rev),
            dest_name:
            Item(status='  ', wc_rev=rev)
        })
        expected_disk.add({
            dest_name:
            Item(),
            dest_name + '/B':
            Item(),
            dest_name + '/B/lambda':
            Item("This is the file 'lambda'.\n"),
            dest_name + '/B/E':
            Item(),
            dest_name + '/B/E/alpha':
            Item("This is the file 'alpha'.\n"),
            dest_name + '/B/E/beta':
            Item("This is the file 'beta'.\n"),
            dest_name + '/B/F':
            Item(),
            dest_name + '/mu':
            Item("This is the file 'mu'.\n"),
            dest_name + '/C':
            Item(),
            dest_name + '/D':
            Item(),
            dest_name + '/D/gamma':
            Item("This is the file 'gamma'.\n"),
            dest_name + '/D/G':
            Item(),
            dest_name + '/D/G/pi':
            Item("This is the file 'pi'.\n"),
            dest_name + '/D/G/rho':
            Item("This is the file 'rho'.\n"),
            dest_name + '/D/G/tau':
            Item("This is the file 'tau'.\n"),
            dest_name + '/D/H':
            Item(),
            dest_name + '/D/H/chi':
            Item("This is the file 'chi'.\n"),
            dest_name + '/D/H/omega':
            Item("This is the file 'omega'.\n"),
            dest_name + '/D/H/psi':
            Item("This is the file 'psi'.\n"),
        })

        # Make a branch A_COPY to merge into.
        actions.run_and_verify_svn(None, expected, [], 'copy',
                                   sbox.repo_url + "/A",
                                   os.path.join(wc_dir, dest_name))

        expected_output = wc.State(wc_dir, {dest_name: Item(verb='Adding')})
        actions.run_and_verify_commit(wc_dir, expected_output, expected_status,
                                      None, wc_dir)

    for i in range(nbr_of_branches):
        if i == 0:
            copy_A('A_COPY', i + 2)
        else:
            copy_A('A_COPY_' + str(i + 1), i + 2)

    if branch_only:
        return expected_disk, expected_status

    # Make some changes under A which we'll later merge under A_COPY:

    # r(nbr_of_branches + 2) - modify and commit A/D/H/psi
    main.file_write(sbox.ospath('A/D/H/psi'), "New content")
    expected_output = wc.State(wc_dir, {'A/D/H/psi': Item(verb='Sending')})
    expected_status.tweak('A/D/H/psi', wc_rev=nbr_of_branches + 2)
    actions.run_and_verify_commit(wc_dir, expected_output, expected_status,
                                  None, wc_dir)
    expected_disk.tweak('A/D/H/psi', contents="New content")

    # r(nbr_of_branches + 3) - modify and commit A/D/G/rho
    main.file_write(sbox.ospath('A/D/G/rho'), "New content")
    expected_output = wc.State(wc_dir, {'A/D/G/rho': Item(verb='Sending')})
    expected_status.tweak('A/D/G/rho', wc_rev=nbr_of_branches + 3)
    actions.run_and_verify_commit(wc_dir, expected_output, expected_status,
                                  None, wc_dir)
    expected_disk.tweak('A/D/G/rho', contents="New content")

    # r(nbr_of_branches + 4) - modify and commit A/B/E/beta
    main.file_write(sbox.ospath('A/B/E/beta'), "New content")
    expected_output = wc.State(wc_dir, {'A/B/E/beta': Item(verb='Sending')})
    expected_status.tweak('A/B/E/beta', wc_rev=nbr_of_branches + 4)
    actions.run_and_verify_commit(wc_dir, expected_output, expected_status,
                                  None, wc_dir)
    expected_disk.tweak('A/B/E/beta', contents="New content")

    # r(nbr_of_branches + 5) - modify and commit A/D/H/omega
    main.file_write(sbox.ospath('A/D/H/omega'), "New content")
    expected_output = wc.State(wc_dir, {'A/D/H/omega': Item(verb='Sending')})
    expected_status.tweak('A/D/H/omega', wc_rev=nbr_of_branches + 5)
    actions.run_and_verify_commit(wc_dir, expected_output, expected_status,
                                  None, wc_dir)
    expected_disk.tweak('A/D/H/omega', contents="New content")

    return expected_disk, expected_status