Skip to content

Commit

Permalink
Add explicit file rename/cp information to svn rietveld uploads
Browse files Browse the repository at this point in the history
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
  • Loading branch information
[email protected] committed Jun 29, 2010
1 parent d36fba8 commit 3fda4cc
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ def RelativePath(path, root):
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():
Expand All @@ -811,8 +812,32 @@ def RelativePath(path, root):
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,
Expand Down

0 comments on commit 3fda4cc

Please sign in to comment.