Title: [206283] trunk/Tools
- Revision
- 206283
- Author
- matthew_han...@apple.com
- Date
- 2016-09-22 18:14:59 -0700 (Thu, 22 Sep 2016)
Log Message
Add an API for getting the branch identifier from a Git or SVN checkout.
https://bugs.webkit.org/show_bug.cgi?id=151570
rdar://problem/17959831
Reviewed by David Kilzer.
This patch adds a function called svnIdentifierForPath. This function returns either "trunk",
the name of the tag, or the name of the branch, as appropriate. This function is necessary for
a VCSUtils client that is not checked in to the WebKit project.
This patch also breaks up pathRelativeToSVNRepositoryRootForPath into four functions:
- pathRelativeToSVNRepositoryRootForPath
- svnInfoForPath
- svnURLForPath
- svnRepositoryRootForPath
This allows us to reuse logic from pathRelativeToSVNRepositoryRootForPath in svnIdentifierForPath and
allows clients of VCSUtils to extract what arbitrary information from the `svn info` command regardless
of SCM.
* Scripts/VCSUtils.pm:
(svnInfoForPath):
Copied logic that previously lived in pathRelativeToSVNRepositoryRootForPath.
Make code safe to use for a path, and not just for the CWD.
(svnURLForPath):
Calls svnInfoForPath and extracts the URL.
(svnRepositoryRootForPath):
Calls svnInfoForPath and extracts the Repository Root.
(svnIdentifierForPath):
Calls pathRelativeToSVNRepositoryRootForPath and extracts the repository identifier.
(pathRelativeToSVNRepositoryRootForPath):
Now uses svnURLForPath and svnRepositoryRootForPath instead of being responsible for
determining both values.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (206282 => 206283)
--- trunk/Tools/ChangeLog 2016-09-22 23:53:33 UTC (rev 206282)
+++ trunk/Tools/ChangeLog 2016-09-23 01:14:59 UTC (rev 206283)
@@ -1,3 +1,43 @@
+2016-09-22 Matthew Hanson <matthew_han...@apple.com>
+
+ Add an API for getting the branch identifier from a Git or SVN checkout.
+ https://bugs.webkit.org/show_bug.cgi?id=151570
+ rdar://problem/17959831
+
+ Reviewed by David Kilzer.
+
+ This patch adds a function called svnIdentifierForPath. This function returns either "trunk",
+ the name of the tag, or the name of the branch, as appropriate. This function is necessary for
+ a VCSUtils client that is not checked in to the WebKit project.
+
+ This patch also breaks up pathRelativeToSVNRepositoryRootForPath into four functions:
+ - pathRelativeToSVNRepositoryRootForPath
+ - svnInfoForPath
+ - svnURLForPath
+ - svnRepositoryRootForPath
+
+ This allows us to reuse logic from pathRelativeToSVNRepositoryRootForPath in svnIdentifierForPath and
+ allows clients of VCSUtils to extract what arbitrary information from the `svn info` command regardless
+ of SCM.
+
+ * Scripts/VCSUtils.pm:
+ (svnInfoForPath):
+ Copied logic that previously lived in pathRelativeToSVNRepositoryRootForPath.
+ Make code safe to use for a path, and not just for the CWD.
+
+ (svnURLForPath):
+ Calls svnInfoForPath and extracts the URL.
+
+ (svnRepositoryRootForPath):
+ Calls svnInfoForPath and extracts the Repository Root.
+
+ (svnIdentifierForPath):
+ Calls pathRelativeToSVNRepositoryRootForPath and extracts the repository identifier.
+
+ (pathRelativeToSVNRepositoryRootForPath):
+ Now uses svnURLForPath and svnRepositoryRootForPath instead of being responsible for
+ determining both values.
+
2016-09-22 Megan Gardner <megan_gard...@apple.com>
Add long press selection test
Modified: trunk/Tools/Scripts/VCSUtils.pm (206282 => 206283)
--- trunk/Tools/Scripts/VCSUtils.pm 2016-09-22 23:53:33 UTC (rev 206282)
+++ trunk/Tools/Scripts/VCSUtils.pm 2016-09-23 01:14:59 UTC (rev 206283)
@@ -87,8 +87,12 @@
&scmMoveOrRenameFile
&scmToggleExecutableBit
&setChangeLogDateAndReviewer
+ &svnIdentifierForPath
+ &svnInfoForPath
+ &svnRepositoryRootForPath
&svnRevisionForDirectory
&svnStatus
+ &svnURLForPath
&toWindowsLineEndings
&gitCommitForSVNRevision
&listOfChangedFilesBetweenRevisions
@@ -444,33 +448,64 @@
return $revision;
}
-sub pathRelativeToSVNRepositoryRootForPath($)
+sub svnInfoForPath($)
{
my ($file) = @_;
my $relativePath = File::Spec->abs2rel($file);
my $svnInfo;
- if (isSVN()) {
+ if (isSVNDirectory($file)) {
my $escapedRelativePath = escapeSubversionPath($relativePath);
my $command = "svn info $escapedRelativePath";
$command = "LC_ALL=C $command" if !isWindows();
$svnInfo = `$command`;
- } elsif (isGit()) {
- my $command = "git svn info $relativePath";
+ } elsif (isGitDirectory($file)) {
+ my $command = "git svn info";
$command = "LC_ALL=C $command" if !isWindows();
- $svnInfo = `$command`;
+ $svnInfo = `cd $relativePath && $command`;
}
+ return $svnInfo;
+}
+
+sub svnURLForPath($)
+{
+ my ($file) = @_;
+ my $svnInfo = svnInfoForPath($file);
+
$svnInfo =~ /.*^URL: (.*?)$/m;
- my $svnURL = $1;
+ return $1;
+}
+sub svnRepositoryRootForPath($)
+{
+ my ($file) = @_;
+ my $svnInfo = svnInfoForPath($file);
+
$svnInfo =~ /.*^Repository Root: (.*?)$/m;
- my $repositoryRoot = $1;
+ return $1;
+}
- $svnURL =~ s/$repositoryRoot\///;
+sub pathRelativeToSVNRepositoryRootForPath($)
+{
+ my ($file) = @_;
+
+ my $svnURL = svnURLForPath($file);
+ my $svnRepositoryRoot = svnRepositoryRootForPath($file);
+
+ $svnURL =~ s/$svnRepositoryRoot\///;
return $svnURL;
}
+sub svnIdentifierForPath($)
+{
+ my ($file) = @_;
+ my $path = pathRelativeToSVNRepositoryRootForPath($file);
+
+ $path =~ /^(trunk)|tags\/([\w\.\-]*)|branches\/([\w\.\-]*).*$/m;
+ return $1 || $2 || $3;
+}
+
sub makeFilePathRelative($)
{
my ($path) = @_;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes