Add explicit file rename/cp information to svn rietveld uploads

Right now if you svn cp or svn mv before uploading to rietveld,
there's no description in the patch at all of what was done; so you
get a diff, but it's for who knows what revision of what prior file
to some current version.

For code reviews this kinda works (you ask the guy what it was), but for
trying to apply patches (ala git patch) this fails badly.  This patch
tries to add some metadata to the start of a rietveld patch that
describes these changes: both to a human (who can read them)
and to a potential clever future git-cl (which I'll do next).

The metadata looks like this after checking out a test repo, and
svn cp -r 1 foo nitz; svn cp bar quux; echo be good>>quux

  ### BEGIN SVN COPY METADATA
  #$ svn cp -r 1 foo nitz ### WARNING: note non-trunk copy
  #$ cp bar quux
  ### END SVN COPY METADATA
  Index: nitz
  Index: quux
  ===================================================================
  --- quux	(revision 0)
  +++ quux	(working copy)
  @@ -1,2 +1,3 @@
   hi mom
   hi sister
  +be good

I did a test, and this looks like it works in svn 1.4.4 as well.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2824035

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@51121 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
gavinp@google.com 15 years ago
parent d36fba8100
commit 3fda4ccee3

@ -800,6 +800,7 @@ class SVN(object):
filenames = [RelativePath(f, root) for f in filenames]
# Get information about the modified items (files and directories)
data = dict([(f, SVN.CaptureInfo(f)) for f in filenames])
diffs = []
if full_move:
# Eliminate modified files inside moved/copied directory.
for (filename, info) in data.iteritems():
@ -811,8 +812,32 @@ class SVN(object):
if not filename in filenames:
# Remove filtered out items.
del data[filename]
else:
metaheaders = []
for (filename, info) in data.iteritems():
if SVN.IsMovedInfo(info):
# for now, the most common case is a head copy,
# so let's just encode that as a straight up cp.
srcurl = info.get('Copied From URL')
root = info.get('Repository Root')
rev = int(info.get('Copied From Rev'))
assert srcurl.startswith(root)
src = srcurl[len(root)+1:]
srcinfo = SVN.CaptureInfo(srcurl)
if (srcinfo.get('Revision') != rev and
SVN.Capture(['diff', '-r', '%d:head' % rev, srcurl])):
metaheaders.append("#$ svn cp -r %d %s %s "
"### WARNING: note non-trunk copy\n" %
(rev, src, filename))
else:
metaheaders.append("#$ cp %s %s\n" % (src,
filename))
if metaheaders:
diffs.append("### BEGIN SVN COPY METADATA\n")
diffs.extend(metaheaders)
diffs.append("### END SVN COPY METADATA\n")
# Now ready to do the actual diff.
diffs = []
for filename in sorted(data.iterkeys()):
diffs.append(SVN._DiffItemInternal(filename, data[filename], bogus_dir,
full_move=full_move,

Loading…
Cancel
Save