proxygen
upload.SubversionVCS Class Reference
Inheritance diagram for upload.SubversionVCS:
upload.VersionControlSystem upload.VersionControlSystem upload.VersionControlSystem upload.VersionControlSystem upload.VersionControlSystem upload.VersionControlSystem

Public Member Functions

def __init__ (self, options)
 
def GuessBase (self, required)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def ReadFile (self, filename)
 
def GetStatus (self, filename)
 
def GetBaseFile (self, filename)
 
def __init__ (self, options)
 
def GuessBase (self, required)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def ReadFile (self, filename)
 
def GetStatus (self, filename)
 
def GetBaseFile (self, filename)
 
def __init__ (self, options)
 
def GuessBase (self, required)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def ReadFile (self, filename)
 
def GetStatus (self, filename)
 
def GetBaseFile (self, filename)
 
def __init__ (self, options)
 
def GuessBase (self, required)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def ReadFile (self, filename)
 
def GetStatus (self, filename)
 
def GetBaseFile (self, filename)
 
def __init__ (self, options)
 
def GuessBase (self, required)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def ReadFile (self, filename)
 
def GetStatus (self, filename)
 
def GetBaseFile (self, filename)
 
def __init__ (self, options)
 
def GuessBase (self, required)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def ReadFile (self, filename)
 
def GetStatus (self, filename)
 
def GetBaseFile (self, filename)
 
- Public Member Functions inherited from upload.VersionControlSystem
def __init__ (self, options)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def CheckForUnknownFiles (self)
 
def GetBaseFile (self, filename)
 
def GetBaseFiles (self, diff)
 
def UploadBaseFiles (self, issue, rpc_server, patch_list, patchset, options, files)
 
def IsImage (self, filename)
 
def __init__ (self, options)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def CheckForUnknownFiles (self)
 
def GetBaseFile (self, filename)
 
def GetBaseFiles (self, diff)
 
def UploadBaseFiles (self, issue, rpc_server, patch_list, patchset, options, files)
 
def IsImage (self, filename)
 
def __init__ (self, options)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def CheckForUnknownFiles (self)
 
def GetBaseFile (self, filename)
 
def GetBaseFiles (self, diff)
 
def UploadBaseFiles (self, issue, rpc_server, patch_list, patchset, options, files)
 
def IsImage (self, filename)
 
def __init__ (self, options)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def CheckForUnknownFiles (self)
 
def GetBaseFile (self, filename)
 
def GetBaseFiles (self, diff)
 
def UploadBaseFiles (self, issue, rpc_server, patch_list, patchset, options, files)
 
def IsImage (self, filename)
 
def __init__ (self, options)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def CheckForUnknownFiles (self)
 
def GetBaseFile (self, filename)
 
def GetBaseFiles (self, diff)
 
def UploadBaseFiles (self, issue, rpc_server, patch_list, patchset, options, files)
 
def IsImage (self, filename)
 
def __init__ (self, options)
 
def GenerateDiff (self, args)
 
def GetUnknownFiles (self)
 
def CheckForUnknownFiles (self)
 
def GetBaseFile (self, filename)
 
def GetBaseFiles (self, diff)
 
def UploadBaseFiles (self, issue, rpc_server, patch_list, patchset, options, files)
 
def IsImage (self, filename)
 

Public Attributes

 rev_start
 
 rev_end
 
 svnls_cache
 
 svn_base
 
- Public Attributes inherited from upload.VersionControlSystem
 options
 

Private Member Functions

def _GuessBase (self, required)
 
def _CollapseKeywords (self, content, keyword_str)
 
def _GuessBase (self, required)
 
def _CollapseKeywords (self, content, keyword_str)
 
def _GuessBase (self, required)
 
def _CollapseKeywords (self, content, keyword_str)
 
def _GuessBase (self, required)
 
def _CollapseKeywords (self, content, keyword_str)
 
def _GuessBase (self, required)
 
def _CollapseKeywords (self, content, keyword_str)
 
def _GuessBase (self, required)
 
def _CollapseKeywords (self, content, keyword_str)
 

Detailed Description

Implementation of the VersionControlSystem interface for Subversion.

Definition at line 721 of file upload.py.

Constructor & Destructor Documentation

def upload.SubversionVCS.__init__ (   self,
  options 
)

Definition at line 724 of file upload.py.

References upload.ErrorExit().

Referenced by upload.SubversionVCS.__init__().

724  def __init__(self, options):
725  super(SubversionVCS, self).__init__(options)
726  if self.options.revision:
727  match = re.match(r"(\d+)(:(\d+))?", self.options.revision)
728  if not match:
729  ErrorExit("Invalid Subversion revision %s." % self.options.revision)
730  self.rev_start = match.group(1)
731  self.rev_end = match.group(3)
732  else:
733  self.rev_start = self.rev_end = None
734  # Cache output from "svn list -r REVNO dirname".
735  # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).
736  self.svnls_cache = {}
737  # SVN base URL is required to fetch files deleted in an older revision.
738  # Result is cached to not guess it over and over again in GetBaseFile().
739  required = self.options.download_base or self.options.revision is not None
740  self.svn_base = self._GuessBase(required)
741 
def _GuessBase(self, required)
Definition: upload.py:746
def ErrorExit(msg)
Definition: upload.py:109
def __init__(self, options)
Definition: upload.py:724
def upload.SubversionVCS.__init__ (   self,
  options 
)

Definition at line 724 of file upload.py.

References upload.SubversionVCS.__init__(), upload.SubversionVCS._GuessBase(), upload.ErrorExit(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.SubversionVCS.svn_base, and upload.SubversionVCS.svnls_cache.

724  def __init__(self, options):
725  super(SubversionVCS, self).__init__(options)
726  if self.options.revision:
727  match = re.match(r"(\d+)(:(\d+))?", self.options.revision)
728  if not match:
729  ErrorExit("Invalid Subversion revision %s." % self.options.revision)
730  self.rev_start = match.group(1)
731  self.rev_end = match.group(3)
732  else:
733  self.rev_start = self.rev_end = None
734  # Cache output from "svn list -r REVNO dirname".
735  # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).
736  self.svnls_cache = {}
737  # SVN base URL is required to fetch files deleted in an older revision.
738  # Result is cached to not guess it over and over again in GetBaseFile().
739  required = self.options.download_base or self.options.revision is not None
740  self.svn_base = self._GuessBase(required)
741 
def _GuessBase(self, required)
Definition: upload.py:746
def ErrorExit(msg)
Definition: upload.py:109
def __init__(self, options)
Definition: upload.py:724
def upload.SubversionVCS.__init__ (   self,
  options 
)

Definition at line 724 of file upload.py.

References upload.SubversionVCS.__init__(), upload.SubversionVCS._GuessBase(), upload.ErrorExit(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.SubversionVCS.svn_base, and upload.SubversionVCS.svnls_cache.

724  def __init__(self, options):
725  super(SubversionVCS, self).__init__(options)
726  if self.options.revision:
727  match = re.match(r"(\d+)(:(\d+))?", self.options.revision)
728  if not match:
729  ErrorExit("Invalid Subversion revision %s." % self.options.revision)
730  self.rev_start = match.group(1)
731  self.rev_end = match.group(3)
732  else:
733  self.rev_start = self.rev_end = None
734  # Cache output from "svn list -r REVNO dirname".
735  # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).
736  self.svnls_cache = {}
737  # SVN base URL is required to fetch files deleted in an older revision.
738  # Result is cached to not guess it over and over again in GetBaseFile().
739  required = self.options.download_base or self.options.revision is not None
740  self.svn_base = self._GuessBase(required)
741 
def _GuessBase(self, required)
Definition: upload.py:746
def ErrorExit(msg)
Definition: upload.py:109
def __init__(self, options)
Definition: upload.py:724
def upload.SubversionVCS.__init__ (   self,
  options 
)

Definition at line 724 of file upload.py.

References upload.SubversionVCS.__init__(), upload.SubversionVCS._GuessBase(), upload.ErrorExit(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.SubversionVCS.svn_base, and upload.SubversionVCS.svnls_cache.

724  def __init__(self, options):
725  super(SubversionVCS, self).__init__(options)
726  if self.options.revision:
727  match = re.match(r"(\d+)(:(\d+))?", self.options.revision)
728  if not match:
729  ErrorExit("Invalid Subversion revision %s." % self.options.revision)
730  self.rev_start = match.group(1)
731  self.rev_end = match.group(3)
732  else:
733  self.rev_start = self.rev_end = None
734  # Cache output from "svn list -r REVNO dirname".
735  # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).
736  self.svnls_cache = {}
737  # SVN base URL is required to fetch files deleted in an older revision.
738  # Result is cached to not guess it over and over again in GetBaseFile().
739  required = self.options.download_base or self.options.revision is not None
740  self.svn_base = self._GuessBase(required)
741 
def _GuessBase(self, required)
Definition: upload.py:746
def ErrorExit(msg)
Definition: upload.py:109
def __init__(self, options)
Definition: upload.py:724
def upload.SubversionVCS.__init__ (   self,
  options 
)

Definition at line 724 of file upload.py.

References upload.SubversionVCS.__init__(), upload.SubversionVCS._GuessBase(), upload.ErrorExit(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.SubversionVCS.svn_base, and upload.SubversionVCS.svnls_cache.

724  def __init__(self, options):
725  super(SubversionVCS, self).__init__(options)
726  if self.options.revision:
727  match = re.match(r"(\d+)(:(\d+))?", self.options.revision)
728  if not match:
729  ErrorExit("Invalid Subversion revision %s." % self.options.revision)
730  self.rev_start = match.group(1)
731  self.rev_end = match.group(3)
732  else:
733  self.rev_start = self.rev_end = None
734  # Cache output from "svn list -r REVNO dirname".
735  # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).
736  self.svnls_cache = {}
737  # SVN base URL is required to fetch files deleted in an older revision.
738  # Result is cached to not guess it over and over again in GetBaseFile().
739  required = self.options.download_base or self.options.revision is not None
740  self.svn_base = self._GuessBase(required)
741 
def _GuessBase(self, required)
Definition: upload.py:746
def ErrorExit(msg)
Definition: upload.py:109
def __init__(self, options)
Definition: upload.py:724
def upload.SubversionVCS.__init__ (   self,
  options 
)

Definition at line 724 of file upload.py.

References upload.SubversionVCS.__init__(), upload.SubversionVCS._GuessBase(), upload.ErrorExit(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.SubversionVCS.svn_base, and upload.SubversionVCS.svnls_cache.

724  def __init__(self, options):
725  super(SubversionVCS, self).__init__(options)
726  if self.options.revision:
727  match = re.match(r"(\d+)(:(\d+))?", self.options.revision)
728  if not match:
729  ErrorExit("Invalid Subversion revision %s." % self.options.revision)
730  self.rev_start = match.group(1)
731  self.rev_end = match.group(3)
732  else:
733  self.rev_start = self.rev_end = None
734  # Cache output from "svn list -r REVNO dirname".
735  # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).
736  self.svnls_cache = {}
737  # SVN base URL is required to fetch files deleted in an older revision.
738  # Result is cached to not guess it over and over again in GetBaseFile().
739  required = self.options.download_base or self.options.revision is not None
740  self.svn_base = self._GuessBase(required)
741 
def _GuessBase(self, required)
Definition: upload.py:746
def ErrorExit(msg)
Definition: upload.py:109
def __init__(self, options)
Definition: upload.py:724

Member Function Documentation

def upload.SubversionVCS._CollapseKeywords (   self,
  content,
  keyword_str 
)
private
Collapses SVN keywords.

Definition at line 805 of file upload.py.

References join.

Referenced by upload.SubversionVCS._CollapseKeywords(), and upload.SubversionVCS.GetBaseFile().

805  def _CollapseKeywords(self, content, keyword_str):
806  """Collapses SVN keywords."""
807  # svn cat translates keywords but svn diff doesn't. As a result of this
808  # behavior patching.PatchChunks() fails with a chunk mismatch error.
809  # This part was originally written by the Review Board development team
810  # who had the same problem (http://reviews.review-board.org/r/276/).
811  # Mapping of keywords to known aliases
812  svn_keywords = {
813  # Standard keywords
814  'Date': ['Date', 'LastChangedDate'],
815  'Revision': ['Revision', 'LastChangedRevision', 'Rev'],
816  'Author': ['Author', 'LastChangedBy'],
817  'HeadURL': ['HeadURL', 'URL'],
818  'Id': ['Id'],
819 
820  # Aliases
821  'LastChangedDate': ['LastChangedDate', 'Date'],
822  'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],
823  'LastChangedBy': ['LastChangedBy', 'Author'],
824  'URL': ['URL', 'HeadURL'],
825  }
826 
827  def repl(m):
828  if m.group(2):
829  return "$%s::%s$" % (m.group(1), " " * len(m.group(3)))
830  return "$%s$" % m.group(1)
831  keywords = [keyword
832  for name in keyword_str.split(" ")
833  for keyword in svn_keywords.get(name, [])]
834  return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content)
835 
#define join
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS._CollapseKeywords (   self,
  content,
  keyword_str 
)
private
Collapses SVN keywords.

Definition at line 805 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), and join.

805  def _CollapseKeywords(self, content, keyword_str):
806  """Collapses SVN keywords."""
807  # svn cat translates keywords but svn diff doesn't. As a result of this
808  # behavior patching.PatchChunks() fails with a chunk mismatch error.
809  # This part was originally written by the Review Board development team
810  # who had the same problem (http://reviews.review-board.org/r/276/).
811  # Mapping of keywords to known aliases
812  svn_keywords = {
813  # Standard keywords
814  'Date': ['Date', 'LastChangedDate'],
815  'Revision': ['Revision', 'LastChangedRevision', 'Rev'],
816  'Author': ['Author', 'LastChangedBy'],
817  'HeadURL': ['HeadURL', 'URL'],
818  'Id': ['Id'],
819 
820  # Aliases
821  'LastChangedDate': ['LastChangedDate', 'Date'],
822  'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],
823  'LastChangedBy': ['LastChangedBy', 'Author'],
824  'URL': ['URL', 'HeadURL'],
825  }
826 
827  def repl(m):
828  if m.group(2):
829  return "$%s::%s$" % (m.group(1), " " * len(m.group(3)))
830  return "$%s$" % m.group(1)
831  keywords = [keyword
832  for name in keyword_str.split(" ")
833  for keyword in svn_keywords.get(name, [])]
834  return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content)
835 
#define join
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS._CollapseKeywords (   self,
  content,
  keyword_str 
)
private
Collapses SVN keywords.

Definition at line 805 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), and join.

805  def _CollapseKeywords(self, content, keyword_str):
806  """Collapses SVN keywords."""
807  # svn cat translates keywords but svn diff doesn't. As a result of this
808  # behavior patching.PatchChunks() fails with a chunk mismatch error.
809  # This part was originally written by the Review Board development team
810  # who had the same problem (http://reviews.review-board.org/r/276/).
811  # Mapping of keywords to known aliases
812  svn_keywords = {
813  # Standard keywords
814  'Date': ['Date', 'LastChangedDate'],
815  'Revision': ['Revision', 'LastChangedRevision', 'Rev'],
816  'Author': ['Author', 'LastChangedBy'],
817  'HeadURL': ['HeadURL', 'URL'],
818  'Id': ['Id'],
819 
820  # Aliases
821  'LastChangedDate': ['LastChangedDate', 'Date'],
822  'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],
823  'LastChangedBy': ['LastChangedBy', 'Author'],
824  'URL': ['URL', 'HeadURL'],
825  }
826 
827  def repl(m):
828  if m.group(2):
829  return "$%s::%s$" % (m.group(1), " " * len(m.group(3)))
830  return "$%s$" % m.group(1)
831  keywords = [keyword
832  for name in keyword_str.split(" ")
833  for keyword in svn_keywords.get(name, [])]
834  return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content)
835 
#define join
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS._CollapseKeywords (   self,
  content,
  keyword_str 
)
private
Collapses SVN keywords.

Definition at line 805 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), and join.

805  def _CollapseKeywords(self, content, keyword_str):
806  """Collapses SVN keywords."""
807  # svn cat translates keywords but svn diff doesn't. As a result of this
808  # behavior patching.PatchChunks() fails with a chunk mismatch error.
809  # This part was originally written by the Review Board development team
810  # who had the same problem (http://reviews.review-board.org/r/276/).
811  # Mapping of keywords to known aliases
812  svn_keywords = {
813  # Standard keywords
814  'Date': ['Date', 'LastChangedDate'],
815  'Revision': ['Revision', 'LastChangedRevision', 'Rev'],
816  'Author': ['Author', 'LastChangedBy'],
817  'HeadURL': ['HeadURL', 'URL'],
818  'Id': ['Id'],
819 
820  # Aliases
821  'LastChangedDate': ['LastChangedDate', 'Date'],
822  'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],
823  'LastChangedBy': ['LastChangedBy', 'Author'],
824  'URL': ['URL', 'HeadURL'],
825  }
826 
827  def repl(m):
828  if m.group(2):
829  return "$%s::%s$" % (m.group(1), " " * len(m.group(3)))
830  return "$%s$" % m.group(1)
831  keywords = [keyword
832  for name in keyword_str.split(" ")
833  for keyword in svn_keywords.get(name, [])]
834  return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content)
835 
#define join
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS._CollapseKeywords (   self,
  content,
  keyword_str 
)
private
Collapses SVN keywords.

Definition at line 805 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), and join.

805  def _CollapseKeywords(self, content, keyword_str):
806  """Collapses SVN keywords."""
807  # svn cat translates keywords but svn diff doesn't. As a result of this
808  # behavior patching.PatchChunks() fails with a chunk mismatch error.
809  # This part was originally written by the Review Board development team
810  # who had the same problem (http://reviews.review-board.org/r/276/).
811  # Mapping of keywords to known aliases
812  svn_keywords = {
813  # Standard keywords
814  'Date': ['Date', 'LastChangedDate'],
815  'Revision': ['Revision', 'LastChangedRevision', 'Rev'],
816  'Author': ['Author', 'LastChangedBy'],
817  'HeadURL': ['HeadURL', 'URL'],
818  'Id': ['Id'],
819 
820  # Aliases
821  'LastChangedDate': ['LastChangedDate', 'Date'],
822  'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],
823  'LastChangedBy': ['LastChangedBy', 'Author'],
824  'URL': ['URL', 'HeadURL'],
825  }
826 
827  def repl(m):
828  if m.group(2):
829  return "$%s::%s$" % (m.group(1), " " * len(m.group(3)))
830  return "$%s$" % m.group(1)
831  keywords = [keyword
832  for name in keyword_str.split(" ")
833  for keyword in svn_keywords.get(name, [])]
834  return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content)
835 
#define join
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS._CollapseKeywords (   self,
  content,
  keyword_str 
)
private
Collapses SVN keywords.

Definition at line 805 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), and join.

805  def _CollapseKeywords(self, content, keyword_str):
806  """Collapses SVN keywords."""
807  # svn cat translates keywords but svn diff doesn't. As a result of this
808  # behavior patching.PatchChunks() fails with a chunk mismatch error.
809  # This part was originally written by the Review Board development team
810  # who had the same problem (http://reviews.review-board.org/r/276/).
811  # Mapping of keywords to known aliases
812  svn_keywords = {
813  # Standard keywords
814  'Date': ['Date', 'LastChangedDate'],
815  'Revision': ['Revision', 'LastChangedRevision', 'Rev'],
816  'Author': ['Author', 'LastChangedBy'],
817  'HeadURL': ['HeadURL', 'URL'],
818  'Id': ['Id'],
819 
820  # Aliases
821  'LastChangedDate': ['LastChangedDate', 'Date'],
822  'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],
823  'LastChangedBy': ['LastChangedBy', 'Author'],
824  'URL': ['URL', 'HeadURL'],
825  }
826 
827  def repl(m):
828  if m.group(2):
829  return "$%s::%s$" % (m.group(1), " " * len(m.group(3)))
830  return "$%s$" % m.group(1)
831  keywords = [keyword
832  for name in keyword_str.split(" ")
833  for keyword in svn_keywords.get(name, [])]
834  return re.sub(r"\$(%s):(:?)([^\$]+)\$" % '|'.join(keywords), repl, content)
835 
#define join
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS._GuessBase (   self,
  required 
)
private
Returns the SVN base URL.

Args:
  required: If true, exits if the url can't be guessed, otherwise None is
returned.

Definition at line 746 of file upload.py.

References upload.SubversionVCS._GuessBase(), upload.ErrorExit(), and upload.RunShell().

746  def _GuessBase(self, required):
747  """Returns the SVN base URL.
748 
749  Args:
750  required: If true, exits if the url can't be guessed, otherwise None is
751  returned.
752  """
753  info = RunShell(["svn", "info"])
754  for line in info.splitlines():
755  words = line.split()
756  if len(words) == 2 and words[0] == "URL:":
757  url = words[1]
758  scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
759  username, netloc = urllib.splituser(netloc)
760  if username:
761  logging.info("Removed username from base URL")
762  if netloc.endswith("svn.python.org"):
763  if netloc == "svn.python.org":
764  if path.startswith("/projects/"):
765  path = path[9:]
766  elif netloc != "pythondev@svn.python.org":
767  ErrorExit("Unrecognized Python URL: %s" % url)
768  base = "http://svn.python.org/view/*checkout*%s/" % path
769  logging.info("Guessed Python base = %s", base)
770  elif netloc.endswith("svn.collab.net"):
771  if path.startswith("/repos/"):
772  path = path[6:]
773  base = "http://svn.collab.net/viewvc/*checkout*%s/" % path
774  logging.info("Guessed CollabNet base = %s", base)
775  elif netloc.endswith(".googlecode.com"):
776  path = path + "/"
777  base = urlparse.urlunparse(("http", netloc, path, params,
778  query, fragment))
779  logging.info("Guessed Google Code base = %s", base)
780  else:
781  path = path + "/"
782  base = urlparse.urlunparse((scheme, netloc, path, params,
783  query, fragment))
784  logging.info("Guessed base = %s", base)
785  return base
786  if required:
787  ErrorExit("Can't find URL in output from svn info")
788  return None
789 
def _GuessBase(self, required)
Definition: upload.py:746
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def upload.SubversionVCS._GuessBase (   self,
  required 
)
private
Returns the SVN base URL.

Args:
  required: If true, exits if the url can't be guessed, otherwise None is
returned.

Definition at line 746 of file upload.py.

References upload.SubversionVCS._GuessBase(), upload.ErrorExit(), and upload.RunShell().

746  def _GuessBase(self, required):
747  """Returns the SVN base URL.
748 
749  Args:
750  required: If true, exits if the url can't be guessed, otherwise None is
751  returned.
752  """
753  info = RunShell(["svn", "info"])
754  for line in info.splitlines():
755  words = line.split()
756  if len(words) == 2 and words[0] == "URL:":
757  url = words[1]
758  scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
759  username, netloc = urllib.splituser(netloc)
760  if username:
761  logging.info("Removed username from base URL")
762  if netloc.endswith("svn.python.org"):
763  if netloc == "svn.python.org":
764  if path.startswith("/projects/"):
765  path = path[9:]
766  elif netloc != "pythondev@svn.python.org":
767  ErrorExit("Unrecognized Python URL: %s" % url)
768  base = "http://svn.python.org/view/*checkout*%s/" % path
769  logging.info("Guessed Python base = %s", base)
770  elif netloc.endswith("svn.collab.net"):
771  if path.startswith("/repos/"):
772  path = path[6:]
773  base = "http://svn.collab.net/viewvc/*checkout*%s/" % path
774  logging.info("Guessed CollabNet base = %s", base)
775  elif netloc.endswith(".googlecode.com"):
776  path = path + "/"
777  base = urlparse.urlunparse(("http", netloc, path, params,
778  query, fragment))
779  logging.info("Guessed Google Code base = %s", base)
780  else:
781  path = path + "/"
782  base = urlparse.urlunparse((scheme, netloc, path, params,
783  query, fragment))
784  logging.info("Guessed base = %s", base)
785  return base
786  if required:
787  ErrorExit("Can't find URL in output from svn info")
788  return None
789 
def _GuessBase(self, required)
Definition: upload.py:746
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def upload.SubversionVCS._GuessBase (   self,
  required 
)
private
Returns the SVN base URL.

Args:
  required: If true, exits if the url can't be guessed, otherwise None is
returned.

Definition at line 746 of file upload.py.

References upload.SubversionVCS._GuessBase(), upload.ErrorExit(), and upload.RunShell().

746  def _GuessBase(self, required):
747  """Returns the SVN base URL.
748 
749  Args:
750  required: If true, exits if the url can't be guessed, otherwise None is
751  returned.
752  """
753  info = RunShell(["svn", "info"])
754  for line in info.splitlines():
755  words = line.split()
756  if len(words) == 2 and words[0] == "URL:":
757  url = words[1]
758  scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
759  username, netloc = urllib.splituser(netloc)
760  if username:
761  logging.info("Removed username from base URL")
762  if netloc.endswith("svn.python.org"):
763  if netloc == "svn.python.org":
764  if path.startswith("/projects/"):
765  path = path[9:]
766  elif netloc != "pythondev@svn.python.org":
767  ErrorExit("Unrecognized Python URL: %s" % url)
768  base = "http://svn.python.org/view/*checkout*%s/" % path
769  logging.info("Guessed Python base = %s", base)
770  elif netloc.endswith("svn.collab.net"):
771  if path.startswith("/repos/"):
772  path = path[6:]
773  base = "http://svn.collab.net/viewvc/*checkout*%s/" % path
774  logging.info("Guessed CollabNet base = %s", base)
775  elif netloc.endswith(".googlecode.com"):
776  path = path + "/"
777  base = urlparse.urlunparse(("http", netloc, path, params,
778  query, fragment))
779  logging.info("Guessed Google Code base = %s", base)
780  else:
781  path = path + "/"
782  base = urlparse.urlunparse((scheme, netloc, path, params,
783  query, fragment))
784  logging.info("Guessed base = %s", base)
785  return base
786  if required:
787  ErrorExit("Can't find URL in output from svn info")
788  return None
789 
def _GuessBase(self, required)
Definition: upload.py:746
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def upload.SubversionVCS._GuessBase (   self,
  required 
)
private
Returns the SVN base URL.

Args:
  required: If true, exits if the url can't be guessed, otherwise None is
returned.

Definition at line 746 of file upload.py.

References upload.SubversionVCS._GuessBase(), upload.ErrorExit(), and upload.RunShell().

746  def _GuessBase(self, required):
747  """Returns the SVN base URL.
748 
749  Args:
750  required: If true, exits if the url can't be guessed, otherwise None is
751  returned.
752  """
753  info = RunShell(["svn", "info"])
754  for line in info.splitlines():
755  words = line.split()
756  if len(words) == 2 and words[0] == "URL:":
757  url = words[1]
758  scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
759  username, netloc = urllib.splituser(netloc)
760  if username:
761  logging.info("Removed username from base URL")
762  if netloc.endswith("svn.python.org"):
763  if netloc == "svn.python.org":
764  if path.startswith("/projects/"):
765  path = path[9:]
766  elif netloc != "pythondev@svn.python.org":
767  ErrorExit("Unrecognized Python URL: %s" % url)
768  base = "http://svn.python.org/view/*checkout*%s/" % path
769  logging.info("Guessed Python base = %s", base)
770  elif netloc.endswith("svn.collab.net"):
771  if path.startswith("/repos/"):
772  path = path[6:]
773  base = "http://svn.collab.net/viewvc/*checkout*%s/" % path
774  logging.info("Guessed CollabNet base = %s", base)
775  elif netloc.endswith(".googlecode.com"):
776  path = path + "/"
777  base = urlparse.urlunparse(("http", netloc, path, params,
778  query, fragment))
779  logging.info("Guessed Google Code base = %s", base)
780  else:
781  path = path + "/"
782  base = urlparse.urlunparse((scheme, netloc, path, params,
783  query, fragment))
784  logging.info("Guessed base = %s", base)
785  return base
786  if required:
787  ErrorExit("Can't find URL in output from svn info")
788  return None
789 
def _GuessBase(self, required)
Definition: upload.py:746
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def upload.SubversionVCS._GuessBase (   self,
  required 
)
private
Returns the SVN base URL.

Args:
  required: If true, exits if the url can't be guessed, otherwise None is
returned.

Definition at line 746 of file upload.py.

References upload.ErrorExit(), and upload.RunShell().

Referenced by upload.SubversionVCS.__init__(), and upload.SubversionVCS._GuessBase().

746  def _GuessBase(self, required):
747  """Returns the SVN base URL.
748 
749  Args:
750  required: If true, exits if the url can't be guessed, otherwise None is
751  returned.
752  """
753  info = RunShell(["svn", "info"])
754  for line in info.splitlines():
755  words = line.split()
756  if len(words) == 2 and words[0] == "URL:":
757  url = words[1]
758  scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
759  username, netloc = urllib.splituser(netloc)
760  if username:
761  logging.info("Removed username from base URL")
762  if netloc.endswith("svn.python.org"):
763  if netloc == "svn.python.org":
764  if path.startswith("/projects/"):
765  path = path[9:]
766  elif netloc != "pythondev@svn.python.org":
767  ErrorExit("Unrecognized Python URL: %s" % url)
768  base = "http://svn.python.org/view/*checkout*%s/" % path
769  logging.info("Guessed Python base = %s", base)
770  elif netloc.endswith("svn.collab.net"):
771  if path.startswith("/repos/"):
772  path = path[6:]
773  base = "http://svn.collab.net/viewvc/*checkout*%s/" % path
774  logging.info("Guessed CollabNet base = %s", base)
775  elif netloc.endswith(".googlecode.com"):
776  path = path + "/"
777  base = urlparse.urlunparse(("http", netloc, path, params,
778  query, fragment))
779  logging.info("Guessed Google Code base = %s", base)
780  else:
781  path = path + "/"
782  base = urlparse.urlunparse((scheme, netloc, path, params,
783  query, fragment))
784  logging.info("Guessed base = %s", base)
785  return base
786  if required:
787  ErrorExit("Can't find URL in output from svn info")
788  return None
789 
def _GuessBase(self, required)
Definition: upload.py:746
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def upload.SubversionVCS._GuessBase (   self,
  required 
)
private
Returns the SVN base URL.

Args:
  required: If true, exits if the url can't be guessed, otherwise None is
returned.

Definition at line 746 of file upload.py.

References upload.SubversionVCS._GuessBase(), upload.ErrorExit(), and upload.RunShell().

746  def _GuessBase(self, required):
747  """Returns the SVN base URL.
748 
749  Args:
750  required: If true, exits if the url can't be guessed, otherwise None is
751  returned.
752  """
753  info = RunShell(["svn", "info"])
754  for line in info.splitlines():
755  words = line.split()
756  if len(words) == 2 and words[0] == "URL:":
757  url = words[1]
758  scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
759  username, netloc = urllib.splituser(netloc)
760  if username:
761  logging.info("Removed username from base URL")
762  if netloc.endswith("svn.python.org"):
763  if netloc == "svn.python.org":
764  if path.startswith("/projects/"):
765  path = path[9:]
766  elif netloc != "pythondev@svn.python.org":
767  ErrorExit("Unrecognized Python URL: %s" % url)
768  base = "http://svn.python.org/view/*checkout*%s/" % path
769  logging.info("Guessed Python base = %s", base)
770  elif netloc.endswith("svn.collab.net"):
771  if path.startswith("/repos/"):
772  path = path[6:]
773  base = "http://svn.collab.net/viewvc/*checkout*%s/" % path
774  logging.info("Guessed CollabNet base = %s", base)
775  elif netloc.endswith(".googlecode.com"):
776  path = path + "/"
777  base = urlparse.urlunparse(("http", netloc, path, params,
778  query, fragment))
779  logging.info("Guessed Google Code base = %s", base)
780  else:
781  path = path + "/"
782  base = urlparse.urlunparse((scheme, netloc, path, params,
783  query, fragment))
784  logging.info("Guessed base = %s", base)
785  return base
786  if required:
787  ErrorExit("Can't find URL in output from svn info")
788  return None
789 
def _GuessBase(self, required)
Definition: upload.py:746
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def upload.SubversionVCS.GenerateDiff (   self,
  args 
)

Definition at line 790 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GenerateDiff(), and upload.RunShell().

790  def GenerateDiff(self, args):
791  cmd = ["svn", "diff"]
792  if self.options.revision:
793  cmd += ["-r", self.options.revision]
794  cmd.extend(args)
795  data = RunShell(cmd)
796  count = 0
797  for line in data.splitlines():
798  if line.startswith("Index:") or line.startswith("Property changes on:"):
799  count += 1
800  logging.info(line)
801  if not count:
802  ErrorExit("No valid patches found in output from svn diff")
803  return data
804 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GenerateDiff(self, args)
Definition: upload.py:790
def upload.SubversionVCS.GenerateDiff (   self,
  args 
)

Definition at line 790 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GenerateDiff(), and upload.RunShell().

790  def GenerateDiff(self, args):
791  cmd = ["svn", "diff"]
792  if self.options.revision:
793  cmd += ["-r", self.options.revision]
794  cmd.extend(args)
795  data = RunShell(cmd)
796  count = 0
797  for line in data.splitlines():
798  if line.startswith("Index:") or line.startswith("Property changes on:"):
799  count += 1
800  logging.info(line)
801  if not count:
802  ErrorExit("No valid patches found in output from svn diff")
803  return data
804 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GenerateDiff(self, args)
Definition: upload.py:790
def upload.SubversionVCS.GenerateDiff (   self,
  args 
)

Definition at line 790 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GenerateDiff(), and upload.RunShell().

790  def GenerateDiff(self, args):
791  cmd = ["svn", "diff"]
792  if self.options.revision:
793  cmd += ["-r", self.options.revision]
794  cmd.extend(args)
795  data = RunShell(cmd)
796  count = 0
797  for line in data.splitlines():
798  if line.startswith("Index:") or line.startswith("Property changes on:"):
799  count += 1
800  logging.info(line)
801  if not count:
802  ErrorExit("No valid patches found in output from svn diff")
803  return data
804 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GenerateDiff(self, args)
Definition: upload.py:790
def upload.SubversionVCS.GenerateDiff (   self,
  args 
)

Definition at line 790 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GenerateDiff(), and upload.RunShell().

790  def GenerateDiff(self, args):
791  cmd = ["svn", "diff"]
792  if self.options.revision:
793  cmd += ["-r", self.options.revision]
794  cmd.extend(args)
795  data = RunShell(cmd)
796  count = 0
797  for line in data.splitlines():
798  if line.startswith("Index:") or line.startswith("Property changes on:"):
799  count += 1
800  logging.info(line)
801  if not count:
802  ErrorExit("No valid patches found in output from svn diff")
803  return data
804 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GenerateDiff(self, args)
Definition: upload.py:790
def upload.SubversionVCS.GenerateDiff (   self,
  args 
)

Definition at line 790 of file upload.py.

References upload.ErrorExit(), and upload.RunShell().

Referenced by upload.SubversionVCS.GenerateDiff().

790  def GenerateDiff(self, args):
791  cmd = ["svn", "diff"]
792  if self.options.revision:
793  cmd += ["-r", self.options.revision]
794  cmd.extend(args)
795  data = RunShell(cmd)
796  count = 0
797  for line in data.splitlines():
798  if line.startswith("Index:") or line.startswith("Property changes on:"):
799  count += 1
800  logging.info(line)
801  if not count:
802  ErrorExit("No valid patches found in output from svn diff")
803  return data
804 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GenerateDiff(self, args)
Definition: upload.py:790
def upload.SubversionVCS.GenerateDiff (   self,
  args 
)

Definition at line 790 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GenerateDiff(), and upload.RunShell().

790  def GenerateDiff(self, args):
791  cmd = ["svn", "diff"]
792  if self.options.revision:
793  cmd += ["-r", self.options.revision]
794  cmd.extend(args)
795  data = RunShell(cmd)
796  count = 0
797  for line in data.splitlines():
798  if line.startswith("Index:") or line.startswith("Property changes on:"):
799  count += 1
800  logging.info(line)
801  if not count:
802  ErrorExit("No valid patches found in output from svn diff")
803  return data
804 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GenerateDiff(self, args)
Definition: upload.py:790
def upload.SubversionVCS.GetBaseFile (   self,
  filename 
)

Definition at line 898 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), upload.SubversionVCS.GetBaseFile(), upload.SubversionVCS.GetStatus(), upload.VersionControlSystem.IsImage(), upload.SubversionVCS.ReadFile(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), upload.StatusUpdate(), and upload.SubversionVCS.svn_base.

898  def GetBaseFile(self, filename):
899  status = self.GetStatus(filename)
900  base_content = None
901  new_content = None
902 
903  # If a file is copied its status will be "A +", which signifies
904  # "addition-with-history". See "svn st" for more information. We need to
905  # upload the original file or else diff parsing will fail if the file was
906  # edited.
907  if status[0] == "A" and status[3] != "+":
908  # We'll need to upload the new content if we're adding a binary file
909  # since diff's output won't contain it.
910  mimetype = RunShell(["svn", "propget", "svn:mime-type", filename],
911  silent_ok=True)
912  base_content = ""
913  is_binary = mimetype and not mimetype.startswith("text/")
914  if is_binary and self.IsImage(filename):
915  new_content = self.ReadFile(filename)
916  elif (status[0] in ("M", "D", "R") or
917  (status[0] == "A" and status[3] == "+") or # Copied file.
918  (status[0] == " " and status[1] == "M")): # Property change.
919  args = []
920  if self.options.revision:
921  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
922  else:
923  # Don't change filename, it's needed later.
924  url = filename
925  args += ["-r", "BASE"]
926  cmd = ["svn"] + args + ["propget", "svn:mime-type", url]
927  mimetype, returncode = RunShellWithReturnCode(cmd)
928  if returncode:
929  # File does not exist in the requested revision.
930  # Reset mimetype, it contains an error message.
931  mimetype = ""
932  get_base = False
933  is_binary = mimetype and not mimetype.startswith("text/")
934  if status[0] == " ":
935  # Empty base content just to force an upload.
936  base_content = ""
937  elif is_binary:
938  if self.IsImage(filename):
939  get_base = True
940  if status[0] == "M":
941  if not self.rev_end:
942  new_content = self.ReadFile(filename)
943  else:
944  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end)
945  new_content = RunShell(["svn", "cat", url],
946  universal_newlines=True, silent_ok=True)
947  else:
948  base_content = ""
949  else:
950  get_base = True
951 
952  if get_base:
953  if is_binary:
954  universal_newlines = False
955  else:
956  universal_newlines = True
957  if self.rev_start:
958  # "svn cat -r REV delete_file.txt" doesn't work. cat requires
959  # the full URL with "@REV" appended instead of using "-r" option.
960  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
961  base_content = RunShell(["svn", "cat", url],
962  universal_newlines=universal_newlines,
963  silent_ok=True)
964  else:
965  base_content = RunShell(["svn", "cat", filename],
966  universal_newlines=universal_newlines,
967  silent_ok=True)
968  if not is_binary:
969  args = []
970  if self.rev_start:
971  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
972  else:
973  url = filename
974  args += ["-r", "BASE"]
975  cmd = ["svn"] + args + ["propget", "svn:keywords", url]
976  keywords, returncode = RunShellWithReturnCode(cmd)
977  if keywords and not returncode:
978  base_content = self._CollapseKeywords(base_content, keywords)
979  else:
980  StatusUpdate("svn status returned unexpected output: %s" % status)
981  sys.exit(1)
982  return base_content, new_content, is_binary, status[0:5]
983 
984 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ReadFile(self, filename)
Definition: upload.py:844
def GetBaseFile(self, filename)
Definition: upload.py:898
def StatusUpdate(msg)
Definition: upload.py:97
def GetStatus(self, filename)
Definition: upload.py:854
def IsImage(self, filename)
Definition: upload.py:713
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS.GetBaseFile (   self,
  filename 
)

Definition at line 898 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), upload.SubversionVCS.GetBaseFile(), upload.SubversionVCS.GetStatus(), upload.VersionControlSystem.IsImage(), upload.SubversionVCS.ReadFile(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), upload.StatusUpdate(), and upload.SubversionVCS.svn_base.

898  def GetBaseFile(self, filename):
899  status = self.GetStatus(filename)
900  base_content = None
901  new_content = None
902 
903  # If a file is copied its status will be "A +", which signifies
904  # "addition-with-history". See "svn st" for more information. We need to
905  # upload the original file or else diff parsing will fail if the file was
906  # edited.
907  if status[0] == "A" and status[3] != "+":
908  # We'll need to upload the new content if we're adding a binary file
909  # since diff's output won't contain it.
910  mimetype = RunShell(["svn", "propget", "svn:mime-type", filename],
911  silent_ok=True)
912  base_content = ""
913  is_binary = mimetype and not mimetype.startswith("text/")
914  if is_binary and self.IsImage(filename):
915  new_content = self.ReadFile(filename)
916  elif (status[0] in ("M", "D", "R") or
917  (status[0] == "A" and status[3] == "+") or # Copied file.
918  (status[0] == " " and status[1] == "M")): # Property change.
919  args = []
920  if self.options.revision:
921  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
922  else:
923  # Don't change filename, it's needed later.
924  url = filename
925  args += ["-r", "BASE"]
926  cmd = ["svn"] + args + ["propget", "svn:mime-type", url]
927  mimetype, returncode = RunShellWithReturnCode(cmd)
928  if returncode:
929  # File does not exist in the requested revision.
930  # Reset mimetype, it contains an error message.
931  mimetype = ""
932  get_base = False
933  is_binary = mimetype and not mimetype.startswith("text/")
934  if status[0] == " ":
935  # Empty base content just to force an upload.
936  base_content = ""
937  elif is_binary:
938  if self.IsImage(filename):
939  get_base = True
940  if status[0] == "M":
941  if not self.rev_end:
942  new_content = self.ReadFile(filename)
943  else:
944  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end)
945  new_content = RunShell(["svn", "cat", url],
946  universal_newlines=True, silent_ok=True)
947  else:
948  base_content = ""
949  else:
950  get_base = True
951 
952  if get_base:
953  if is_binary:
954  universal_newlines = False
955  else:
956  universal_newlines = True
957  if self.rev_start:
958  # "svn cat -r REV delete_file.txt" doesn't work. cat requires
959  # the full URL with "@REV" appended instead of using "-r" option.
960  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
961  base_content = RunShell(["svn", "cat", url],
962  universal_newlines=universal_newlines,
963  silent_ok=True)
964  else:
965  base_content = RunShell(["svn", "cat", filename],
966  universal_newlines=universal_newlines,
967  silent_ok=True)
968  if not is_binary:
969  args = []
970  if self.rev_start:
971  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
972  else:
973  url = filename
974  args += ["-r", "BASE"]
975  cmd = ["svn"] + args + ["propget", "svn:keywords", url]
976  keywords, returncode = RunShellWithReturnCode(cmd)
977  if keywords and not returncode:
978  base_content = self._CollapseKeywords(base_content, keywords)
979  else:
980  StatusUpdate("svn status returned unexpected output: %s" % status)
981  sys.exit(1)
982  return base_content, new_content, is_binary, status[0:5]
983 
984 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ReadFile(self, filename)
Definition: upload.py:844
def GetBaseFile(self, filename)
Definition: upload.py:898
def StatusUpdate(msg)
Definition: upload.py:97
def GetStatus(self, filename)
Definition: upload.py:854
def IsImage(self, filename)
Definition: upload.py:713
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS.GetBaseFile (   self,
  filename 
)

Definition at line 898 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), upload.SubversionVCS.GetStatus(), upload.VersionControlSystem.IsImage(), upload.SubversionVCS.ReadFile(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), upload.StatusUpdate(), and upload.SubversionVCS.svn_base.

Referenced by upload.SubversionVCS.GetBaseFile().

898  def GetBaseFile(self, filename):
899  status = self.GetStatus(filename)
900  base_content = None
901  new_content = None
902 
903  # If a file is copied its status will be "A +", which signifies
904  # "addition-with-history". See "svn st" for more information. We need to
905  # upload the original file or else diff parsing will fail if the file was
906  # edited.
907  if status[0] == "A" and status[3] != "+":
908  # We'll need to upload the new content if we're adding a binary file
909  # since diff's output won't contain it.
910  mimetype = RunShell(["svn", "propget", "svn:mime-type", filename],
911  silent_ok=True)
912  base_content = ""
913  is_binary = mimetype and not mimetype.startswith("text/")
914  if is_binary and self.IsImage(filename):
915  new_content = self.ReadFile(filename)
916  elif (status[0] in ("M", "D", "R") or
917  (status[0] == "A" and status[3] == "+") or # Copied file.
918  (status[0] == " " and status[1] == "M")): # Property change.
919  args = []
920  if self.options.revision:
921  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
922  else:
923  # Don't change filename, it's needed later.
924  url = filename
925  args += ["-r", "BASE"]
926  cmd = ["svn"] + args + ["propget", "svn:mime-type", url]
927  mimetype, returncode = RunShellWithReturnCode(cmd)
928  if returncode:
929  # File does not exist in the requested revision.
930  # Reset mimetype, it contains an error message.
931  mimetype = ""
932  get_base = False
933  is_binary = mimetype and not mimetype.startswith("text/")
934  if status[0] == " ":
935  # Empty base content just to force an upload.
936  base_content = ""
937  elif is_binary:
938  if self.IsImage(filename):
939  get_base = True
940  if status[0] == "M":
941  if not self.rev_end:
942  new_content = self.ReadFile(filename)
943  else:
944  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end)
945  new_content = RunShell(["svn", "cat", url],
946  universal_newlines=True, silent_ok=True)
947  else:
948  base_content = ""
949  else:
950  get_base = True
951 
952  if get_base:
953  if is_binary:
954  universal_newlines = False
955  else:
956  universal_newlines = True
957  if self.rev_start:
958  # "svn cat -r REV delete_file.txt" doesn't work. cat requires
959  # the full URL with "@REV" appended instead of using "-r" option.
960  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
961  base_content = RunShell(["svn", "cat", url],
962  universal_newlines=universal_newlines,
963  silent_ok=True)
964  else:
965  base_content = RunShell(["svn", "cat", filename],
966  universal_newlines=universal_newlines,
967  silent_ok=True)
968  if not is_binary:
969  args = []
970  if self.rev_start:
971  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
972  else:
973  url = filename
974  args += ["-r", "BASE"]
975  cmd = ["svn"] + args + ["propget", "svn:keywords", url]
976  keywords, returncode = RunShellWithReturnCode(cmd)
977  if keywords and not returncode:
978  base_content = self._CollapseKeywords(base_content, keywords)
979  else:
980  StatusUpdate("svn status returned unexpected output: %s" % status)
981  sys.exit(1)
982  return base_content, new_content, is_binary, status[0:5]
983 
984 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ReadFile(self, filename)
Definition: upload.py:844
def GetBaseFile(self, filename)
Definition: upload.py:898
def StatusUpdate(msg)
Definition: upload.py:97
def GetStatus(self, filename)
Definition: upload.py:854
def IsImage(self, filename)
Definition: upload.py:713
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS.GetBaseFile (   self,
  filename 
)

Definition at line 898 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), upload.SubversionVCS.GetBaseFile(), upload.SubversionVCS.GetStatus(), upload.VersionControlSystem.IsImage(), upload.SubversionVCS.ReadFile(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), upload.StatusUpdate(), and upload.SubversionVCS.svn_base.

898  def GetBaseFile(self, filename):
899  status = self.GetStatus(filename)
900  base_content = None
901  new_content = None
902 
903  # If a file is copied its status will be "A +", which signifies
904  # "addition-with-history". See "svn st" for more information. We need to
905  # upload the original file or else diff parsing will fail if the file was
906  # edited.
907  if status[0] == "A" and status[3] != "+":
908  # We'll need to upload the new content if we're adding a binary file
909  # since diff's output won't contain it.
910  mimetype = RunShell(["svn", "propget", "svn:mime-type", filename],
911  silent_ok=True)
912  base_content = ""
913  is_binary = mimetype and not mimetype.startswith("text/")
914  if is_binary and self.IsImage(filename):
915  new_content = self.ReadFile(filename)
916  elif (status[0] in ("M", "D", "R") or
917  (status[0] == "A" and status[3] == "+") or # Copied file.
918  (status[0] == " " and status[1] == "M")): # Property change.
919  args = []
920  if self.options.revision:
921  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
922  else:
923  # Don't change filename, it's needed later.
924  url = filename
925  args += ["-r", "BASE"]
926  cmd = ["svn"] + args + ["propget", "svn:mime-type", url]
927  mimetype, returncode = RunShellWithReturnCode(cmd)
928  if returncode:
929  # File does not exist in the requested revision.
930  # Reset mimetype, it contains an error message.
931  mimetype = ""
932  get_base = False
933  is_binary = mimetype and not mimetype.startswith("text/")
934  if status[0] == " ":
935  # Empty base content just to force an upload.
936  base_content = ""
937  elif is_binary:
938  if self.IsImage(filename):
939  get_base = True
940  if status[0] == "M":
941  if not self.rev_end:
942  new_content = self.ReadFile(filename)
943  else:
944  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end)
945  new_content = RunShell(["svn", "cat", url],
946  universal_newlines=True, silent_ok=True)
947  else:
948  base_content = ""
949  else:
950  get_base = True
951 
952  if get_base:
953  if is_binary:
954  universal_newlines = False
955  else:
956  universal_newlines = True
957  if self.rev_start:
958  # "svn cat -r REV delete_file.txt" doesn't work. cat requires
959  # the full URL with "@REV" appended instead of using "-r" option.
960  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
961  base_content = RunShell(["svn", "cat", url],
962  universal_newlines=universal_newlines,
963  silent_ok=True)
964  else:
965  base_content = RunShell(["svn", "cat", filename],
966  universal_newlines=universal_newlines,
967  silent_ok=True)
968  if not is_binary:
969  args = []
970  if self.rev_start:
971  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
972  else:
973  url = filename
974  args += ["-r", "BASE"]
975  cmd = ["svn"] + args + ["propget", "svn:keywords", url]
976  keywords, returncode = RunShellWithReturnCode(cmd)
977  if keywords and not returncode:
978  base_content = self._CollapseKeywords(base_content, keywords)
979  else:
980  StatusUpdate("svn status returned unexpected output: %s" % status)
981  sys.exit(1)
982  return base_content, new_content, is_binary, status[0:5]
983 
984 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ReadFile(self, filename)
Definition: upload.py:844
def GetBaseFile(self, filename)
Definition: upload.py:898
def StatusUpdate(msg)
Definition: upload.py:97
def GetStatus(self, filename)
Definition: upload.py:854
def IsImage(self, filename)
Definition: upload.py:713
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS.GetBaseFile (   self,
  filename 
)

Definition at line 898 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), upload.SubversionVCS.GetBaseFile(), upload.SubversionVCS.GetStatus(), upload.VersionControlSystem.IsImage(), upload.SubversionVCS.ReadFile(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), upload.StatusUpdate(), and upload.SubversionVCS.svn_base.

898  def GetBaseFile(self, filename):
899  status = self.GetStatus(filename)
900  base_content = None
901  new_content = None
902 
903  # If a file is copied its status will be "A +", which signifies
904  # "addition-with-history". See "svn st" for more information. We need to
905  # upload the original file or else diff parsing will fail if the file was
906  # edited.
907  if status[0] == "A" and status[3] != "+":
908  # We'll need to upload the new content if we're adding a binary file
909  # since diff's output won't contain it.
910  mimetype = RunShell(["svn", "propget", "svn:mime-type", filename],
911  silent_ok=True)
912  base_content = ""
913  is_binary = mimetype and not mimetype.startswith("text/")
914  if is_binary and self.IsImage(filename):
915  new_content = self.ReadFile(filename)
916  elif (status[0] in ("M", "D", "R") or
917  (status[0] == "A" and status[3] == "+") or # Copied file.
918  (status[0] == " " and status[1] == "M")): # Property change.
919  args = []
920  if self.options.revision:
921  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
922  else:
923  # Don't change filename, it's needed later.
924  url = filename
925  args += ["-r", "BASE"]
926  cmd = ["svn"] + args + ["propget", "svn:mime-type", url]
927  mimetype, returncode = RunShellWithReturnCode(cmd)
928  if returncode:
929  # File does not exist in the requested revision.
930  # Reset mimetype, it contains an error message.
931  mimetype = ""
932  get_base = False
933  is_binary = mimetype and not mimetype.startswith("text/")
934  if status[0] == " ":
935  # Empty base content just to force an upload.
936  base_content = ""
937  elif is_binary:
938  if self.IsImage(filename):
939  get_base = True
940  if status[0] == "M":
941  if not self.rev_end:
942  new_content = self.ReadFile(filename)
943  else:
944  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end)
945  new_content = RunShell(["svn", "cat", url],
946  universal_newlines=True, silent_ok=True)
947  else:
948  base_content = ""
949  else:
950  get_base = True
951 
952  if get_base:
953  if is_binary:
954  universal_newlines = False
955  else:
956  universal_newlines = True
957  if self.rev_start:
958  # "svn cat -r REV delete_file.txt" doesn't work. cat requires
959  # the full URL with "@REV" appended instead of using "-r" option.
960  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
961  base_content = RunShell(["svn", "cat", url],
962  universal_newlines=universal_newlines,
963  silent_ok=True)
964  else:
965  base_content = RunShell(["svn", "cat", filename],
966  universal_newlines=universal_newlines,
967  silent_ok=True)
968  if not is_binary:
969  args = []
970  if self.rev_start:
971  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
972  else:
973  url = filename
974  args += ["-r", "BASE"]
975  cmd = ["svn"] + args + ["propget", "svn:keywords", url]
976  keywords, returncode = RunShellWithReturnCode(cmd)
977  if keywords and not returncode:
978  base_content = self._CollapseKeywords(base_content, keywords)
979  else:
980  StatusUpdate("svn status returned unexpected output: %s" % status)
981  sys.exit(1)
982  return base_content, new_content, is_binary, status[0:5]
983 
984 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ReadFile(self, filename)
Definition: upload.py:844
def GetBaseFile(self, filename)
Definition: upload.py:898
def StatusUpdate(msg)
Definition: upload.py:97
def GetStatus(self, filename)
Definition: upload.py:854
def IsImage(self, filename)
Definition: upload.py:713
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS.GetBaseFile (   self,
  filename 
)

Definition at line 898 of file upload.py.

References upload.SubversionVCS._CollapseKeywords(), upload.SubversionVCS.GetBaseFile(), upload.SubversionVCS.GetStatus(), upload.VersionControlSystem.IsImage(), upload.SubversionVCS.ReadFile(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), upload.StatusUpdate(), and upload.SubversionVCS.svn_base.

898  def GetBaseFile(self, filename):
899  status = self.GetStatus(filename)
900  base_content = None
901  new_content = None
902 
903  # If a file is copied its status will be "A +", which signifies
904  # "addition-with-history". See "svn st" for more information. We need to
905  # upload the original file or else diff parsing will fail if the file was
906  # edited.
907  if status[0] == "A" and status[3] != "+":
908  # We'll need to upload the new content if we're adding a binary file
909  # since diff's output won't contain it.
910  mimetype = RunShell(["svn", "propget", "svn:mime-type", filename],
911  silent_ok=True)
912  base_content = ""
913  is_binary = mimetype and not mimetype.startswith("text/")
914  if is_binary and self.IsImage(filename):
915  new_content = self.ReadFile(filename)
916  elif (status[0] in ("M", "D", "R") or
917  (status[0] == "A" and status[3] == "+") or # Copied file.
918  (status[0] == " " and status[1] == "M")): # Property change.
919  args = []
920  if self.options.revision:
921  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
922  else:
923  # Don't change filename, it's needed later.
924  url = filename
925  args += ["-r", "BASE"]
926  cmd = ["svn"] + args + ["propget", "svn:mime-type", url]
927  mimetype, returncode = RunShellWithReturnCode(cmd)
928  if returncode:
929  # File does not exist in the requested revision.
930  # Reset mimetype, it contains an error message.
931  mimetype = ""
932  get_base = False
933  is_binary = mimetype and not mimetype.startswith("text/")
934  if status[0] == " ":
935  # Empty base content just to force an upload.
936  base_content = ""
937  elif is_binary:
938  if self.IsImage(filename):
939  get_base = True
940  if status[0] == "M":
941  if not self.rev_end:
942  new_content = self.ReadFile(filename)
943  else:
944  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end)
945  new_content = RunShell(["svn", "cat", url],
946  universal_newlines=True, silent_ok=True)
947  else:
948  base_content = ""
949  else:
950  get_base = True
951 
952  if get_base:
953  if is_binary:
954  universal_newlines = False
955  else:
956  universal_newlines = True
957  if self.rev_start:
958  # "svn cat -r REV delete_file.txt" doesn't work. cat requires
959  # the full URL with "@REV" appended instead of using "-r" option.
960  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
961  base_content = RunShell(["svn", "cat", url],
962  universal_newlines=universal_newlines,
963  silent_ok=True)
964  else:
965  base_content = RunShell(["svn", "cat", filename],
966  universal_newlines=universal_newlines,
967  silent_ok=True)
968  if not is_binary:
969  args = []
970  if self.rev_start:
971  url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
972  else:
973  url = filename
974  args += ["-r", "BASE"]
975  cmd = ["svn"] + args + ["propget", "svn:keywords", url]
976  keywords, returncode = RunShellWithReturnCode(cmd)
977  if keywords and not returncode:
978  base_content = self._CollapseKeywords(base_content, keywords)
979  else:
980  StatusUpdate("svn status returned unexpected output: %s" % status)
981  sys.exit(1)
982  return base_content, new_content, is_binary, status[0:5]
983 
984 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ReadFile(self, filename)
Definition: upload.py:844
def GetBaseFile(self, filename)
Definition: upload.py:898
def StatusUpdate(msg)
Definition: upload.py:97
def GetStatus(self, filename)
Definition: upload.py:854
def IsImage(self, filename)
Definition: upload.py:713
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def _CollapseKeywords(self, content, keyword_str)
Definition: upload.py:805
def upload.SubversionVCS.GetStatus (   self,
  filename 
)
Returns the status of a file.

Definition at line 854 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GetStatus(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), and upload.SubversionVCS.svnls_cache.

854  def GetStatus(self, filename):
855  """Returns the status of a file."""
856  if not self.options.revision:
857  status = RunShell(["svn", "status", "--ignore-externals", filename])
858  if not status:
859  ErrorExit("svn status returned no output for %s" % filename)
860  status_lines = status.splitlines()
861  # If file is in a cl, the output will begin with
862  # "\n--- Changelist 'cl_name':\n". See
863  # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
864  if (len(status_lines) == 3 and
865  not status_lines[0] and
866  status_lines[1].startswith("--- Changelist")):
867  status = status_lines[2]
868  else:
869  status = status_lines[0]
870  # If we have a revision to diff against we need to run "svn list"
871  # for the old and the new revision and compare the results to get
872  # the correct status for a file.
873  else:
874  dirname, relfilename = os.path.split(filename)
875  if dirname not in self.svnls_cache:
876  cmd = ["svn", "list", "-r", self.rev_start, dirname or "."]
877  out, returncode = RunShellWithReturnCode(cmd)
878  if returncode:
879  ErrorExit("Failed to get status for %s." % filename)
880  old_files = out.splitlines()
881  args = ["svn", "list"]
882  if self.rev_end:
883  args += ["-r", self.rev_end]
884  cmd = args + [dirname or "."]
885  out, returncode = RunShellWithReturnCode(cmd)
886  if returncode:
887  ErrorExit("Failed to run command %s" % cmd)
888  self.svnls_cache[dirname] = (old_files, out.splitlines())
889  old_files, new_files = self.svnls_cache[dirname]
890  if relfilename in old_files and relfilename not in new_files:
891  status = "D "
892  elif relfilename in old_files and relfilename in new_files:
893  status = "M "
894  else:
895  status = "A "
896  return status
897 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GetStatus(self, filename)
Definition: upload.py:854
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def upload.SubversionVCS.GetStatus (   self,
  filename 
)
Returns the status of a file.

Definition at line 854 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GetStatus(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), and upload.SubversionVCS.svnls_cache.

854  def GetStatus(self, filename):
855  """Returns the status of a file."""
856  if not self.options.revision:
857  status = RunShell(["svn", "status", "--ignore-externals", filename])
858  if not status:
859  ErrorExit("svn status returned no output for %s" % filename)
860  status_lines = status.splitlines()
861  # If file is in a cl, the output will begin with
862  # "\n--- Changelist 'cl_name':\n". See
863  # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
864  if (len(status_lines) == 3 and
865  not status_lines[0] and
866  status_lines[1].startswith("--- Changelist")):
867  status = status_lines[2]
868  else:
869  status = status_lines[0]
870  # If we have a revision to diff against we need to run "svn list"
871  # for the old and the new revision and compare the results to get
872  # the correct status for a file.
873  else:
874  dirname, relfilename = os.path.split(filename)
875  if dirname not in self.svnls_cache:
876  cmd = ["svn", "list", "-r", self.rev_start, dirname or "."]
877  out, returncode = RunShellWithReturnCode(cmd)
878  if returncode:
879  ErrorExit("Failed to get status for %s." % filename)
880  old_files = out.splitlines()
881  args = ["svn", "list"]
882  if self.rev_end:
883  args += ["-r", self.rev_end]
884  cmd = args + [dirname or "."]
885  out, returncode = RunShellWithReturnCode(cmd)
886  if returncode:
887  ErrorExit("Failed to run command %s" % cmd)
888  self.svnls_cache[dirname] = (old_files, out.splitlines())
889  old_files, new_files = self.svnls_cache[dirname]
890  if relfilename in old_files and relfilename not in new_files:
891  status = "D "
892  elif relfilename in old_files and relfilename in new_files:
893  status = "M "
894  else:
895  status = "A "
896  return status
897 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GetStatus(self, filename)
Definition: upload.py:854
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def upload.SubversionVCS.GetStatus (   self,
  filename 
)
Returns the status of a file.

Definition at line 854 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GetStatus(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), and upload.SubversionVCS.svnls_cache.

854  def GetStatus(self, filename):
855  """Returns the status of a file."""
856  if not self.options.revision:
857  status = RunShell(["svn", "status", "--ignore-externals", filename])
858  if not status:
859  ErrorExit("svn status returned no output for %s" % filename)
860  status_lines = status.splitlines()
861  # If file is in a cl, the output will begin with
862  # "\n--- Changelist 'cl_name':\n". See
863  # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
864  if (len(status_lines) == 3 and
865  not status_lines[0] and
866  status_lines[1].startswith("--- Changelist")):
867  status = status_lines[2]
868  else:
869  status = status_lines[0]
870  # If we have a revision to diff against we need to run "svn list"
871  # for the old and the new revision and compare the results to get
872  # the correct status for a file.
873  else:
874  dirname, relfilename = os.path.split(filename)
875  if dirname not in self.svnls_cache:
876  cmd = ["svn", "list", "-r", self.rev_start, dirname or "."]
877  out, returncode = RunShellWithReturnCode(cmd)
878  if returncode:
879  ErrorExit("Failed to get status for %s." % filename)
880  old_files = out.splitlines()
881  args = ["svn", "list"]
882  if self.rev_end:
883  args += ["-r", self.rev_end]
884  cmd = args + [dirname or "."]
885  out, returncode = RunShellWithReturnCode(cmd)
886  if returncode:
887  ErrorExit("Failed to run command %s" % cmd)
888  self.svnls_cache[dirname] = (old_files, out.splitlines())
889  old_files, new_files = self.svnls_cache[dirname]
890  if relfilename in old_files and relfilename not in new_files:
891  status = "D "
892  elif relfilename in old_files and relfilename in new_files:
893  status = "M "
894  else:
895  status = "A "
896  return status
897 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GetStatus(self, filename)
Definition: upload.py:854
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def upload.SubversionVCS.GetStatus (   self,
  filename 
)
Returns the status of a file.

Definition at line 854 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GetStatus(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), and upload.SubversionVCS.svnls_cache.

854  def GetStatus(self, filename):
855  """Returns the status of a file."""
856  if not self.options.revision:
857  status = RunShell(["svn", "status", "--ignore-externals", filename])
858  if not status:
859  ErrorExit("svn status returned no output for %s" % filename)
860  status_lines = status.splitlines()
861  # If file is in a cl, the output will begin with
862  # "\n--- Changelist 'cl_name':\n". See
863  # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
864  if (len(status_lines) == 3 and
865  not status_lines[0] and
866  status_lines[1].startswith("--- Changelist")):
867  status = status_lines[2]
868  else:
869  status = status_lines[0]
870  # If we have a revision to diff against we need to run "svn list"
871  # for the old and the new revision and compare the results to get
872  # the correct status for a file.
873  else:
874  dirname, relfilename = os.path.split(filename)
875  if dirname not in self.svnls_cache:
876  cmd = ["svn", "list", "-r", self.rev_start, dirname or "."]
877  out, returncode = RunShellWithReturnCode(cmd)
878  if returncode:
879  ErrorExit("Failed to get status for %s." % filename)
880  old_files = out.splitlines()
881  args = ["svn", "list"]
882  if self.rev_end:
883  args += ["-r", self.rev_end]
884  cmd = args + [dirname or "."]
885  out, returncode = RunShellWithReturnCode(cmd)
886  if returncode:
887  ErrorExit("Failed to run command %s" % cmd)
888  self.svnls_cache[dirname] = (old_files, out.splitlines())
889  old_files, new_files = self.svnls_cache[dirname]
890  if relfilename in old_files and relfilename not in new_files:
891  status = "D "
892  elif relfilename in old_files and relfilename in new_files:
893  status = "M "
894  else:
895  status = "A "
896  return status
897 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GetStatus(self, filename)
Definition: upload.py:854
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def upload.SubversionVCS.GetStatus (   self,
  filename 
)
Returns the status of a file.

Definition at line 854 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), and upload.SubversionVCS.svnls_cache.

Referenced by upload.SubversionVCS.GetBaseFile(), and upload.SubversionVCS.GetStatus().

854  def GetStatus(self, filename):
855  """Returns the status of a file."""
856  if not self.options.revision:
857  status = RunShell(["svn", "status", "--ignore-externals", filename])
858  if not status:
859  ErrorExit("svn status returned no output for %s" % filename)
860  status_lines = status.splitlines()
861  # If file is in a cl, the output will begin with
862  # "\n--- Changelist 'cl_name':\n". See
863  # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
864  if (len(status_lines) == 3 and
865  not status_lines[0] and
866  status_lines[1].startswith("--- Changelist")):
867  status = status_lines[2]
868  else:
869  status = status_lines[0]
870  # If we have a revision to diff against we need to run "svn list"
871  # for the old and the new revision and compare the results to get
872  # the correct status for a file.
873  else:
874  dirname, relfilename = os.path.split(filename)
875  if dirname not in self.svnls_cache:
876  cmd = ["svn", "list", "-r", self.rev_start, dirname or "."]
877  out, returncode = RunShellWithReturnCode(cmd)
878  if returncode:
879  ErrorExit("Failed to get status for %s." % filename)
880  old_files = out.splitlines()
881  args = ["svn", "list"]
882  if self.rev_end:
883  args += ["-r", self.rev_end]
884  cmd = args + [dirname or "."]
885  out, returncode = RunShellWithReturnCode(cmd)
886  if returncode:
887  ErrorExit("Failed to run command %s" % cmd)
888  self.svnls_cache[dirname] = (old_files, out.splitlines())
889  old_files, new_files = self.svnls_cache[dirname]
890  if relfilename in old_files and relfilename not in new_files:
891  status = "D "
892  elif relfilename in old_files and relfilename in new_files:
893  status = "M "
894  else:
895  status = "A "
896  return status
897 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GetStatus(self, filename)
Definition: upload.py:854
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def upload.SubversionVCS.GetStatus (   self,
  filename 
)
Returns the status of a file.

Definition at line 854 of file upload.py.

References upload.ErrorExit(), upload.SubversionVCS.GetStatus(), upload.SubversionVCS.rev_end, upload.SubversionVCS.rev_start, upload.RunShell(), upload.RunShellWithReturnCode(), and upload.SubversionVCS.svnls_cache.

854  def GetStatus(self, filename):
855  """Returns the status of a file."""
856  if not self.options.revision:
857  status = RunShell(["svn", "status", "--ignore-externals", filename])
858  if not status:
859  ErrorExit("svn status returned no output for %s" % filename)
860  status_lines = status.splitlines()
861  # If file is in a cl, the output will begin with
862  # "\n--- Changelist 'cl_name':\n". See
863  # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
864  if (len(status_lines) == 3 and
865  not status_lines[0] and
866  status_lines[1].startswith("--- Changelist")):
867  status = status_lines[2]
868  else:
869  status = status_lines[0]
870  # If we have a revision to diff against we need to run "svn list"
871  # for the old and the new revision and compare the results to get
872  # the correct status for a file.
873  else:
874  dirname, relfilename = os.path.split(filename)
875  if dirname not in self.svnls_cache:
876  cmd = ["svn", "list", "-r", self.rev_start, dirname or "."]
877  out, returncode = RunShellWithReturnCode(cmd)
878  if returncode:
879  ErrorExit("Failed to get status for %s." % filename)
880  old_files = out.splitlines()
881  args = ["svn", "list"]
882  if self.rev_end:
883  args += ["-r", self.rev_end]
884  cmd = args + [dirname or "."]
885  out, returncode = RunShellWithReturnCode(cmd)
886  if returncode:
887  ErrorExit("Failed to run command %s" % cmd)
888  self.svnls_cache[dirname] = (old_files, out.splitlines())
889  old_files, new_files = self.svnls_cache[dirname]
890  if relfilename in old_files and relfilename not in new_files:
891  status = "D "
892  elif relfilename in old_files and relfilename in new_files:
893  status = "M "
894  else:
895  status = "A "
896  return status
897 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def ErrorExit(msg)
Definition: upload.py:109
def GetStatus(self, filename)
Definition: upload.py:854
def RunShellWithReturnCode(command, print_output=False, universal_newlines=True)
Definition: upload.py:542
def upload.SubversionVCS.GetUnknownFiles (   self)

Definition at line 836 of file upload.py.

References upload.SubversionVCS.GetUnknownFiles(), and upload.RunShell().

836  def GetUnknownFiles(self):
837  status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True)
838  unknown_files = []
839  for line in status.split("\n"):
840  if line and line[0] == "?":
841  unknown_files.append(line)
842  return unknown_files
843 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def GetUnknownFiles(self)
Definition: upload.py:836
def upload.SubversionVCS.GetUnknownFiles (   self)

Definition at line 836 of file upload.py.

References upload.RunShell().

Referenced by upload.SubversionVCS.GetUnknownFiles().

836  def GetUnknownFiles(self):
837  status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True)
838  unknown_files = []
839  for line in status.split("\n"):
840  if line and line[0] == "?":
841  unknown_files.append(line)
842  return unknown_files
843 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def GetUnknownFiles(self)
Definition: upload.py:836
def upload.SubversionVCS.GetUnknownFiles (   self)

Definition at line 836 of file upload.py.

References upload.SubversionVCS.GetUnknownFiles(), and upload.RunShell().

836  def GetUnknownFiles(self):
837  status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True)
838  unknown_files = []
839  for line in status.split("\n"):
840  if line and line[0] == "?":
841  unknown_files.append(line)
842  return unknown_files
843 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def GetUnknownFiles(self)
Definition: upload.py:836
def upload.SubversionVCS.GetUnknownFiles (   self)

Definition at line 836 of file upload.py.

References upload.SubversionVCS.GetUnknownFiles(), and upload.RunShell().

836  def GetUnknownFiles(self):
837  status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True)
838  unknown_files = []
839  for line in status.split("\n"):
840  if line and line[0] == "?":
841  unknown_files.append(line)
842  return unknown_files
843 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def GetUnknownFiles(self)
Definition: upload.py:836
def upload.SubversionVCS.GetUnknownFiles (   self)

Definition at line 836 of file upload.py.

References upload.SubversionVCS.GetUnknownFiles(), and upload.RunShell().

836  def GetUnknownFiles(self):
837  status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True)
838  unknown_files = []
839  for line in status.split("\n"):
840  if line and line[0] == "?":
841  unknown_files.append(line)
842  return unknown_files
843 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def GetUnknownFiles(self)
Definition: upload.py:836
def upload.SubversionVCS.GetUnknownFiles (   self)

Definition at line 836 of file upload.py.

References upload.SubversionVCS.GetUnknownFiles(), and upload.RunShell().

836  def GetUnknownFiles(self):
837  status = RunShell(["svn", "status", "--ignore-externals"], silent_ok=True)
838  unknown_files = []
839  for line in status.split("\n"):
840  if line and line[0] == "?":
841  unknown_files.append(line)
842  return unknown_files
843 
def RunShell(command, silent_ok=False, universal_newlines=True, print_output=False)
Definition: upload.py:578
def GetUnknownFiles(self)
Definition: upload.py:836
def upload.SubversionVCS.GuessBase (   self,
  required 
)
Wrapper for _GuessBase.

Definition at line 742 of file upload.py.

References upload.SubversionVCS.GuessBase(), and upload.SubversionVCS.svn_base.

742  def GuessBase(self, required):
743  """Wrapper for _GuessBase."""
744  return self.svn_base
745 
def GuessBase(self, required)
Definition: upload.py:742
def upload.SubversionVCS.GuessBase (   self,
  required 
)
Wrapper for _GuessBase.

Definition at line 742 of file upload.py.

References upload.SubversionVCS.svn_base.

Referenced by upload.SubversionVCS.GuessBase().

742  def GuessBase(self, required):
743  """Wrapper for _GuessBase."""
744  return self.svn_base
745 
def GuessBase(self, required)
Definition: upload.py:742
def upload.SubversionVCS.GuessBase (   self,
  required 
)
Wrapper for _GuessBase.

Definition at line 742 of file upload.py.

References upload.SubversionVCS.GuessBase(), and upload.SubversionVCS.svn_base.

742  def GuessBase(self, required):
743  """Wrapper for _GuessBase."""
744  return self.svn_base
745 
def GuessBase(self, required)
Definition: upload.py:742
def upload.SubversionVCS.GuessBase (   self,
  required 
)
Wrapper for _GuessBase.

Definition at line 742 of file upload.py.

References upload.SubversionVCS.GuessBase(), and upload.SubversionVCS.svn_base.

742  def GuessBase(self, required):
743  """Wrapper for _GuessBase."""
744  return self.svn_base
745 
def GuessBase(self, required)
Definition: upload.py:742
def upload.SubversionVCS.GuessBase (   self,
  required 
)
Wrapper for _GuessBase.

Definition at line 742 of file upload.py.

References upload.SubversionVCS.GuessBase(), and upload.SubversionVCS.svn_base.

742  def GuessBase(self, required):
743  """Wrapper for _GuessBase."""
744  return self.svn_base
745 
def GuessBase(self, required)
Definition: upload.py:742
def upload.SubversionVCS.GuessBase (   self,
  required 
)
Wrapper for _GuessBase.

Definition at line 742 of file upload.py.

References upload.SubversionVCS.GuessBase(), and upload.SubversionVCS.svn_base.

742  def GuessBase(self, required):
743  """Wrapper for _GuessBase."""
744  return self.svn_base
745 
def GuessBase(self, required)
Definition: upload.py:742
def upload.SubversionVCS.ReadFile (   self,
  filename 
)
Returns the contents of a file.

Definition at line 844 of file upload.py.

References upload.SubversionVCS.ReadFile().

844  def ReadFile(self, filename):
845  """Returns the contents of a file."""
846  file = open(filename, 'rb')
847  result = ""
848  try:
849  result = file.read()
850  finally:
851  file.close()
852  return result
853 
def ReadFile(self, filename)
Definition: upload.py:844
def upload.SubversionVCS.ReadFile (   self,
  filename 
)
Returns the contents of a file.

Definition at line 844 of file upload.py.

References upload.SubversionVCS.ReadFile().

844  def ReadFile(self, filename):
845  """Returns the contents of a file."""
846  file = open(filename, 'rb')
847  result = ""
848  try:
849  result = file.read()
850  finally:
851  file.close()
852  return result
853 
def ReadFile(self, filename)
Definition: upload.py:844
def upload.SubversionVCS.ReadFile (   self,
  filename 
)
Returns the contents of a file.

Definition at line 844 of file upload.py.

References upload.SubversionVCS.ReadFile().

844  def ReadFile(self, filename):
845  """Returns the contents of a file."""
846  file = open(filename, 'rb')
847  result = ""
848  try:
849  result = file.read()
850  finally:
851  file.close()
852  return result
853 
def ReadFile(self, filename)
Definition: upload.py:844
def upload.SubversionVCS.ReadFile (   self,
  filename 
)
Returns the contents of a file.

Definition at line 844 of file upload.py.

Referenced by upload.SubversionVCS.GetBaseFile(), and upload.SubversionVCS.ReadFile().

844  def ReadFile(self, filename):
845  """Returns the contents of a file."""
846  file = open(filename, 'rb')
847  result = ""
848  try:
849  result = file.read()
850  finally:
851  file.close()
852  return result
853 
def ReadFile(self, filename)
Definition: upload.py:844
def upload.SubversionVCS.ReadFile (   self,
  filename 
)
Returns the contents of a file.

Definition at line 844 of file upload.py.

References upload.SubversionVCS.ReadFile().

844  def ReadFile(self, filename):
845  """Returns the contents of a file."""
846  file = open(filename, 'rb')
847  result = ""
848  try:
849  result = file.read()
850  finally:
851  file.close()
852  return result
853 
def ReadFile(self, filename)
Definition: upload.py:844
def upload.SubversionVCS.ReadFile (   self,
  filename 
)
Returns the contents of a file.

Definition at line 844 of file upload.py.

References upload.SubversionVCS.ReadFile().

844  def ReadFile(self, filename):
845  """Returns the contents of a file."""
846  file = open(filename, 'rb')
847  result = ""
848  try:
849  result = file.read()
850  finally:
851  file.close()
852  return result
853 
def ReadFile(self, filename)
Definition: upload.py:844

Member Data Documentation

upload.SubversionVCS.rev_end
upload.SubversionVCS.rev_start
upload.SubversionVCS.svn_base
upload.SubversionVCS.svnls_cache

Definition at line 736 of file upload.py.

Referenced by upload.SubversionVCS.__init__(), and upload.SubversionVCS.GetStatus().


The documentation for this class was generated from the following file: