Module: Amp::Repositories::CommonVersionedFileMethods

Included in:
AbstractVersionedFile
Defined in:
lib/amp/repository/abstract/common_methods/versioned_file.rb

Overview

CommonVersionedFileMethods

These methods are common to all repositories, and this module is mixed into the AbstractLocalRepository class. This guarantees that all repositories will have these methods.

No methods should be placed into this module unless it relies on methods in the general API for repositories.

Instance Method Summary collapse

Instance Method Details

#===(other) ⇒ Boolean

Compares two versioned files - namely, their data.

Parameters:

  • other (VersionedFile)

    what to compare to

Returns:

  • (Boolean)

    true if the two are the same



27
28
29
30
# File 'lib/amp/repository/abstract/common_methods/versioned_file.rb', line 27

def ===(other)
  self.path == other.path &&
  self.data == other.data
end

#branchString

The branch this tracked file belongs to

Returns:



64
# File 'lib/amp/repository/abstract/common_methods/versioned_file.rb', line 64

def branch; changeset.branch; end

#childrenObject

Working directory has no children!



68
# File 'lib/amp/repository/abstract/common_methods/versioned_file.rb', line 68

def children; []; end

#clean?Boolean

Returns if the file has been changed since its parent. Slow. If your implementation has a fast way of doing this, we recommend you override this method.

Returns:

  • (Boolean)

    has the file been changed since its parent?



37
38
39
# File 'lib/amp/repository/abstract/common_methods/versioned_file.rb', line 37

def clean?
  self === parents.first
end

#dateDateTime

Date this revision to this file was committed

Returns:

  • (DateTime)


52
# File 'lib/amp/repository/abstract/common_methods/versioned_file.rb', line 52

def date; changeset.date; end

#descriptionString

The description of the commit that contained this file revision

Returns:



58
# File 'lib/amp/repository/abstract/common_methods/versioned_file.rb', line 58

def description; changeset.description; end

#unified_diff_with(other_vf, opts = {}) ⇒ Object



15
16
17
18
19
20
# File 'lib/amp/repository/abstract/common_methods/versioned_file.rb', line 15

def unified_diff_with(other_vf, opts = {})    
  Diffs::Mercurial::MercurialDiff.unified_diff(self.data, self.changeset.easy_date, 
                                               other_vf.data, other_vf.changeset.easy_date,
                                               self.path, other_vf.path || "/dev/null", 
                                               false, opts)
end

#userString

User who committed this revision to this file

Returns:



46
# File 'lib/amp/repository/abstract/common_methods/versioned_file.rb', line 46

def user; changeset.user; end