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

Public Member Functions

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

 options
 

Detailed Description

Abstract base class providing an interface to the VCS.

Definition at line 588 of file upload.py.

Constructor & Destructor Documentation

def upload.VersionControlSystem.__init__ (   self,
  options 
)
Constructor.

Args:
  options: Command line options.

Definition at line 591 of file upload.py.

Referenced by upload.VersionControlSystem.__init__().

591  def __init__(self, options):
592  """Constructor.
593 
594  Args:
595  options: Command line options.
596  """
597  self.options = options
598 
def __init__(self, options)
Definition: upload.py:591
def upload.VersionControlSystem.__init__ (   self,
  options 
)
Constructor.

Args:
  options: Command line options.

Definition at line 591 of file upload.py.

References upload.VersionControlSystem.__init__(), and upload.VersionControlSystem.options.

591  def __init__(self, options):
592  """Constructor.
593 
594  Args:
595  options: Command line options.
596  """
597  self.options = options
598 
def __init__(self, options)
Definition: upload.py:591
def upload.VersionControlSystem.__init__ (   self,
  options 
)
Constructor.

Args:
  options: Command line options.

Definition at line 591 of file upload.py.

References upload.VersionControlSystem.__init__(), and upload.VersionControlSystem.options.

591  def __init__(self, options):
592  """Constructor.
593 
594  Args:
595  options: Command line options.
596  """
597  self.options = options
598 
def __init__(self, options)
Definition: upload.py:591
def upload.VersionControlSystem.__init__ (   self,
  options 
)
Constructor.

Args:
  options: Command line options.

Definition at line 591 of file upload.py.

References upload.VersionControlSystem.__init__(), and upload.VersionControlSystem.options.

591  def __init__(self, options):
592  """Constructor.
593 
594  Args:
595  options: Command line options.
596  """
597  self.options = options
598 
def __init__(self, options)
Definition: upload.py:591
def upload.VersionControlSystem.__init__ (   self,
  options 
)
Constructor.

Args:
  options: Command line options.

Definition at line 591 of file upload.py.

References upload.VersionControlSystem.__init__(), and upload.VersionControlSystem.options.

591  def __init__(self, options):
592  """Constructor.
593 
594  Args:
595  options: Command line options.
596  """
597  self.options = options
598 
def __init__(self, options)
Definition: upload.py:591
def upload.VersionControlSystem.__init__ (   self,
  options 
)
Constructor.

Args:
  options: Command line options.

Definition at line 591 of file upload.py.

References upload.VersionControlSystem.__init__(), and upload.VersionControlSystem.options.

591  def __init__(self, options):
592  """Constructor.
593 
594  Args:
595  options: Command line options.
596  """
597  self.options = options
598 
def __init__(self, options)
Definition: upload.py:591

Member Function Documentation

def upload.VersionControlSystem.CheckForUnknownFiles (   self)
Show an "are you sure?" prompt if there are unknown files.

Definition at line 613 of file upload.py.

References upload.ErrorExit(), upload.VersionControlSystem.GetUnknownFiles(), and folly::detail::distributed_mutex.strip().

Referenced by upload.VersionControlSystem.CheckForUnknownFiles().

614  """Show an "are you sure?" prompt if there are unknown files."""
615  unknown_files = self.GetUnknownFiles()
616  if unknown_files:
617  print "The following files are not added to version control:"
618  for line in unknown_files:
619  print line
620  prompt = "Are you sure to continue?(y/N) "
621  answer = raw_input(prompt).strip()
622  if answer != "y":
623  ErrorExit("User aborted")
624 
def ErrorExit(msg)
Definition: upload.py:109
std::uint64_t strip(std::chrono::nanoseconds t)
def CheckForUnknownFiles(self)
Definition: upload.py:613
def upload.VersionControlSystem.CheckForUnknownFiles (   self)
Show an "are you sure?" prompt if there are unknown files.

Definition at line 613 of file upload.py.

References upload.VersionControlSystem.CheckForUnknownFiles(), upload.ErrorExit(), upload.VersionControlSystem.GetUnknownFiles(), and folly::detail::distributed_mutex.strip().

614  """Show an "are you sure?" prompt if there are unknown files."""
615  unknown_files = self.GetUnknownFiles()
616  if unknown_files:
617  print "The following files are not added to version control:"
618  for line in unknown_files:
619  print line
620  prompt = "Are you sure to continue?(y/N) "
621  answer = raw_input(prompt).strip()
622  if answer != "y":
623  ErrorExit("User aborted")
624 
def ErrorExit(msg)
Definition: upload.py:109
std::uint64_t strip(std::chrono::nanoseconds t)
def CheckForUnknownFiles(self)
Definition: upload.py:613
def upload.VersionControlSystem.CheckForUnknownFiles (   self)
Show an "are you sure?" prompt if there are unknown files.

Definition at line 613 of file upload.py.

References upload.VersionControlSystem.CheckForUnknownFiles(), upload.ErrorExit(), upload.VersionControlSystem.GetUnknownFiles(), and folly::detail::distributed_mutex.strip().

614  """Show an "are you sure?" prompt if there are unknown files."""
615  unknown_files = self.GetUnknownFiles()
616  if unknown_files:
617  print "The following files are not added to version control:"
618  for line in unknown_files:
619  print line
620  prompt = "Are you sure to continue?(y/N) "
621  answer = raw_input(prompt).strip()
622  if answer != "y":
623  ErrorExit("User aborted")
624 
def ErrorExit(msg)
Definition: upload.py:109
std::uint64_t strip(std::chrono::nanoseconds t)
def CheckForUnknownFiles(self)
Definition: upload.py:613
def upload.VersionControlSystem.CheckForUnknownFiles (   self)
Show an "are you sure?" prompt if there are unknown files.

Definition at line 613 of file upload.py.

References upload.VersionControlSystem.CheckForUnknownFiles(), upload.ErrorExit(), upload.VersionControlSystem.GetUnknownFiles(), and folly::detail::distributed_mutex.strip().

614  """Show an "are you sure?" prompt if there are unknown files."""
615  unknown_files = self.GetUnknownFiles()
616  if unknown_files:
617  print "The following files are not added to version control:"
618  for line in unknown_files:
619  print line
620  prompt = "Are you sure to continue?(y/N) "
621  answer = raw_input(prompt).strip()
622  if answer != "y":
623  ErrorExit("User aborted")
624 
def ErrorExit(msg)
Definition: upload.py:109
std::uint64_t strip(std::chrono::nanoseconds t)
def CheckForUnknownFiles(self)
Definition: upload.py:613
def upload.VersionControlSystem.CheckForUnknownFiles (   self)
Show an "are you sure?" prompt if there are unknown files.

Definition at line 613 of file upload.py.

References upload.VersionControlSystem.CheckForUnknownFiles(), upload.ErrorExit(), upload.VersionControlSystem.GetUnknownFiles(), and folly::detail::distributed_mutex.strip().

614  """Show an "are you sure?" prompt if there are unknown files."""
615  unknown_files = self.GetUnknownFiles()
616  if unknown_files:
617  print "The following files are not added to version control:"
618  for line in unknown_files:
619  print line
620  prompt = "Are you sure to continue?(y/N) "
621  answer = raw_input(prompt).strip()
622  if answer != "y":
623  ErrorExit("User aborted")
624 
def ErrorExit(msg)
Definition: upload.py:109
std::uint64_t strip(std::chrono::nanoseconds t)
def CheckForUnknownFiles(self)
Definition: upload.py:613
def upload.VersionControlSystem.CheckForUnknownFiles (   self)
Show an "are you sure?" prompt if there are unknown files.

Definition at line 613 of file upload.py.

References upload.VersionControlSystem.CheckForUnknownFiles(), upload.ErrorExit(), upload.VersionControlSystem.GetUnknownFiles(), and folly::detail::distributed_mutex.strip().

614  """Show an "are you sure?" prompt if there are unknown files."""
615  unknown_files = self.GetUnknownFiles()
616  if unknown_files:
617  print "The following files are not added to version control:"
618  for line in unknown_files:
619  print line
620  prompt = "Are you sure to continue?(y/N) "
621  answer = raw_input(prompt).strip()
622  if answer != "y":
623  ErrorExit("User aborted")
624 
def ErrorExit(msg)
Definition: upload.py:109
std::uint64_t strip(std::chrono::nanoseconds t)
def CheckForUnknownFiles(self)
Definition: upload.py:613
def upload.VersionControlSystem.GenerateDiff (   self,
  args 
)
Return the current diff as a string.

Args:
  args: Extra arguments to pass to the diff command.

Definition at line 599 of file upload.py.

References upload.VersionControlSystem.GenerateDiff().

599  def GenerateDiff(self, args):
600  """Return the current diff as a string.
601 
602  Args:
603  args: Extra arguments to pass to the diff command.
604  """
605  raise NotImplementedError(
606  "abstract method -- subclass %s must override" % self.__class__)
607 
def GenerateDiff(self, args)
Definition: upload.py:599
def upload.VersionControlSystem.GenerateDiff (   self,
  args 
)
Return the current diff as a string.

Args:
  args: Extra arguments to pass to the diff command.

Definition at line 599 of file upload.py.

References upload.VersionControlSystem.GenerateDiff().

599  def GenerateDiff(self, args):
600  """Return the current diff as a string.
601 
602  Args:
603  args: Extra arguments to pass to the diff command.
604  """
605  raise NotImplementedError(
606  "abstract method -- subclass %s must override" % self.__class__)
607 
def GenerateDiff(self, args)
Definition: upload.py:599
def upload.VersionControlSystem.GenerateDiff (   self,
  args 
)
Return the current diff as a string.

Args:
  args: Extra arguments to pass to the diff command.

Definition at line 599 of file upload.py.

References upload.VersionControlSystem.GenerateDiff().

599  def GenerateDiff(self, args):
600  """Return the current diff as a string.
601 
602  Args:
603  args: Extra arguments to pass to the diff command.
604  """
605  raise NotImplementedError(
606  "abstract method -- subclass %s must override" % self.__class__)
607 
def GenerateDiff(self, args)
Definition: upload.py:599
def upload.VersionControlSystem.GenerateDiff (   self,
  args 
)
Return the current diff as a string.

Args:
  args: Extra arguments to pass to the diff command.

Definition at line 599 of file upload.py.

Referenced by upload.VersionControlSystem.GenerateDiff().

599  def GenerateDiff(self, args):
600  """Return the current diff as a string.
601 
602  Args:
603  args: Extra arguments to pass to the diff command.
604  """
605  raise NotImplementedError(
606  "abstract method -- subclass %s must override" % self.__class__)
607 
def GenerateDiff(self, args)
Definition: upload.py:599
def upload.VersionControlSystem.GenerateDiff (   self,
  args 
)
Return the current diff as a string.

Args:
  args: Extra arguments to pass to the diff command.

Definition at line 599 of file upload.py.

References upload.VersionControlSystem.GenerateDiff().

599  def GenerateDiff(self, args):
600  """Return the current diff as a string.
601 
602  Args:
603  args: Extra arguments to pass to the diff command.
604  """
605  raise NotImplementedError(
606  "abstract method -- subclass %s must override" % self.__class__)
607 
def GenerateDiff(self, args)
Definition: upload.py:599
def upload.VersionControlSystem.GenerateDiff (   self,
  args 
)
Return the current diff as a string.

Args:
  args: Extra arguments to pass to the diff command.

Definition at line 599 of file upload.py.

References upload.VersionControlSystem.GenerateDiff().

599  def GenerateDiff(self, args):
600  """Return the current diff as a string.
601 
602  Args:
603  args: Extra arguments to pass to the diff command.
604  """
605  raise NotImplementedError(
606  "abstract method -- subclass %s must override" % self.__class__)
607 
def GenerateDiff(self, args)
Definition: upload.py:599
def upload.VersionControlSystem.GetBaseFile (   self,
  filename 
)
Get the content of the upstream version of a file.

Returns:
  A tuple (base_content, new_content, is_binary, status)
base_content: The contents of the base file.
new_content: For text files, this is empty.  For binary files, this is
  the contents of the new file, since the diff output won't contain
  information to reconstruct the current file.
is_binary: True iff the file is binary.
status: The status of the file.

Definition at line 625 of file upload.py.

Referenced by upload.VersionControlSystem.GetBaseFile(), and upload.VersionControlSystem.GetBaseFiles().

625  def GetBaseFile(self, filename):
626  """Get the content of the upstream version of a file.
627 
628  Returns:
629  A tuple (base_content, new_content, is_binary, status)
630  base_content: The contents of the base file.
631  new_content: For text files, this is empty. For binary files, this is
632  the contents of the new file, since the diff output won't contain
633  information to reconstruct the current file.
634  is_binary: True iff the file is binary.
635  status: The status of the file.
636  """
637 
638  raise NotImplementedError(
639  "abstract method -- subclass %s must override" % self.__class__)
640 
641 
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFile (   self,
  filename 
)
Get the content of the upstream version of a file.

Returns:
  A tuple (base_content, new_content, is_binary, status)
base_content: The contents of the base file.
new_content: For text files, this is empty.  For binary files, this is
  the contents of the new file, since the diff output won't contain
  information to reconstruct the current file.
is_binary: True iff the file is binary.
status: The status of the file.

Definition at line 625 of file upload.py.

References upload.VersionControlSystem.GetBaseFile().

625  def GetBaseFile(self, filename):
626  """Get the content of the upstream version of a file.
627 
628  Returns:
629  A tuple (base_content, new_content, is_binary, status)
630  base_content: The contents of the base file.
631  new_content: For text files, this is empty. For binary files, this is
632  the contents of the new file, since the diff output won't contain
633  information to reconstruct the current file.
634  is_binary: True iff the file is binary.
635  status: The status of the file.
636  """
637 
638  raise NotImplementedError(
639  "abstract method -- subclass %s must override" % self.__class__)
640 
641 
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFile (   self,
  filename 
)
Get the content of the upstream version of a file.

Returns:
  A tuple (base_content, new_content, is_binary, status)
base_content: The contents of the base file.
new_content: For text files, this is empty.  For binary files, this is
  the contents of the new file, since the diff output won't contain
  information to reconstruct the current file.
is_binary: True iff the file is binary.
status: The status of the file.

Definition at line 625 of file upload.py.

References upload.VersionControlSystem.GetBaseFile().

625  def GetBaseFile(self, filename):
626  """Get the content of the upstream version of a file.
627 
628  Returns:
629  A tuple (base_content, new_content, is_binary, status)
630  base_content: The contents of the base file.
631  new_content: For text files, this is empty. For binary files, this is
632  the contents of the new file, since the diff output won't contain
633  information to reconstruct the current file.
634  is_binary: True iff the file is binary.
635  status: The status of the file.
636  """
637 
638  raise NotImplementedError(
639  "abstract method -- subclass %s must override" % self.__class__)
640 
641 
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFile (   self,
  filename 
)
Get the content of the upstream version of a file.

Returns:
  A tuple (base_content, new_content, is_binary, status)
base_content: The contents of the base file.
new_content: For text files, this is empty.  For binary files, this is
  the contents of the new file, since the diff output won't contain
  information to reconstruct the current file.
is_binary: True iff the file is binary.
status: The status of the file.

Definition at line 625 of file upload.py.

References upload.VersionControlSystem.GetBaseFile().

625  def GetBaseFile(self, filename):
626  """Get the content of the upstream version of a file.
627 
628  Returns:
629  A tuple (base_content, new_content, is_binary, status)
630  base_content: The contents of the base file.
631  new_content: For text files, this is empty. For binary files, this is
632  the contents of the new file, since the diff output won't contain
633  information to reconstruct the current file.
634  is_binary: True iff the file is binary.
635  status: The status of the file.
636  """
637 
638  raise NotImplementedError(
639  "abstract method -- subclass %s must override" % self.__class__)
640 
641 
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFile (   self,
  filename 
)
Get the content of the upstream version of a file.

Returns:
  A tuple (base_content, new_content, is_binary, status)
base_content: The contents of the base file.
new_content: For text files, this is empty.  For binary files, this is
  the contents of the new file, since the diff output won't contain
  information to reconstruct the current file.
is_binary: True iff the file is binary.
status: The status of the file.

Definition at line 625 of file upload.py.

References upload.VersionControlSystem.GetBaseFile().

625  def GetBaseFile(self, filename):
626  """Get the content of the upstream version of a file.
627 
628  Returns:
629  A tuple (base_content, new_content, is_binary, status)
630  base_content: The contents of the base file.
631  new_content: For text files, this is empty. For binary files, this is
632  the contents of the new file, since the diff output won't contain
633  information to reconstruct the current file.
634  is_binary: True iff the file is binary.
635  status: The status of the file.
636  """
637 
638  raise NotImplementedError(
639  "abstract method -- subclass %s must override" % self.__class__)
640 
641 
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFile (   self,
  filename 
)
Get the content of the upstream version of a file.

Returns:
  A tuple (base_content, new_content, is_binary, status)
base_content: The contents of the base file.
new_content: For text files, this is empty.  For binary files, this is
  the contents of the new file, since the diff output won't contain
  information to reconstruct the current file.
is_binary: True iff the file is binary.
status: The status of the file.

Definition at line 625 of file upload.py.

References upload.VersionControlSystem.GetBaseFile().

625  def GetBaseFile(self, filename):
626  """Get the content of the upstream version of a file.
627 
628  Returns:
629  A tuple (base_content, new_content, is_binary, status)
630  base_content: The contents of the base file.
631  new_content: For text files, this is empty. For binary files, this is
632  the contents of the new file, since the diff output won't contain
633  information to reconstruct the current file.
634  is_binary: True iff the file is binary.
635  status: The status of the file.
636  """
637 
638  raise NotImplementedError(
639  "abstract method -- subclass %s must override" % self.__class__)
640 
641 
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFiles (   self,
  diff 
)
Helper that calls GetBase file for each file in the patch.

Returns:
  A dictionary that maps from filename to GetBaseFile's tuple.  Filenames
  are retrieved based on lines that start with "Index:" or
  "Property changes on:".

Definition at line 642 of file upload.py.

References upload.VersionControlSystem.GetBaseFile(), upload.VersionControlSystem.GetBaseFiles(), replace(), and upload.VersionControlSystem.UploadBaseFiles().

642  def GetBaseFiles(self, diff):
643  """Helper that calls GetBase file for each file in the patch.
644 
645  Returns:
646  A dictionary that maps from filename to GetBaseFile's tuple. Filenames
647  are retrieved based on lines that start with "Index:" or
648  "Property changes on:".
649  """
650  files = {}
651  for line in diff.splitlines(True):
652  if line.startswith('Index:') or line.startswith('Property changes on:'):
653  unused, filename = line.split(':', 1)
654  # On Windows if a file has property changes its filename uses '\'
655  # instead of '/'.
656  filename = filename.strip().replace('\\', '/')
657  files[filename] = self.GetBaseFile(filename)
658  return files
659 
660 
def GetBaseFiles(self, diff)
Definition: upload.py:642
void BENCHFUN() replace(size_t iters, size_t arg)
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFiles (   self,
  diff 
)
Helper that calls GetBase file for each file in the patch.

Returns:
  A dictionary that maps from filename to GetBaseFile's tuple.  Filenames
  are retrieved based on lines that start with "Index:" or
  "Property changes on:".

Definition at line 642 of file upload.py.

References upload.VersionControlSystem.GetBaseFile(), replace(), and upload.VersionControlSystem.UploadBaseFiles().

Referenced by upload.VersionControlSystem.GetBaseFiles().

642  def GetBaseFiles(self, diff):
643  """Helper that calls GetBase file for each file in the patch.
644 
645  Returns:
646  A dictionary that maps from filename to GetBaseFile's tuple. Filenames
647  are retrieved based on lines that start with "Index:" or
648  "Property changes on:".
649  """
650  files = {}
651  for line in diff.splitlines(True):
652  if line.startswith('Index:') or line.startswith('Property changes on:'):
653  unused, filename = line.split(':', 1)
654  # On Windows if a file has property changes its filename uses '\'
655  # instead of '/'.
656  filename = filename.strip().replace('\\', '/')
657  files[filename] = self.GetBaseFile(filename)
658  return files
659 
660 
def GetBaseFiles(self, diff)
Definition: upload.py:642
void BENCHFUN() replace(size_t iters, size_t arg)
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFiles (   self,
  diff 
)
Helper that calls GetBase file for each file in the patch.

Returns:
  A dictionary that maps from filename to GetBaseFile's tuple.  Filenames
  are retrieved based on lines that start with "Index:" or
  "Property changes on:".

Definition at line 642 of file upload.py.

References upload.VersionControlSystem.GetBaseFile(), upload.VersionControlSystem.GetBaseFiles(), replace(), and upload.VersionControlSystem.UploadBaseFiles().

642  def GetBaseFiles(self, diff):
643  """Helper that calls GetBase file for each file in the patch.
644 
645  Returns:
646  A dictionary that maps from filename to GetBaseFile's tuple. Filenames
647  are retrieved based on lines that start with "Index:" or
648  "Property changes on:".
649  """
650  files = {}
651  for line in diff.splitlines(True):
652  if line.startswith('Index:') or line.startswith('Property changes on:'):
653  unused, filename = line.split(':', 1)
654  # On Windows if a file has property changes its filename uses '\'
655  # instead of '/'.
656  filename = filename.strip().replace('\\', '/')
657  files[filename] = self.GetBaseFile(filename)
658  return files
659 
660 
def GetBaseFiles(self, diff)
Definition: upload.py:642
void BENCHFUN() replace(size_t iters, size_t arg)
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFiles (   self,
  diff 
)
Helper that calls GetBase file for each file in the patch.

Returns:
  A dictionary that maps from filename to GetBaseFile's tuple.  Filenames
  are retrieved based on lines that start with "Index:" or
  "Property changes on:".

Definition at line 642 of file upload.py.

References upload.VersionControlSystem.GetBaseFile(), upload.VersionControlSystem.GetBaseFiles(), replace(), and upload.VersionControlSystem.UploadBaseFiles().

642  def GetBaseFiles(self, diff):
643  """Helper that calls GetBase file for each file in the patch.
644 
645  Returns:
646  A dictionary that maps from filename to GetBaseFile's tuple. Filenames
647  are retrieved based on lines that start with "Index:" or
648  "Property changes on:".
649  """
650  files = {}
651  for line in diff.splitlines(True):
652  if line.startswith('Index:') or line.startswith('Property changes on:'):
653  unused, filename = line.split(':', 1)
654  # On Windows if a file has property changes its filename uses '\'
655  # instead of '/'.
656  filename = filename.strip().replace('\\', '/')
657  files[filename] = self.GetBaseFile(filename)
658  return files
659 
660 
def GetBaseFiles(self, diff)
Definition: upload.py:642
void BENCHFUN() replace(size_t iters, size_t arg)
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFiles (   self,
  diff 
)
Helper that calls GetBase file for each file in the patch.

Returns:
  A dictionary that maps from filename to GetBaseFile's tuple.  Filenames
  are retrieved based on lines that start with "Index:" or
  "Property changes on:".

Definition at line 642 of file upload.py.

References upload.VersionControlSystem.GetBaseFile(), upload.VersionControlSystem.GetBaseFiles(), replace(), and upload.VersionControlSystem.UploadBaseFiles().

642  def GetBaseFiles(self, diff):
643  """Helper that calls GetBase file for each file in the patch.
644 
645  Returns:
646  A dictionary that maps from filename to GetBaseFile's tuple. Filenames
647  are retrieved based on lines that start with "Index:" or
648  "Property changes on:".
649  """
650  files = {}
651  for line in diff.splitlines(True):
652  if line.startswith('Index:') or line.startswith('Property changes on:'):
653  unused, filename = line.split(':', 1)
654  # On Windows if a file has property changes its filename uses '\'
655  # instead of '/'.
656  filename = filename.strip().replace('\\', '/')
657  files[filename] = self.GetBaseFile(filename)
658  return files
659 
660 
def GetBaseFiles(self, diff)
Definition: upload.py:642
void BENCHFUN() replace(size_t iters, size_t arg)
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetBaseFiles (   self,
  diff 
)
Helper that calls GetBase file for each file in the patch.

Returns:
  A dictionary that maps from filename to GetBaseFile's tuple.  Filenames
  are retrieved based on lines that start with "Index:" or
  "Property changes on:".

Definition at line 642 of file upload.py.

References upload.VersionControlSystem.GetBaseFile(), upload.VersionControlSystem.GetBaseFiles(), replace(), and upload.VersionControlSystem.UploadBaseFiles().

642  def GetBaseFiles(self, diff):
643  """Helper that calls GetBase file for each file in the patch.
644 
645  Returns:
646  A dictionary that maps from filename to GetBaseFile's tuple. Filenames
647  are retrieved based on lines that start with "Index:" or
648  "Property changes on:".
649  """
650  files = {}
651  for line in diff.splitlines(True):
652  if line.startswith('Index:') or line.startswith('Property changes on:'):
653  unused, filename = line.split(':', 1)
654  # On Windows if a file has property changes its filename uses '\'
655  # instead of '/'.
656  filename = filename.strip().replace('\\', '/')
657  files[filename] = self.GetBaseFile(filename)
658  return files
659 
660 
def GetBaseFiles(self, diff)
Definition: upload.py:642
void BENCHFUN() replace(size_t iters, size_t arg)
def GetBaseFile(self, filename)
Definition: upload.py:625
def upload.VersionControlSystem.GetUnknownFiles (   self)
Return a list of files unknown to the VCS.

Definition at line 608 of file upload.py.

References upload.VersionControlSystem.GetUnknownFiles().

608  def GetUnknownFiles(self):
609  """Return a list of files unknown to the VCS."""
610  raise NotImplementedError(
611  "abstract method -- subclass %s must override" % self.__class__)
612 
def upload.VersionControlSystem.GetUnknownFiles (   self)
Return a list of files unknown to the VCS.

Definition at line 608 of file upload.py.

Referenced by upload.VersionControlSystem.CheckForUnknownFiles(), and upload.VersionControlSystem.GetUnknownFiles().

608  def GetUnknownFiles(self):
609  """Return a list of files unknown to the VCS."""
610  raise NotImplementedError(
611  "abstract method -- subclass %s must override" % self.__class__)
612 
def upload.VersionControlSystem.GetUnknownFiles (   self)
Return a list of files unknown to the VCS.

Definition at line 608 of file upload.py.

References upload.VersionControlSystem.GetUnknownFiles().

608  def GetUnknownFiles(self):
609  """Return a list of files unknown to the VCS."""
610  raise NotImplementedError(
611  "abstract method -- subclass %s must override" % self.__class__)
612 
def upload.VersionControlSystem.GetUnknownFiles (   self)
Return a list of files unknown to the VCS.

Definition at line 608 of file upload.py.

References upload.VersionControlSystem.GetUnknownFiles().

608  def GetUnknownFiles(self):
609  """Return a list of files unknown to the VCS."""
610  raise NotImplementedError(
611  "abstract method -- subclass %s must override" % self.__class__)
612 
def upload.VersionControlSystem.GetUnknownFiles (   self)
Return a list of files unknown to the VCS.

Definition at line 608 of file upload.py.

References upload.VersionControlSystem.GetUnknownFiles().

608  def GetUnknownFiles(self):
609  """Return a list of files unknown to the VCS."""
610  raise NotImplementedError(
611  "abstract method -- subclass %s must override" % self.__class__)
612 
def upload.VersionControlSystem.GetUnknownFiles (   self)
Return a list of files unknown to the VCS.

Definition at line 608 of file upload.py.

References upload.VersionControlSystem.GetUnknownFiles().

608  def GetUnknownFiles(self):
609  """Return a list of files unknown to the VCS."""
610  raise NotImplementedError(
611  "abstract method -- subclass %s must override" % self.__class__)
612 
def upload.VersionControlSystem.IsImage (   self,
  filename 
)
Returns true if the filename has an image extension.

Definition at line 713 of file upload.py.

Referenced by upload.SubversionVCS.GetBaseFile(), upload.MercurialVCS.GetBaseFile(), and upload.VersionControlSystem.IsImage().

713  def IsImage(self, filename):
714  """Returns true if the filename has an image extension."""
715  mimetype = mimetypes.guess_type(filename)[0]
716  if not mimetype:
717  return False
718  return mimetype.startswith("image/")
719 
720 
def IsImage(self, filename)
Definition: upload.py:713
def upload.VersionControlSystem.IsImage (   self,
  filename 
)
Returns true if the filename has an image extension.

Definition at line 713 of file upload.py.

References upload.VersionControlSystem.IsImage().

713  def IsImage(self, filename):
714  """Returns true if the filename has an image extension."""
715  mimetype = mimetypes.guess_type(filename)[0]
716  if not mimetype:
717  return False
718  return mimetype.startswith("image/")
719 
720 
def IsImage(self, filename)
Definition: upload.py:713
def upload.VersionControlSystem.IsImage (   self,
  filename 
)
Returns true if the filename has an image extension.

Definition at line 713 of file upload.py.

References upload.VersionControlSystem.IsImage().

713  def IsImage(self, filename):
714  """Returns true if the filename has an image extension."""
715  mimetype = mimetypes.guess_type(filename)[0]
716  if not mimetype:
717  return False
718  return mimetype.startswith("image/")
719 
720 
def IsImage(self, filename)
Definition: upload.py:713
def upload.VersionControlSystem.IsImage (   self,
  filename 
)
Returns true if the filename has an image extension.

Definition at line 713 of file upload.py.

References upload.VersionControlSystem.IsImage().

713  def IsImage(self, filename):
714  """Returns true if the filename has an image extension."""
715  mimetype = mimetypes.guess_type(filename)[0]
716  if not mimetype:
717  return False
718  return mimetype.startswith("image/")
719 
720 
def IsImage(self, filename)
Definition: upload.py:713
def upload.VersionControlSystem.IsImage (   self,
  filename 
)
Returns true if the filename has an image extension.

Definition at line 713 of file upload.py.

References upload.VersionControlSystem.IsImage().

713  def IsImage(self, filename):
714  """Returns true if the filename has an image extension."""
715  mimetype = mimetypes.guess_type(filename)[0]
716  if not mimetype:
717  return False
718  return mimetype.startswith("image/")
719 
720 
def IsImage(self, filename)
Definition: upload.py:713
def upload.VersionControlSystem.IsImage (   self,
  filename 
)
Returns true if the filename has an image extension.

Definition at line 713 of file upload.py.

References upload.VersionControlSystem.IsImage().

713  def IsImage(self, filename):
714  """Returns true if the filename has an image extension."""
715  mimetype = mimetypes.guess_type(filename)[0]
716  if not mimetype:
717  return False
718  return mimetype.startswith("image/")
719 
720 
def IsImage(self, filename)
Definition: upload.py:713
def upload.VersionControlSystem.UploadBaseFiles (   self,
  issue,
  rpc_server,
  patch_list,
  patchset,
  options,
  files 
)
Uploads the base files (and if necessary, the current ones as well).

Definition at line 662 of file upload.py.

References upload.EncodeMultipartFormData(), and upload.StatusUpdate().

662  files):
663  """Uploads the base files (and if necessary, the current ones as well)."""
664 
665  def UploadFile(filename, file_id, content, is_binary, status, is_base):
666  """Uploads a file to the server."""
667  file_too_large = False
668  if is_base:
669  type = "base"
670  else:
671  type = "current"
672  if len(content) > MAX_UPLOAD_SIZE:
673  print ("Not uploading the %s file for %s because it's too large." %
674  (type, filename))
675  file_too_large = True
676  content = ""
677  checksum = md5.new(content).hexdigest()
678  if options.verbose > 0 and not file_too_large:
679  print "Uploading %s file for %s" % (type, filename)
680  url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id)
681  form_fields = [("filename", filename),
682  ("status", status),
683  ("checksum", checksum),
684  ("is_binary", str(is_binary)),
685  ("is_current", str(not is_base)),
686  ]
687  if file_too_large:
688  form_fields.append(("file_too_large", "1"))
689  if options.email:
690  form_fields.append(("user", options.email))
691  ctype, body = EncodeMultipartFormData(form_fields,
692  [("data", filename, content)])
693  response_body = rpc_server.Send(url, body,
694  content_type=ctype)
695  if not response_body.startswith("OK"):
696  StatusUpdate(" --> %s" % response_body)
697  sys.exit(1)
698 
699  patches = dict()
700  [patches.setdefault(v, k) for k, v in patch_list]
701  for filename in patches.keys():
702  base_content, new_content, is_binary, status = files[filename]
703  file_id_str = patches.get(filename)
704  if file_id_str.find("nobase") != -1:
705  base_content = None
706  file_id_str = file_id_str[file_id_str.rfind("_") + 1:]
707  file_id = int(file_id_str)
708  if base_content != None:
709  UploadFile(filename, file_id, base_content, is_binary, status, True)
710  if new_content != None:
711  UploadFile(filename, file_id, new_content, is_binary, status, False)
712 
def EncodeMultipartFormData(fields, files)
Definition: upload.py:498
def StatusUpdate(msg)
Definition: upload.py:97
def upload.VersionControlSystem.UploadBaseFiles (   self,
  issue,
  rpc_server,
  patch_list,
  patchset,
  options,
  files 
)
Uploads the base files (and if necessary, the current ones as well).

Definition at line 662 of file upload.py.

References upload.EncodeMultipartFormData(), and upload.StatusUpdate().

Referenced by upload.VersionControlSystem.GetBaseFiles().

662  files):
663  """Uploads the base files (and if necessary, the current ones as well)."""
664 
665  def UploadFile(filename, file_id, content, is_binary, status, is_base):
666  """Uploads a file to the server."""
667  file_too_large = False
668  if is_base:
669  type = "base"
670  else:
671  type = "current"
672  if len(content) > MAX_UPLOAD_SIZE:
673  print ("Not uploading the %s file for %s because it's too large." %
674  (type, filename))
675  file_too_large = True
676  content = ""
677  checksum = md5.new(content).hexdigest()
678  if options.verbose > 0 and not file_too_large:
679  print "Uploading %s file for %s" % (type, filename)
680  url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id)
681  form_fields = [("filename", filename),
682  ("status", status),
683  ("checksum", checksum),
684  ("is_binary", str(is_binary)),
685  ("is_current", str(not is_base)),
686  ]
687  if file_too_large:
688  form_fields.append(("file_too_large", "1"))
689  if options.email:
690  form_fields.append(("user", options.email))
691  ctype, body = EncodeMultipartFormData(form_fields,
692  [("data", filename, content)])
693  response_body = rpc_server.Send(url, body,
694  content_type=ctype)
695  if not response_body.startswith("OK"):
696  StatusUpdate(" --> %s" % response_body)
697  sys.exit(1)
698 
699  patches = dict()
700  [patches.setdefault(v, k) for k, v in patch_list]
701  for filename in patches.keys():
702  base_content, new_content, is_binary, status = files[filename]
703  file_id_str = patches.get(filename)
704  if file_id_str.find("nobase") != -1:
705  base_content = None
706  file_id_str = file_id_str[file_id_str.rfind("_") + 1:]
707  file_id = int(file_id_str)
708  if base_content != None:
709  UploadFile(filename, file_id, base_content, is_binary, status, True)
710  if new_content != None:
711  UploadFile(filename, file_id, new_content, is_binary, status, False)
712 
def EncodeMultipartFormData(fields, files)
Definition: upload.py:498
def StatusUpdate(msg)
Definition: upload.py:97
def upload.VersionControlSystem.UploadBaseFiles (   self,
  issue,
  rpc_server,
  patch_list,
  patchset,
  options,
  files 
)
Uploads the base files (and if necessary, the current ones as well).

Definition at line 662 of file upload.py.

References upload.EncodeMultipartFormData(), and upload.StatusUpdate().

662  files):
663  """Uploads the base files (and if necessary, the current ones as well)."""
664 
665  def UploadFile(filename, file_id, content, is_binary, status, is_base):
666  """Uploads a file to the server."""
667  file_too_large = False
668  if is_base:
669  type = "base"
670  else:
671  type = "current"
672  if len(content) > MAX_UPLOAD_SIZE:
673  print ("Not uploading the %s file for %s because it's too large." %
674  (type, filename))
675  file_too_large = True
676  content = ""
677  checksum = md5.new(content).hexdigest()
678  if options.verbose > 0 and not file_too_large:
679  print "Uploading %s file for %s" % (type, filename)
680  url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id)
681  form_fields = [("filename", filename),
682  ("status", status),
683  ("checksum", checksum),
684  ("is_binary", str(is_binary)),
685  ("is_current", str(not is_base)),
686  ]
687  if file_too_large:
688  form_fields.append(("file_too_large", "1"))
689  if options.email:
690  form_fields.append(("user", options.email))
691  ctype, body = EncodeMultipartFormData(form_fields,
692  [("data", filename, content)])
693  response_body = rpc_server.Send(url, body,
694  content_type=ctype)
695  if not response_body.startswith("OK"):
696  StatusUpdate(" --> %s" % response_body)
697  sys.exit(1)
698 
699  patches = dict()
700  [patches.setdefault(v, k) for k, v in patch_list]
701  for filename in patches.keys():
702  base_content, new_content, is_binary, status = files[filename]
703  file_id_str = patches.get(filename)
704  if file_id_str.find("nobase") != -1:
705  base_content = None
706  file_id_str = file_id_str[file_id_str.rfind("_") + 1:]
707  file_id = int(file_id_str)
708  if base_content != None:
709  UploadFile(filename, file_id, base_content, is_binary, status, True)
710  if new_content != None:
711  UploadFile(filename, file_id, new_content, is_binary, status, False)
712 
def EncodeMultipartFormData(fields, files)
Definition: upload.py:498
def StatusUpdate(msg)
Definition: upload.py:97
def upload.VersionControlSystem.UploadBaseFiles (   self,
  issue,
  rpc_server,
  patch_list,
  patchset,
  options,
  files 
)
Uploads the base files (and if necessary, the current ones as well).

Definition at line 662 of file upload.py.

References upload.EncodeMultipartFormData(), and upload.StatusUpdate().

662  files):
663  """Uploads the base files (and if necessary, the current ones as well)."""
664 
665  def UploadFile(filename, file_id, content, is_binary, status, is_base):
666  """Uploads a file to the server."""
667  file_too_large = False
668  if is_base:
669  type = "base"
670  else:
671  type = "current"
672  if len(content) > MAX_UPLOAD_SIZE:
673  print ("Not uploading the %s file for %s because it's too large." %
674  (type, filename))
675  file_too_large = True
676  content = ""
677  checksum = md5.new(content).hexdigest()
678  if options.verbose > 0 and not file_too_large:
679  print "Uploading %s file for %s" % (type, filename)
680  url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id)
681  form_fields = [("filename", filename),
682  ("status", status),
683  ("checksum", checksum),
684  ("is_binary", str(is_binary)),
685  ("is_current", str(not is_base)),
686  ]
687  if file_too_large:
688  form_fields.append(("file_too_large", "1"))
689  if options.email:
690  form_fields.append(("user", options.email))
691  ctype, body = EncodeMultipartFormData(form_fields,
692  [("data", filename, content)])
693  response_body = rpc_server.Send(url, body,
694  content_type=ctype)
695  if not response_body.startswith("OK"):
696  StatusUpdate(" --> %s" % response_body)
697  sys.exit(1)
698 
699  patches = dict()
700  [patches.setdefault(v, k) for k, v in patch_list]
701  for filename in patches.keys():
702  base_content, new_content, is_binary, status = files[filename]
703  file_id_str = patches.get(filename)
704  if file_id_str.find("nobase") != -1:
705  base_content = None
706  file_id_str = file_id_str[file_id_str.rfind("_") + 1:]
707  file_id = int(file_id_str)
708  if base_content != None:
709  UploadFile(filename, file_id, base_content, is_binary, status, True)
710  if new_content != None:
711  UploadFile(filename, file_id, new_content, is_binary, status, False)
712 
def EncodeMultipartFormData(fields, files)
Definition: upload.py:498
def StatusUpdate(msg)
Definition: upload.py:97
def upload.VersionControlSystem.UploadBaseFiles (   self,
  issue,
  rpc_server,
  patch_list,
  patchset,
  options,
  files 
)
Uploads the base files (and if necessary, the current ones as well).

Definition at line 662 of file upload.py.

References upload.EncodeMultipartFormData(), and upload.StatusUpdate().

662  files):
663  """Uploads the base files (and if necessary, the current ones as well)."""
664 
665  def UploadFile(filename, file_id, content, is_binary, status, is_base):
666  """Uploads a file to the server."""
667  file_too_large = False
668  if is_base:
669  type = "base"
670  else:
671  type = "current"
672  if len(content) > MAX_UPLOAD_SIZE:
673  print ("Not uploading the %s file for %s because it's too large." %
674  (type, filename))
675  file_too_large = True
676  content = ""
677  checksum = md5.new(content).hexdigest()
678  if options.verbose > 0 and not file_too_large:
679  print "Uploading %s file for %s" % (type, filename)
680  url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id)
681  form_fields = [("filename", filename),
682  ("status", status),
683  ("checksum", checksum),
684  ("is_binary", str(is_binary)),
685  ("is_current", str(not is_base)),
686  ]
687  if file_too_large:
688  form_fields.append(("file_too_large", "1"))
689  if options.email:
690  form_fields.append(("user", options.email))
691  ctype, body = EncodeMultipartFormData(form_fields,
692  [("data", filename, content)])
693  response_body = rpc_server.Send(url, body,
694  content_type=ctype)
695  if not response_body.startswith("OK"):
696  StatusUpdate(" --> %s" % response_body)
697  sys.exit(1)
698 
699  patches = dict()
700  [patches.setdefault(v, k) for k, v in patch_list]
701  for filename in patches.keys():
702  base_content, new_content, is_binary, status = files[filename]
703  file_id_str = patches.get(filename)
704  if file_id_str.find("nobase") != -1:
705  base_content = None
706  file_id_str = file_id_str[file_id_str.rfind("_") + 1:]
707  file_id = int(file_id_str)
708  if base_content != None:
709  UploadFile(filename, file_id, base_content, is_binary, status, True)
710  if new_content != None:
711  UploadFile(filename, file_id, new_content, is_binary, status, False)
712 
def EncodeMultipartFormData(fields, files)
Definition: upload.py:498
def StatusUpdate(msg)
Definition: upload.py:97
def upload.VersionControlSystem.UploadBaseFiles (   self,
  issue,
  rpc_server,
  patch_list,
  patchset,
  options,
  files 
)
Uploads the base files (and if necessary, the current ones as well).

Definition at line 662 of file upload.py.

References upload.EncodeMultipartFormData(), and upload.StatusUpdate().

662  files):
663  """Uploads the base files (and if necessary, the current ones as well)."""
664 
665  def UploadFile(filename, file_id, content, is_binary, status, is_base):
666  """Uploads a file to the server."""
667  file_too_large = False
668  if is_base:
669  type = "base"
670  else:
671  type = "current"
672  if len(content) > MAX_UPLOAD_SIZE:
673  print ("Not uploading the %s file for %s because it's too large." %
674  (type, filename))
675  file_too_large = True
676  content = ""
677  checksum = md5.new(content).hexdigest()
678  if options.verbose > 0 and not file_too_large:
679  print "Uploading %s file for %s" % (type, filename)
680  url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id)
681  form_fields = [("filename", filename),
682  ("status", status),
683  ("checksum", checksum),
684  ("is_binary", str(is_binary)),
685  ("is_current", str(not is_base)),
686  ]
687  if file_too_large:
688  form_fields.append(("file_too_large", "1"))
689  if options.email:
690  form_fields.append(("user", options.email))
691  ctype, body = EncodeMultipartFormData(form_fields,
692  [("data", filename, content)])
693  response_body = rpc_server.Send(url, body,
694  content_type=ctype)
695  if not response_body.startswith("OK"):
696  StatusUpdate(" --> %s" % response_body)
697  sys.exit(1)
698 
699  patches = dict()
700  [patches.setdefault(v, k) for k, v in patch_list]
701  for filename in patches.keys():
702  base_content, new_content, is_binary, status = files[filename]
703  file_id_str = patches.get(filename)
704  if file_id_str.find("nobase") != -1:
705  base_content = None
706  file_id_str = file_id_str[file_id_str.rfind("_") + 1:]
707  file_id = int(file_id_str)
708  if base_content != None:
709  UploadFile(filename, file_id, base_content, is_binary, status, True)
710  if new_content != None:
711  UploadFile(filename, file_id, new_content, is_binary, status, False)
712 
def EncodeMultipartFormData(fields, files)
Definition: upload.py:498
def StatusUpdate(msg)
Definition: upload.py:97

Member Data Documentation

upload.VersionControlSystem.options

Definition at line 597 of file upload.py.

Referenced by upload.VersionControlSystem.__init__().


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